Skip to content

Instantly share code, notes, and snippets.

@bradhintze
Created November 23, 2010 23:08
Show Gist options
  • Save bradhintze/712729 to your computer and use it in GitHub Desktop.
Save bradhintze/712729 to your computer and use it in GitHub Desktop.
Add the Facebook Like button to Twitter.com
meta {
name "TwitterBook"
author "Jesse Stay"
description <<
Allows you to like any Tweet on Twitter.com and have that like appear on Facebook. Also adds other Facebook features to Twitter.com.
>>
logging on
key facebook {
"consumer_key" : "REDACTED",
"consumer_secret" : "REDACTED"
}
}
dispatch {
domain "www.twitter.com"
domain "twitter.com"
}
rule auth_app is active {
select using ".*" setting ()
if (not facebook:authorized())
then
facebook:authorize(["publish_stream","email","user_photos","read_stream",
"user_notes","offline_access","user_about_me","user_notes",
"user_photos","user_likes","user_online_presence"
])
with opacity = 1 and
sticky = true;
fired {
last;
}
}
rule twitter is active {
select using "http://(www.){0,1}twitter.com" setting()
emit <<
//$K(".twttr-editor").append("<input type=\"checkbox\" id=\"send_fb\" /> Also send to Facebook");
$K(".stream-item-content").each(function() {
$K(this).find(".tweet-actions").append("<a href=\"#\" class=\"like-action\"><i></i><b><iframe src=\"http://www.facebook.com/plugins/like.php?href=http://twitter.com/"+$K(this).attr("data-screen-name")+"/status/"+$K(this).attr("data-tweet-id")+"&amp;layout=button_count&amp;show_faces=true&amp;width=100&amp;action=like&amp;colorscheme=light&amp;height=21\" scrolling=\"no\" frameborder=\"0\" style=\"border:none; overflow:hidden; width:100px; height:21px;\" allowTransparency=\"true\" style=\"display:inline;float:left;width:100px;vertical-align:bottom;height:10px\"></iframe></b></a>");
});
>>
noop();
}
rule message is active {
select using "http://(www.){0,1}twitter.com" setting()
pre {
user = facebook:get({"fields”" : ["first_name","last_name","email"]});
first_name = user.pick("$.first_name");
title = "Hello "+first_name+",";
}
notify(title, "To like a Tweet just mouse over any Tweet and click the Facebook 'like' button that appears.");
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment