Jump to content

User:Scholar596440/timeless.js: Difference between revisions

From Wikipedia, the free encyclopedia
Content deleted Content added
No edit summary
No edit summary
Line 27: Line 27:
};
};
if (node.style.background.includes(node.style["border-color"]) && node.tagName !== "button") {
if ([node.style.background, ""].includes(node.style["border-color"]) && node.tagName !== "button") {
style["border-color"] = style.background;
style["border-color"] = style.background;
} else {
console.log(node.style["border-color"]);
}
}
if (node.tagName === "A") {
if (node.tagName === "A") {
style.color = "#BBBBFF";
style.color = "#BBBBFF";
}
if (node.src === "/enwiki/static/images/mobile/copyright/wikipedia-wordmark-en.svg" || node.src === "/enwiki/static/images/mobile/copyright/wikipedia.png") {
node.remove()
}
}

Revision as of 05:54, 17 June 2021

function list(obj) {
	var total = [];
	for (var i = 0; i < obj.length; i++) {
		total.push(obj[i]);
	}
	return total;
}

function concatf(a, c) {
	return a.concat(c);
}

function children(n) {
	return [n].concat(list(n.children).map(children).reduce(concatf, []));
}

function all() {
	return children(document.querySelector("body"));
}


function style(node) {
	var style = {
		"background": "#080818",
		"color": "white",
		"font-family": "monospace",
	};
	
	if ([node.style.background, ""].includes(node.style["border-color"]) && node.tagName !== "button") {
		style["border-color"] = style.background;
	}
	
	if (node.tagName === "A") {
		style.color = "#BBBBFF";
	}
	
	return style;
}

function mod(i) {
	for (var key in style(i)) {
		i.style[key] = style(i)[key];
	}
}

all().forEach(mod);