// ==UserScript== // @name 标签页标题隐藏!隐私保护! // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.2.3 // @description 是否还在担心你偷偷看小视频被别人发现?是否担心切去其他标签页的时候页面还在但标题暴露了你在看什么?那就试试这个吧! // @author i白羽 // @match http*://*/* // @grant GM_getValue // ==/UserScript== /* ==UserConfig== 隐私保护设置: type: title: 隐藏方式 description: 高斯模糊:使用高斯模糊直接隐藏内容|降低透明度:直接让整个页面变空白 type: select default: 高斯模糊 values: ["高斯模糊", "降低透明度"] isTransition: title: 渐变效果 description: 渐变显示效果,transition实现 type: checkbox default: true blur: title: 高斯模糊值(单位:px) description: 高斯模糊的值,如果选择直接隐藏,该配置不生效. type: number default: 80 sleep: title: 延迟显示(单位:ms) description: 默认参数为1500ms,如果为0,立刻显示内容,当使用渐变效果,将会变成动画的持续效果,否则使用settimeout type: number default: 1500 ==/UserConfig== */ (function () { const INCLUDE_HOST = [ "", ] const CONFIG = { type: GM_getValue("隐私保护设置.type", "高斯模糊") === "高斯模糊" ? "blur" : "opacity", isTransition: GM_getValue("隐私保护设置.isTransition") ?? true, blur: GM_getValue("隐私保护设置.blur") ?? 80, sleep: GM_getValue("隐私保护设置.sleep") ?? 1500 } if (INCLUDE_HOST.indexOf(location.host) === -1) { return undefined; } window.addEventListener('load', () => { const TITLE = document.title; const styleEl = document.createElement('style'); styleEl.innerHTML = ` .scriptcat-transition { transition-property: opacity, filter; transition-duration: ${CONFIG.sleep}ms; } .scriptcat-blur { filter: blur(${CONFIG.blur}px); } .scriptcat-opacity { opacity: 0; } `; document.body.append(styleEl); window.addEventListener('focus', async () => { const handler = function () { document.title = TITLE; CONFIG.type === "blur" ? document.body.classList.remove('scriptcat-blur') : document.body.classList.remove('scriptcat-opacity'); } if (!CONFIG.isTransition) { if (CONFIG.sleep !== 0) await new Promise(resolve => setTimeout(() => resolve(), CONFIG.sleep)); } else { document.body.classList.add('scriptcat-transition'); } handler(); }); window.addEventListener('blur', () => { document.body.classList.remove('scriptcat-transition'); document.title = "好好学习,天天向上"; CONFIG.type === "blur" ? document.body.classList.add('scriptcat-blur') : document.body.classList.add('scriptcat-opacity'); }) }) })()