Created
August 12, 2018 21:06
-
-
Save arpruss/7ef2e4945aadd3a0888d2d02a463e968 to your computer and use it in GitHub Desktop.
Make bookmarklet available from gist
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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