您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Darkens web pages without changing the funcionality of a page. Improve night reading.
// ==UserScript== // @name Darken Website // @namespace https://theusaf.org // @version 1.0.2 // @description Darkens web pages without changing the funcionality of a page. Improve night reading. // @author theusaf // @icon https://www.google.com/s2/favicons?sz=64&domain=x.com // @match *://*/* // @license MIT // @grant none // @noframes // @run-at document-body // ==/UserScript== if (window.parent === window) { const template = document.createElement("template"); template.innerHTML = `<div class="darken-website-usaf" style=" position: fixed; top: 0; z-index: 99999; width: 100%; height: 100%; pointer-events: none; background: black; opacity: 0; left: 0; "></div>`; const specialElements = new Set(); document.body.append(template.content.cloneNode(true)); if (sessionStorage.enableDark === "true") { sessionStorage.enableDark = false; toggleDark(); } window.addEventListener("fullscreenchange", (e) => { const { target } = e, darkenApplies = !!target.querySelector(".darken-website-usaf"); if (!darkenApplies) { if (document.fullscreenElement) { // Entering full screen if (target.tagName === "IFRAME" || target.tagName === "VIDEO") { target.style.opacity = sessionStorage.enableDark == "true" ? 1 - (+localStorage.darkVal || 0.7) : 1; specialElements.add(target); } else { target.append(template.content.cloneNode(true)); toggleDark(); toggleDark(); } } else { // Exiting full screen if (target.tagName === "IFRAME" || target.tagName === "VIDEO") { target.style.opacity = ""; specialElements.delete(target); } else { target.querySelector(".darken-website-usaf")?.remove(); } } } }); window.addEventListener("keydown", (e) => { if (e.altKey && e.ctrlKey) { switch (e.code) { case "KeyC": { changeDark(); e.preventDefault(); e.stopImmediatePropagation(); break; } case "KeyD": { toggleDark(); e.preventDefault(); e.stopImmediatePropagation(); break; } } } }); function changeDark() { const n = +prompt("Enter darkness value", localStorage.darkVal || 0.7); if (!isNaN(n)) { localStorage.darkVal = n || 0.7; } toggleDark(); toggleDark(); return true; } function toggleDark() { let darks = document.querySelectorAll(".darken-website-usaf"); if (darks.length === 0) { document.body.append(template.content.cloneNode(true)); darks = document.querySelectorAll(".darken-website-usaf"); } for (let i = 0; i < darks.length; i++) { // Toggle darkness darks[i].style.opacity = sessionStorage.enableDark == "true" ? 0 : +localStorage.darkVal || 0.7; } sessionStorage.enableDark = sessionStorage.enableDark == "true" ? false : true; return true; } } else { console.log("[DARKEN] - Ignoring frame"); }
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址