Instantly share code, notes, and snippets.

Embed
What would you like to do?
Service Worker Killer
// ==UserScript==
// @name Service Worker Killer
// @version 0.3.0
// @description Unregister ServiceWorker(s) before page unload
// @author Gavin Lloyd <gavinhungry@gmail.com>
// @match *
// @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