Skip to content

Instantly share code, notes, and snippets.

@gavinhungry
Last active December 21, 2022 19:30
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gavinhungry/f5e7137c558a801476dc358b1a7a8bf4 to your computer and use it in GitHub Desktop.
Save gavinhungry/f5e7137c558a801476dc358b1a7a8bf4 to your computer and use it in GitHub Desktop.
Service Worker Killer
// ==UserScript==
// @name Service Worker Killer
// @version 0.4.0
// @description Unregister ServiceWorker(s) before page unload
// @author Gavin Lloyd <gavinhungry@gmail.com>
// @match http://*/*
// @match https://*/*
// @grant none
// ==/UserScript==
(() => {
window.addEventListener('beforeunload', () => {
navigator.serviceWorker.getRegistrations().then(serviceWorkers => {
serviceWorkers.forEach(serviceWorker => serviceWorker.unregister());
});
});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment