Created
August 19, 2012 13:23
-
-
Save christopherdebeer/3394765 to your computer and use it in GitHub Desktop.
text selection bookmarklet code unminified from marksaved.com
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
//javascript: | |
(function () { | |
var enc = encodeURIComponent; | |
var s = window.getSelection(); | |
if (location.href == "http://marksaved.com/welcome") { | |
alert("Drag this button to the toolbar to start highlighting") | |
} else if (s && encodeURIComponent(s).length > 1300) { | |
alert("Sorry, you can only highlight up to 1K characters") | |
} else { | |
var d = document; | |
var m = 'Saving'; | |
if (s.toString().length == 0) { | |
m = 'Highlighting'; | |
} | |
var t = d.createElement("div"); | |
t.innerHTML = "<div style = 'padding:10px;background-color:#feffde; border:1px solid #cecfa4;font-family:helvetica,arial,sans;'>" + m + "</div>"; | |
t.style.position = "fixed"; | |
t.style.top = "5px"; | |
t.style.left = "5px"; | |
d.body.appendChild(t); | |
if (typeof marksaved == "undefined") { | |
var s = d.createElement("script"); | |
s.src = "http://marksaved.com:80/ui/bootstrap" + "?v=4&r=" + (new Date()).getTime() + "&u=" + enc("christopherdebeer") + "&b=" + enc("709eb0a53c1cbea01639abf707ae4534fd348da8"); | |
s.type = "text/javascript"; | |
d.getElementsByTagName("head").item(0).appendChild(s); | |
} else { | |
marksaved.save_highlight(); | |
} | |
window.setTimeout(function () { | |
d.body.removeChild(t) | |
}, 2000); | |
} | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment