Block Service Workers

Blocks Service Worker's registration.

Version vom 03.10.2023. Aktuellste Version

Du musst eine Erweiterung wie Tampermonkey, Greasemonkey oder Violentmonkey installieren, um dieses Skript zu installieren.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

Sie müssten eine Skript Manager Erweiterung installieren damit sie dieses Skript installieren können

(Ich habe schon ein Skript Manager, Lass mich es installieren!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name        Block Service Workers
// @name:zh-CN  禁用Service Workers
// @namespace   Violentmonkey Scripts
// @match       *://*/*
// @unwrap
// @version     0.2
// @author      axototl
// @inject-into page
// @sandbox     JavaScript
// @license     AGPL-3.0-or-later
// @description Blocks Service Worker's registration.
// @description:zh-CN 阻止Service Worker,并移除现有的Service Worker,杜绝网上垃圾。
// @run-at      document-start
// ==/UserScript==

(() => {
    'use strict';
    if (!('serviceWorker' in navigator)) 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...");
    (async () => {
        let arrs = await navigator.serviceWorker.getRegistrations();
        for (const it of arrs) it.unregister();
    })();
    console.log("All done!");
    // GM_registerMenuCommand("注销Service Workers", logout);
})();