纸墨模式

简单地模拟报纸阅读模式,将背景颜色改为更柔和的颜色。

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

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

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==UserScript==
// @name            纸墨模式
// @name:zh-CN      纸墨模式
// @name:en         NewsPaper Mode
// @version         0.1
// @description     简单地模拟报纸阅读模式,将背景颜色改为更柔和的颜色。
// @description:en  Easy NewsPaper Mode, Reduce Background Color.
// @author          RunningCheese
// @namespace       https://www.runningcheese.com
// @license         MIT
// @match           *://*/*
// @icon            data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAAAAXNSR0IArs4c6QAAAERlWElmTU0AKgAAAAgAAYdpAAQAAAABAAAAGgAAAAAAA6ABAAMAAAABAAEAAKACAAQAAAABAAAAEKADAAQAAAABAAAAEAAAAAA0VXHyAAAAVUlEQVQ4EWNgoBAwIun/j8QmhgnWy4Ks8vXri8hcnGxRUX24HIoBIFFkSbgqKAObBRgGYFOEbhAyH8OAURcM1ljAF7UY0YhPMXL8w9gU5wWYQQNHAwA59SFyGEDyYwAAAABJRU5ErkJggg==
// ==/UserScript==


(function() {
	function getRGBColor(node, prop) {
		var rgb = getComputedStyle(node, null)
			.getPropertyValue(prop);
		var r, g, b;
		if (/rgb\((\d+),\s(\d+),\s(\d+)\)/.exec(rgb)) {
			r = parseInt(RegExp.$1, 10);
			g = parseInt(RegExp.$2, 10);
			b = parseInt(RegExp.$3, 10);
			return [r / 255, g / 255, b / 255];
		}
		return rgb;
	}
	R(document.documentElement);

	function R(n) {
		var i, x, color;
		if (n.nodeType == Node.ELEMENT_NODE && n.tagName.toLowerCase() != 'input' && n.tagName.toLowerCase() != 'select' && n.tagName.toLowerCase != 'textarea') {
			for (i = 0; x = n.childNodes[i]; ++i) R(x);
			color = getRGBColor(n, 'background-color');
			if ((typeof(color) != 'string' && color[0] + color[1] + color[2] >= 2.8) || (n == document.documentElement && color == 'transparent')) {
				n.style.backgroundColor = '#f5f5f5';
				n.style.setProperty('background-color', '#f5f5f5', 'important');
			}
		}
	}
})()