Skip to content

Instantly share code, notes, and snippets.

@arpruss
Created August 12, 2018 21:06
Show Gist options
  • Save arpruss/7ef2e4945aadd3a0888d2d02a463e968 to your computer and use it in GitHub Desktop.
Save arpruss/7ef2e4945aadd3a0888d2d02a463e968 to your computer and use it in GitHub Desktop.
Make bookmarklet available from gist
function bookmarklet(linkId, gistRawLink) {
fetch(gistRawLink).then(function(response) {
if (!response.ok) {
//alert("Error fetching "+response.statusText);
}
else {
response.text().then(function(text) {
var link = document.getElementById(linkId);
link.href = "javascript:"+encodeURIComponent("(function(){"+text+"})()");
});
}
});
}
bookmarklet("myBookmarklet1",
"https://gist.githubusercontent.com/arpruss/74abc1bc95ae08e543b9b74f15a23b07/raw");
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment