您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
阻止Service Worker注册,并移除现有的Service Workers,杜绝网上垃圾。
当前为
// ==UserScript== // @name Block Service Workers // @name:zh-CN 禁用Service Workers // @namespace Violentmonkey Scripts // @match *://*/* // @grant GM_addElement // @grant GM_info // @version 0.5 // @grant GM_log // @author axototl // @license Unlicense // @description Blocks Service Worker's registration. // @description:zh-CN 阻止Service Worker注册,并移除现有的Service Workers,杜绝网上垃圾。 // @icon https://www.w3.org/favicon.ico // @run-at document-start // ==/UserScript== 'use strict'; async function main () { console.groupCollapsed("remove SW APIs"); if (!('serviceWorker' in navigator)) { console.warn("Did not detected SW APIs, exiting..."); console.groupEnd(); return; } console.log("Removing Service Workers API, please wait..."); navigator.serviceWorker.register = () => new Promise((res, rej) => rej("This method is not allowed!")); console.log("Deregistering Installed Service Workers, please wait..."); const arrs = await navigator.serviceWorker.getRegistrations(); for (const it of arrs) it.unregister(); console.log("All done!"); console.groupEnd(); } if (GM_info.injectInto === 'page' || GM_info.sandboxMode === "raw") main(); else { const blobURL = URL.createObjectURL(new Blob([`(${main.toString()})();`], {type: "text/javascript"})); GM_addElement("script", {src: blobURL}).onload = () => URL.revokeObjectURL(blobURL); }