Created
November 3, 2014 14:42
-
-
Save cdzombak/7f20d00e9235f4214fa1 to your computer and use it in GitHub Desktop.
Spillo bookmarklet
This file contains 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
// original: | |
javascript:(function()%7Bfunction%20bookmark(url)%20%7Bvar%20location%20%3D%20'spillo%3A%2F%2F%2Fbookmark%3F'%3Bvar%20description%20%3D%20getSelText()%3Bif%20(description%20%3D%3D%3D%20%22%22)%20%7Bdescription%20%3D%20getMetaDescription()%3B%7Dlocation%20%2B%3D%20'url'%20%2B%20'%3D'%20%2B%20encodeURIComponent(url)%3Blocation%20%2B%3D%20'%26'%3Blocation%20%2B%3D%20'title'%20%2B%20'%3D'%20%2B%20encodeURIComponent(document.title)%3Blocation%20%2B%3D%20'%26'%3Blocation%20%2B%3D%20'desc'%20%2B%20'%3D'%20%2B%20encodeURIComponent(description)%3Bdocument.location.href%20%3D%20location%3B%7Dfunction%20getSelText()%7Bvar%20txt%20%3D%20%22%22%3Bif%20(window.getSelection)%20%7Btxt%20%3D%20window.getSelection()%3B%7D%20else%20if%20(document.getSelection)%20%7Btxt%20%3D%20document.getSelection()%3B%7D%20else%20if%20(document.selection)%20%7Btxt%20%3D%20document.selection.createRange().text%3B%7D%20else%20return%3Breturn%20txt.toString()%3B%7Dfunction%20getMetaDescription()%20%7Bvar%20meta%20%3D%20document.getElementsByTagName(%22meta%22)%3Bfor%20(var%20idx%20%3D%200%3B%20idx%20%3C%20meta.length%3B%20idx%2B%2B)%20%7Bif%20(meta%5Bidx%5D.name.toLowerCase()%20%3D%3D%3D%20%22description%22)%20%7Breturn%20meta%5Bidx%5D.content%3B%7D%7Dreturn%20%22%22%3B%7Dbookmark(document.location.href)%7D)() | |
// modified to include <blockquote> around selection: | |
javascript:(function(){function bookmark(url) {var location = 'spillo:///bookmark?';var description = getSelText();if (description === "") {description = getMetaDescription();} else {description='<blockquote>'+description+'</blockquote>';}location += 'url' + '=' + encodeURIComponent(url);location += '&';location += 'title' + '=' + encodeURIComponent(document.title);location += '&';location += 'desc' + '=' + encodeURIComponent(description);document.location.href = location;}function getSelText(){var txt = "";if (window.getSelection) {txt = window.getSelection();} else if (document.getSelection) {txt = document.getSelection();} else if (document.selection) {txt = document.selection.createRange().text;} else return;return txt.toString();}function getMetaDescription() {var meta = document.getElementsByTagName("meta");for (var idx = 0; idx < meta.length; idx++) {if (meta[idx].name.toLowerCase() === "description") {return meta[idx].content;}}return "";}bookmark(document.location.href)})() | |
// modified, escaped: | |
javascript:(function()%7Bfunction%20bookmark(url)%20%7Bvar%20location%20%3D%20%27spillo%3A%2F%2F%2Fbookmark%3F%27%3Bvar%20description%20%3D%20getSelText()%3Bif%20(description%20%3D%3D%3D%20%22%22)%20%7Bdescription%20%3D%20getMetaDescription()%3B%7D%20else%20%7Bdescription%3D%27%3Cblockquote%3E%27%2Bdescription%2B%27%3C%2Fblockquote%3E%27%3B%7Dlocation%20%2B%3D%20%27url%27%20%2B%20%27%3D%27%20%2B%20encodeURIComponent(url)%3Blocation%20%2B%3D%20%27%26%27%3Blocation%20%2B%3D%20%27title%27%20%2B%20%27%3D%27%20%2B%20encodeURIComponent(document.title)%3Blocation%20%2B%3D%20%27%26%27%3Blocation%20%2B%3D%20%27desc%27%20%2B%20%27%3D%27%20%2B%20encodeURIComponent(description)%3Bdocument.location.href%20%3D%20location%3B%7Dfunction%20getSelText()%7Bvar%20txt%20%3D%20%22%22%3Bif%20(window.getSelection)%20%7Btxt%20%3D%20window.getSelection()%3B%7D%20else%20if%20(document.getSelection)%20%7Btxt%20%3D%20document.getSelection()%3B%7D%20else%20if%20(document.selection)%20%7Btxt%20%3D%20document.selection.createRange().text%3B%7D%20else%20return%3Breturn%20txt.toString()%3B%7Dfunction%20getMetaDescription()%20%7Bvar%20meta%20%3D%20document.getElementsByTagName(%22meta%22)%3Bfor%20(var%20idx%20%3D%200%3B%20idx%20%3C%20meta.length%3B%20idx%2B%2B)%20%7Bif%20(meta%5Bidx%5D.name.toLowerCase()%20%3D%3D%3D%20%22description%22)%20%7Breturn%20meta%5Bidx%5D.content%3B%7D%7Dreturn%20%22%22%3B%7Dbookmark(document.location.href)%7D)() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment