Skip to content

Instantly share code, notes, and snippets.

@pid
Last active December 16, 2015 04:48
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 pid/5379270 to your computer and use it in GitHub Desktop.
Save pid/5379270 to your computer and use it in GitHub Desktop.
Google Bookmark Bookmarklet || page title => title || page meta description => annotation || text selection => concat to annotation
javascript: (function () {
function document_description() {
var description = '',
selection = '';
var metas = document.getElementsByTagName('meta');
if (metas) {
for (var x = 0, y = metas.length; x < y; x++) {
if (metas[x].name.toLowerCase() == "description") {
description += metas[x].content;
}
}
}
selection = window.getSelection().toString();
if (!selection.length) {
selection = '';
}
if (!description.length) {
description = '';
} else {
if (selection.length) {
description += ' ### ';
}
}
return encodeURIComponent(description + selection);
}
var a = window,
b = document,
c = encodeURIComponent,
d = a.open("http://www.google.com/bookmarks/mark?op=edit&output=popup&bkmk=" + c(b.location) + "&title=" + c(b.title) + "&annotation=" + document_description(), "bkmk_popup", "left=" + ((a.screenX || a.screenLeft) + 10) + ",top=" + ((a.screenY || a.screenTop) + 10) + ",height=420px,width=550px,resizable=1,alwaysRaised=1");
a.setTimeout(function () {
d.focus()
}, 300)
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment