// ==UserScript== // @name 舍利护眼 - 用科技保护健康 // @namespace eye-safe-mode // @author 茹莱本座 // @version 1.02 // @license LGPL // @description 自由调节护眼功能,最好的护眼模式插件 // @grant GM_setValue // @grant GM_getValue // @grant GM_deleteValue // @grant none // @require https://code.jquery.com/jquery-3.4.0.js // @include *://*/* // @downloadURL https://update.greasyfork.icu/scripts/492390/%E8%88%8D%E5%88%A9%E6%8A%A4%E7%9C%BC%20-%20%E7%94%A8%E7%A7%91%E6%8A%80%E4%BF%9D%E6%8A%A4%E5%81%A5%E5%BA%B7.user.js // @updateURL https://update.greasyfork.icu/scripts/492390/%E8%88%8D%E5%88%A9%E6%8A%A4%E7%9C%BC%20-%20%E7%94%A8%E7%A7%91%E6%8A%80%E4%BF%9D%E6%8A%A4%E5%81%A5%E5%BA%B7.meta.js // ==/UserScript== $($("*")[0]).append("
舍利护眼管理面板
关于



12345678


hello world


保存
应用
重置
") window.slhy = new Object(); slhy.saveConfig = function (configStr) { GM_setValue("slhy_cfg", configStr); } slhy.readConfig = function () { return slhy.decodeConfig(GM_getValue("slhy_cfg", "background_color:darkgrey;color:skyblue;font_size:5mm;word_spacing:1.5")); } slhy.encodeConfig = function (configObj) { return Object.entries(configObj).map((co) => co[0] + ":" + co[1] + ";").join("").replace(/\;$/, ""); } slhy.decodeConfig = function (configStr) { return Object.fromEntries(configStr.split(";").filter((co) => typeof co === typeof "" && !co.trim() == "").map((co) => co.split(":"))); } slhy.updateCSS = function (cssObj) { if ($("#slhycss").length === 0) { $("head").append(""); } $("#slhycss").text("* {" + Object.entries(cssObj).map((cp) => cp[0].replaceAll("_", "-") + ": " + cp[1] + "; ").join("") + "}"); } slhy.resetConfig = function () { slhy.css = { background_color: "darkgrey", color: "skyblue", font_size: "5mm", word_spacing: "1.5" }; GM_deleteValue("slhy_css"); updateCSS(); window.location.reload(); } slhy._BuildRGBColorStr = function (r, g, b) { return "rgb(" + r + "," + g + "," + b + ")"; } slhy._bgColorRInputElem = $(".slhy_bigsub input")[0]; slhy._bgColorGInputElem = $(".slhy_bigsub input")[1]; slhy._bgColorBInputElem = $(".slhy_bigsub input")[2]; slhy._colorRInputElem = $(".slhy_bigsub input")[3]; slhy._colorGInputElem = $(".slhy_bigsub input")[4]; slhy._colorBInputElem = $(".slhy_bigsub input")[5]; slhy._fontSizeInputElem = $(".slhy_bigsub input")[6]; slhy._wordSpacingInputElem = $(".slhy_bigsub input")[7]; slhy._bgColorPreviewBox = $("#slhy_previewBGColor"); slhy._colorPreviewBox = $("#slhy_previewTColor"); slhy._fontSizePreviewBox = $("#slhy_previewTSize"); slhy._wordSpacingPreviewBox = $("#slhy_previewWSpacing"); slhy.css = slhy.readConfig(); $("#slhy_apply_button").click(slhy.updateCSS); $("#slhy_reset_button").click(slhy.resetConfig); $("#slhy_save_button").click(() => {slhy.saveConfig(slhy.encodeConfig(slhy.css))}); slhy._bgColorRInputElem.on("input", slhy.updateBgColorPreview); slhy._bgColorGInputElem.on("input", slhy.updateBgColorPreview); slhy._bgColorBInputElem.on("input", slhy.updateBgColorPreview); slhy._colorRInputElem.on("input", slhy.updateColorPreview); slhy._colorGInputElem.on("input", slhy.updateColorPreview); slhy._colorBInputElem.on("input", slhy.updateColorPreview); slhy._fontSizeInputElem.on("input", slhy.updateFontSizePreview); slhy._wordSpacingInputElem.on("input". slhy.updateWordSpacingPreview) slhy.updateBgColorPreview = function () { slhy._bgColorPreviewBox.style.backgroundColor = slhy.css.background_color; } slhy.updateColorPreview = function () { slhy._colorPreviewBox.style.color = slhy.css.color; } slhy.updateFontSizePreview = function () { slhy._fontSizePreviewBox.style.fontSize = slhy.css.font_size; } slhy.updateWordSpacingPreview = function () { slhy._wordSpacingPreviewBox.style.wordSpacing = slhy.css.word_spacing }