// ==UserScript== // @name 自研 - 萌娘百科 - 切换文字遮罩 // @name:en_US Self-made - MoeGirl - Switch text mask // @description 按下`.`键或菜单命令,即可切换文字遮罩展示或隐藏。 // @description:en_US Press the `.` key or use the menu command to toggle the display of text masks on or off. // @version 1.0.3 // @author CPlayerCHN // @license MulanPSL-2.0 // @namespace https://www.gitlink.org.cn/CPlayerCHN // @match *://zh.moegirl.org.cn/* // @match *://mzh.moegirl.org.cn/* // @match *://mobile.moegirl.org.cn/* // @match *://moegirl.uk/* // @match *://moegirl.icu/* // @grant GM_addStyle // @grant GM_registerMenuCommand // @run-at document-end // @noframes // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 调整样式 GM_addStyle('/*修改动效*/ .heimu, .heimu a { transition: color 0.15s cubic-bezier(0.00, 0.00, 0.40, 1.00) !important } /*去除遮罩*/ body.show-mask .heimu, body.show-mask .colormu > span { color: #FFFFFF !important } body.show-mask .hovers-blur { filter: blur(.5px) } body.show-mask .heimu a { color: #5291FF !important } /*美化链接*/ a { color: #0A59F7 }'); // 定义「重复触发」变量和「切换展示遮罩」函数。 var repeat = false; function switcher() { if(/show-mask/.test(document.body.className)) { document.body.classList.remove("show-mask"); }else { document.body.classList.add("show-mask"); } } // 运行「切换展示遮罩」函数,并注册相关菜单命令。 switcher(); GM_registerMenuCommand('切换隐藏与显示', () => switcher() ); // 监听按下`.`键且非重复触发就,设置为重复触发并切换显示状态。 addEventListener("keydown", (data) => { if(!repeat && data.key === ".") { repeat = true; switcher(); } }); // 监听抬起`.`键且重复触发就,恢复「重复触发」状态。 addEventListener("keyup", (data) => { if(repeat) { repeat = false; } }); // 移除悬浮文字。 document.querySelectorAll('.heimu, .colormu, .hovers-blur').forEach((ele) => { ele.removeAttribute('title'); }); })();