Advertisement
cdolphin

RT@FB

Oct 16th, 2011
100
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. (function(){
  2. //A random piece of JS that could be placed in a user script for Chrome / Greasemonkey and make it easier to post tweets to FB.
  3. //@wcdolphin
  4.  
  5.     myTest = function(cl) {
  6.         var retnode = [];
  7.         var myclass = 'tweet-actions js-actions'
  8.         var elem = document.getElementsByTagName('*');
  9.         for (var i = 0; i < elem.length; i++) {
  10.             if (myclass == elem[i].className) retnode.push(elem[i]);
  11.         }
  12.         return retnode;
  13.     };
  14.  
  15.     postToFacebook = function(what){
  16.     //Wouldn't that be cool? I don't think it is too hard...
  17.     alert('It would be really cool if I actually finished this someday...');
  18.     };
  19.     addElements = function(){
  20.         for(var i =0, myTweets = myTest(),myElement,child; i < myTweets.length; i ++){ //need to actually check if node exists... Will add multiple otherwise.
  21.             myElement =document.createElement('span');
  22.             myElement.setAttribute('class','tweet-action action-retweet');
  23.             child = document.createElement('a');
  24.             child.setAttribute('href','#');
  25.             child.setAttribute('class','retweet-action');
  26.             child.setAttribute('title','RT@FB');
  27.             child.innerHTML = '<span><i></i><b>RT@FB</b></span>';
  28.             myElement.appendChild(child);
  29.             myElement.addEventListener('click',postToFacebook,false)
  30.  
  31.             myTweets[i].appendChild(myElement);
  32.         }
  33.     }
  34.     addElements();
  35. })();
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement