Greasy Fork is available in English.

Tumblr Classic Blue

Change Tumblr's blue to classic blue

Version vom 2019-01-30 21:15:12 UTC. Aktuellste Version

// ==UserScript==
// @name         Tumblr Classic Blue
// @namespace    tumblrClassicTheme_kk
// @description  Change Tumblr's blue to classic blue
// @version      1.0
// @author       Kai Krause <kaikrause95@gmail.com>
// @match        http://*.tumblr.com/*
// @match        https://*.tumblr.com/*
// @run-at       document-start
// @grant        none
// ==/UserScript==

var bgColor = "rgb(0, 25, 53)";
var classicBgColorCSS = ".classicBG_KK{background: #36465D !important;}";

var cachedElements = [];
var cssCheck = '';
function classicBackgroundCSS() {
	if (cssCheck.length < 1) {
		var classicBG_KK = document.createElement("style");
		classicBG_KK.innerText = classicBgColorCSS;
		document.head.appendChild(classicBG_KK);
		cssCheck = document.getElementsByClassName("classicBG_KK");
	}
	applyCSS("classicBG_KK");
}

function applyCSS (className) {
	var allElements = document.querySelectorAll('*');
	for (var i = 0; i < allElements.length; i++) {
		var element = allElements[i];
		if (cachedElements.indexOf(element) > -1) continue;
		cachedElements.push(element);
		setCSS(element, className);
	}
}

function setCSS(element, className) {
	setTimeout(function(){
		console.log(element)
		var elementComputed = window.getComputedStyle(element, null);
		var backgroundColor = elementComputed.getPropertyValue("background");
		if (backgroundColor && backgroundColor.includes(bgColor)) {
			element.classList.add(className);
		}
	}, Math.random(4,12));
}

// Page Load
classicBackgroundCSS();

// constantly check for css every second while page is loading
var x = setInterval(() => {
	classicBackgroundCSS();
}, 10);

// delete the above interval after a number of seconds
setTimeout(() => {
	clearInterval(x);
}, 2500);