Skip to content

Instantly share code, notes, and snippets.

@eversonl
Created March 4, 2009 14:36
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 eversonl/73855 to your computer and use it in GitHub Desktop.
Save eversonl/73855 to your computer and use it in GitHub Desktop.
post-to-facebook
//post-to-facebook
CmdUtils.CreateCommand({
name: "post-to-facebook",
icon: "http://www.facebook.com/favicon.ico",
homepage: "http://www.leeeverson.co.uk/20090223/my-ubiquity-commands/",
author: { name: "Lee Everson", email: "lee@0-21.co.uk"},
license: "GPL",
description: "quickly share any web page with your friends, even when you're not on Facebook.",
help: "The Share Bookmarklet will recognise when you share videos and music, making them easy to play within Facebook.",
preview: function(pblock) {
pblock.innerHTML = "Executes the <b>Facebook</b> bookmarklet<br>quickly share any web page with your friends, even when you're not on Facebook.";
},
execute: function() {
var bookmarkletCode = "javascript:var%20d=document,f='http://www.facebook.com/share',l=d.location,e=encodeURIComponent,p='.php?src=bm&v=4&i=1236177022&u='+e(l.href)+'&t='+e(d.title);1;try{if%20(!/^(.*\.)?facebook\.[^.]*$/.test(l.host))throw(0);share_internal_bookmarklet(p)}catch(z)%20{a=function()%20{if%20(!window.open(f+'r'+p,'sharer','toolbar=0,status=0,resizable=1,width=626,height=436'))l.href=f+p};if%20(/Firefox/.test(navigator.userAgent))setTimeout(a,0);else{a()}}void(0)";
var urlBar = context.chromeWindow.document.getElementById("urlbar");
var oldURL = urlBar.value;
urlBar.value = bookmarkletCode;
context.chromeWindow.handleURLBarCommand();
urlBar.value = oldURL;
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment