Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Bookmark Builder
<!DOCTYPE html>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
window.onload = function(e) {
var bookmark = document.getElementById("bookmark");
var code = document.getElementById("code");
var script = document.getElementById("script");
bookmark.href = "javascript: "+ encodeURIComponent("(function() { " + script.textContent + "}())");
<a id="bookmark" href="">Unregsiter Service Worker</a>
<div id="code"></div>
<script id="script">
var sw = navigator.serviceWorker;
if (sw.controller) {
sw.getRegistration(document.location).then(function(reg) { return reg.unregister(); }).then(function() { console.log("Unregister Successful") }).catch(function(e) { console.log("No Service Worker: " + e)});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment