Skip to content

Instantly share code, notes, and snippets.

@egoens
Created December 4, 2015 20:40
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save egoens/85e15e2430bb5b49142a to your computer and use it in GitHub Desktop.
Save egoens/85e15e2430bb5b49142a to your computer and use it in GitHub Desktop.
(function(){
var v = "1.3.2";
if (window.jQuery === undefined || window.jQuery.fn.jquery < v) {
var done = false;
var script = document.createElement("script");
script.src = "http://ajax.googleapis.com/ajax/libs/jquery/" + v + "/jquery.min.js";
script.onload = script.onreadystatechange = function(){
if (!done && (!this.readyState || this.readyState == "loaded" || this.readyState == "complete")) {
done = true;
initMyBookmarklet();
}
};
document.getElementsByTagName("head")[0].appendChild(script);
} else {
initMyBookmarklet();
}
function initMyBookmarklet() {
(window.myBookmarklet = function() {
function getSelText() {
var s = '';
if (window.getSelection) {
s = window.getSelection();
} else if (document.getSelection) {
s = document.getSelection();
} else if (document.selection) {
s = document.selection.createRange().text;
}
return s;
}
// your JavaScript code goes here!
})();
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment