Skip to content

Instantly share code, notes, and snippets.

@avivo
Created March 20, 2011 21:02
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save avivo/878671 to your computer and use it in GitHub Desktop.
Save avivo/878671 to your computer and use it in GitHub Desktop.
A bookmarklet to make a diigo bookmark with a default tag with one click.
javascript:
/* Usage:
Copy the contents of this file and paste into the url of a new bookmark to make the bookmarklet.
Click the bookmarklet to make a Diigo bookmark to the current page with the tag 'oneclick'. It will bring up a popup, which will close 2 seconds after you click anywhere on the bookmarked page, or after you leave the bookmarked page.
Feel free to edit and improve, this was just a quick hack.
*/
(function(){
var path = 'https://secure.diigo.com/api/v2/bookmarks';
var params = {
'url': document.URL,
'title': document.title,
'tags': 'oneclick',
'shared': 'no'
};
var form = document.createElement("form");
form.setAttribute("method", "post");
form.setAttribute("action", path);
form.setAttribute("target", "formresult");
for (var key in params) {
var hiddenField = document.createElement("input");
hiddenField.setAttribute("type", "hidden");
hiddenField.setAttribute("name", key);
hiddenField.setAttribute("value", params[key]);
form.appendChild(hiddenField);
}
document.body.appendChild(form);
var w = window.open('about:blank', 'formresult', 'scrollbars=no,menubar=no,height=300,width=400,resizable=yes,toolbar=no,status=no,location=no');
form.submit();
var existing_onclick = (document.onclick) ? document.onclick : function(){
};
var existing_onunload = (document.body.onunload) ? document.body.onunload : function(){
};
document.body.onunload = function(event){
w.close();
existing_onunload(event);
};
document.onclick = function(event){
document.onclick = existing_onclick;
document.body.onunload = existing_onunload;
window.setTimeout(function(){
w.close();
}, 2000);
existing_onclick(event);
};
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment