Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Bookmark Builder
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<title>Bookmarklet</title>
<script>
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 + "}())");
};
</script>
</head>
<body>
<a id="bookmark" href="">Unregsiter Service Worker</a>
<div id="code"></div>
</body>
<script id="script">
console.log("test");
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)});
}
</script>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.