// ==UserScript== // @name 修改网页颜色 // @namespace http://tampermonkey.net/ // @version 0.1.0 // @author yhu // @description 这是一个非常简便的修改网页颜色,只需点一下文字,然后输入rgb即可 // @match *://*/* // @grant none // ==/UserScript== (function() { 'use strict'; document.body.addEventListener('click', function(e) { let target = e.target; if (target.nodeType === 3) { target = target.parentNode; } if (target.tagName && target.tagName.toLowerCase() === 'input') { return; } e.preventDefault(); e.stopPropagation(); const rgbInput = prompt('输入RGB(使用空格分离)', '如蓝色:0 0 255'); if (rgbInput) { const parts = rgbInput.trim().split(/\s+/); if (parts.length === 3) { const r = parseInt(parts[0]); const g = parseInt(parts[1]); const b = parseInt(parts[2]); if (!isNaN(r) && !isNaN(g) && !isNaN(b)) { target.style.color = `rgb(${r}, ${g}, ${b})`; } else { alert('无效'); } } else { alert('请输入三个数字(使用空格分离)'); } } }, true); })();