您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
调整网页亮度,护眼
当前为
// ==UserScript== // @name 调整网页亮度 // @namespace http://tampermonkey.net/ // @version 0.4 // @description 调整网页亮度,护眼 // @description:en Adjust page brightness,eyeshield // @author wodexianghua // @match http://*/* // @match https://*/* // @match file:///* // @grant GM_setValue // @grant GM_getValue // ==/UserScript== (function () { 'use strict'; //保证iframe不起作用 if (self == top) { var timer = null; var mousemove = false; var liangduui; var liangduuitz; var liangduuitzmouse; var __nightingale_view_cover; function insertHTML(lv) { if (self == top) { document.body.insertAdjacentHTML("beforebegin", '<div class="liangduui" style="display: none; width: 60px; height: 170px; background-color: rgb(255, 255, 255); z-index: 2147483640; position: fixed; top: 200px; left: 50%; border-radius: 50px; box-shadow: rgb(74, 74, 74) 0px 0px 20px;"><div class="liangduuitzmouse" style="width:40%;height:100px;background-color:#cecece;position:absolute;top:20px;left:30%;border-radius:50px;cursor:pointer"><div class="liangduuitz" style="width: 100%; height: 100%; background-color: rgb(147, 112, 223); position: absolute; bottom: 0px; right: 0px; border-radius: 50px;"></div></div><div style="background-image:url(https://www.easyicon.net/api/resizeApi.php?id=1180288&size=24);width:24px;height:24px;position:absolute;bottom:15px;right:18px;border-radius:50%;box-shadow:0 0 10px #9370df;background-repeat:no-repeat"></div></div><div id="__nightingale_view_cover" style="width: 100%; height: 100%; transition: -webkit-transform 10s ease-in-out 0s; position: fixed !important; left: 0px !important; bottom: 0px !important; overflow: hidden !important; background: rgb(0, 0, 0) !important; pointer-events: none !important; z-index: 2147483647; opacity: ' + lv + ';"></div>'); } liangduui = document.querySelector(".liangduui"); liangduuitz = document.querySelector(".liangduuitz"); liangduuitzmouse = document.querySelector(".liangduuitzmouse"); __nightingale_view_cover = document.querySelector("#__nightingale_view_cover"); liangduui.style.top = ((window.innerHeight / 2) - (liangduui.style.height.replace("px", "")/2)) + "px"; liangduui.style.left = ((window.innerWidth / 2) - (liangduui.style.width.replace("px", "")/2)) + "px"; liangduuitzmouse.addEventListener('mousedown', function (event) { mousemove = true; liangduuitz.style.height = (100 - (event.clientY - liangduui.offsetTop - liangduuitzmouse.offsetTop)) + "%" lv = (event.clientY - liangduui.offsetTop - liangduuitzmouse.offsetTop) / 100; GM_setValue("lv", lv); __nightingale_view_cover.style.opacity = lv }); liangduuitzmouse.addEventListener('mousemove', function (event) { if (!mousemove) return; if (liangduuitz.offsetTop <= 0 || liangduuitz.offsetTop > 100) return; liangduuitz.style.height = (100 - (event.clientY - liangduui.offsetTop - liangduuitzmouse.offsetTop)) + "%" lv = (event.clientY - liangduui.offsetTop - liangduuitzmouse.offsetTop) / 100; GM_setValue("lv", lv); __nightingale_view_cover.style.opacity = lv }); liangduuitzmouse.addEventListener('mouseup', function (event) { mousemove = false; }); } if (GM_getValue("lv") == undefined) { GM_setValue("lv", '0.35'); } document.addEventListener('keydown', function (event) { if (event.altKey && event.which == 40) { var lv = parseFloat(GM_getValue("lv")); lv += 0.02; if (lv > 1.0) lv = 1.0; GM_setValue('lv', lv); __nightingale_view_cover.style.opacity = lv; liangduui.style.display = "block"; liangduuitz.style.height = (100 - (lv * 100)) + "%"; window.clearTimeout(timer); timer = setTimeout(function () { liangduui.style.display = "none"; }, 2000); } else if (event.altKey && event.which == 38) { var lv = parseFloat(GM_getValue("lv")); lv -= 0.02; if (lv < 0) lv = 0; GM_setValue("lv", lv); __nightingale_view_cover.style.opacity = lv; liangduui.style.display = "block"; liangduuitz.style.height = (100 - (lv * 100)) + "%"; window.clearTimeout(timer); timer = setTimeout(function () { liangduui.style.display = "none"; }, 2000); } else if (event.ctrlKey && event.altKey && event.which == 83) { liangduuitz.style.height = (100 - (GM_getValue("lv") * 100)) + "%" liangduui.style.display = "block"; } }); document.addEventListener('visibilitychange', function () { if (document.visibilityState == 'hidden') { //状态判断 } else { var lv = parseFloat(GM_getValue("lv")); if (document.querySelector("#__nightingale_view_cover") == null) { insertHTML(GM_getValue("lv")); } GM_setValue("lv", lv); document.querySelector("#__nightingale_view_cover").style.opacity = lv } }); document.body.addEventListener('click', function () { liangduui.style.display = "none"; mousemove = false; }); // window.addEventListener("storage", function(event) { // console.log(event.key + '=' +event.newValue); // }); setTimeout(insertHTML(GM_getValue("lv")), 300); } // Your code here... })();