Created
June 6, 2011 04:12
-
-
Save sethladd/1009733 to your computer and use it in GitHub Desktop.
Tweets +1 Chrome Extension for Google +1 Button and twitter.com
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var plusOneScript = document.createElement('script'); | |
plusOneScript.setAttribute("src", "https://apis.google.com/js/plusone.js"); | |
plusOneScript.textContent = '{"parsetags": "explicit"}'; | |
plusOneScript.addEventListener("load", function() { | |
var script = document.createElement("script"); | |
script.textContent = "var addPlusOne = function(){gapi.plusone.go();setTimeout(addPlusOne, 1000);};setTimeout(addPlusOne, 1000);"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(plusOneScript); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var findTweets = function(event) { | |
var node = event.target; | |
if (node.webkitMatchesSelector && node.webkitMatchesSelector('div[data-item-type=tweet]')) { | |
addPlusOne(node); | |
} else if (node.querySelectorAll) { | |
var tweets = node.querySelectorAll('div[data-item-type=tweet]'); | |
for (var i = 0; i < tweets.length; i++) { | |
addPlusOne(tweets[i]); | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
document.body.addEventListener("DOMNodeInserted", findTweets, false); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"name" : "Tweets +1", | |
"version" : "1.0", | |
"description" : "Adds a +1 button to tweets on twitter.com", | |
"content_scripts" : [ | |
{ | |
"matches" : [ | |
"http://twitter.com/*", | |
"https://twitter.com/*" | |
], | |
"js" : ["contentscript.js"], | |
"run_at" : "document_idle", | |
"all_frames" : false | |
} | |
], | |
"icons" : { | |
"128" : "tweets+1.png" | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment