Clean Font Weights

Make website font-weights standard (400) if below 400

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Clean Font Weights
// @namespace    cleanFonts_kk
// @description  Make website font-weights standard (400) if below 400
// @version      0.7
// @author       Kai Krause <[email protected]>
// @include      *
// @run-at       document-idle
// @grant        none
// ==/UserScript==

var cachedElements = [];
var fontCheck = '';
function font() {
	if (fontCheck.length < 1) {
		var fontOverride_kk = document.createElement("style");
		fontOverride_kk.innerText = ".fontOverride_kk{font-weight: 400 !important;}";
		document.head.appendChild(fontOverride_kk);
		fontCheck = document.getElementsByClassName("fontOverride_kk");
	}

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

function applyFont (allElements, i) {
	setTimeout(function(){
		var css = window.getComputedStyle(allElements[i], null);
		var fontWeight = css.getPropertyValue("font-weight");
		if (fontWeight && fontWeight < 400) {
			allElements[i].classList.add("fontOverride_kk");
		}
	}, Math.random(4,12));
}

// Page Load
font();

// Peformant Dynamic function wrapper
var oldScrollPos = 0;
function dynamicScroll (f) {
	window.addEventListener("scroll", (function(){
		var scrollDifference = Math.abs(oldScrollPos-window.scrollY);
		if (scrollDifference > 500) {
			window.requestAnimationFrame(f);
			oldScrollPos = window.scrollY;
		}
	}), false);
}
dynamicScroll(font);