Advertisement
Gerst20051

FB Like

Aug 5th, 2011
131
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Organized Into 4 Files | I plan on combining these into one file soon. (Very Easy)
  2.  
  3. -- Like Everything
  4. -- Unlike Everything
  5. -- Like Comments
  6. -- Unlike Comments
  7.  
  8.  
  9.  
  10. // Like Everything
  11.  
  12. var sad = document.getElementsByTagName('button'), happy = [], halt = false;
  13.  
  14. for (var i = 0; i < sad.length; i++) {
  15.     if (sad[i] && hasClass(sad[i], 'like_link')) {
  16.         var sad_likebutton = sad[i].getElementsByTagName('span');
  17.         for (var j = 0; j < sad_likebutton.length; j++) {
  18.             if (sad_likebutton[j] && hasClass(sad_likebutton[j], 'default_message') && sad_likebutton[j].style.display != 'none') happy.push(sad[i]);
  19.         }
  20.     }
  21. }
  22.  
  23. function hasClass(ele, cls) {
  24.     return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  25. }
  26.  
  27. var happyDiv = document.createElement('div');
  28. happyDiv.innerHTML = '<div id=\'happy\' style=\'cursor:pointer;background-color:#ddd;font-size:16px;text-align:center;position:fixed;top:40px;right:40px;width:200px;height:100px;border:4px solid black;z-index:9999;padding-top:15px;\' title="Close" onClick="this.parentNode.removeChild(this)"><span>0</span> of ' + happy.length + ' items liked.<div id=\'happyStatus\' style=\'margin-top:30px;\'><a id=\'happyButton\' href=\'#\' style=\'display:block;\' onclick=\'haltFn();\'>Stop it.</a></div></div>';
  29. document.getElementsByTagName('body')[0].appendChild(happyDiv);
  30.  
  31. function happyFn(happy) {
  32.     if (halt || !happy || !happy.length) {
  33.         document.getElementById('happyStatus').innerHTML = 'Done!';
  34.         return;
  35.     }
  36.     happy[0].click();
  37.     happy[0].style.color = '#f00';
  38.     var countSpan = document.querySelector('#happy span');
  39.     countSpan.innerHTML = parseInt(countSpan.innerHTML) + 1;
  40.     window.setTimeout(function () {
  41.         happyFn(happy.splice(1));
  42.     }, 800);
  43. }
  44.  
  45. function haltFn() {
  46.     halt = true;
  47.     return false;
  48. }
  49. happyFn(happy);
  50.  
  51.  
  52.  
  53. // Unlike Everything
  54.  
  55. var sad = document.getElementsByTagName('button'), happy = [], halt = false;
  56.  
  57. for (var i = 0; i < sad.length; i++) {
  58.     if (sad[i] && hasClass(sad[i], 'like_link')) {
  59.         var sad_likebutton = sad[i].getElementsByTagName('span');
  60.         for (var j = 0; j < sad_likebutton.length; j++) {
  61.             if (sad_likebutton[j] && hasClass(sad_likebutton[j], 'default_message') && sad_likebutton[j].style.display != 'none' && sad_likebutton[0].innerHTML == 'Unlike') happy.push(sad[i]);
  62.         }
  63.     }
  64. }
  65.  
  66. function hasClass(ele, cls) {
  67.     return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  68. }
  69.  
  70. var happyDiv = document.createElement('div');
  71. happyDiv.innerHTML = '<div id=\'happy\' style=\'cursor:pointer;background-color:#ddd;font-size:16px;text-align:center;position:fixed;top:40px;right:40px;width:200px;height:100px;border:4px solid black;z-index:9999;padding-top:15px;\' title="Close" onClick="this.parentNode.removeChild(this)"><span>0</span> of ' + happy.length + ' items unliked.<div id=\'happyStatus\' style=\'margin-top:30px;\'><a id=\'happyButton\' href=\'#\' style=\'display:block;\' onclick=\'haltFn();\'>Stop it.</a></div></div>';
  72. document.getElementsByTagName('body')[0].appendChild(happyDiv);
  73.  
  74. function happyFn(happy) {
  75.     if (halt || !happy || !happy.length) {
  76.         document.getElementById('happyStatus').innerHTML = 'Done!';
  77.         return;
  78.     }
  79.     happy[0].click();
  80.     happy[0].style.color = '#f00';
  81.     var countSpan = document.querySelector('#happy span');
  82.     countSpan.innerHTML = parseInt(countSpan.innerHTML) + 1;
  83.     window.setTimeout(function () {
  84.         happyFn(happy.splice(1));
  85.     }, 800);
  86. }
  87.  
  88. function haltFn() {
  89.     halt = true;
  90.     return false;
  91. }
  92. happyFn(happy);
  93.  
  94.  
  95.  
  96. // Like Comments
  97.  
  98. var sad = document.getElementsByTagName('button'), happy = [], halt = false;
  99.  
  100. for (var i = 0; i < sad.length; i++) {
  101.     if (sad[i] && hasClass(sad[i], 'cmnt_like_link')) {
  102.         var sad_likebutton = sad[i].getElementsByTagName('span');
  103.         for (var j = 0; j < sad_likebutton.length; j++) {
  104.             if (sad_likebutton[j] && hasClass(sad_likebutton[j], 'default_message') && sad_likebutton[j].style.display != 'none') happy.push(sad[i]);
  105.         }
  106.     }
  107. }
  108.  
  109. function hasClass(ele, cls) {
  110.     return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  111. }
  112.  
  113. var happyDiv = document.createElement('div');
  114. happyDiv.innerHTML = '<div id=\'happy\' style=\'cursor:pointer;background-color:#ddd;font-size:16px;text-align:center;position:fixed;top:40px;right:40px;width:200px;height:100px;border:4px solid black;z-index:9999;padding-top:15px;\' title="Close" onClick="this.parentNode.removeChild(this)"><span>0</span> of ' + happy.length + ' comments liked.<div id=\'happyStatus\' style=\'margin-top:30px;\'><a id=\'happyButton\' href=\'#\' style=\'display:block;\' onclick=\'haltFn();\'>Stop it.</a></div></div>';
  115. document.getElementsByTagName('body')[0].appendChild(happyDiv);
  116.  
  117. function happyFn(happy) {
  118.     if (halt || !happy || !happy.length) {
  119.         document.getElementById('happyStatus').innerHTML = 'Done!';
  120.         return;
  121.     }
  122.     happy[0].click();
  123.     happy[0].style.color = '#f00';
  124.     var countSpan = document.querySelector('#happy span');
  125.     countSpan.innerHTML = parseInt(countSpan.innerHTML) + 1;
  126.     window.setTimeout(function () {
  127.         happyFn(happy.splice(1));
  128.     }, 800);
  129. }
  130.  
  131. function haltFn() {
  132.     halt = true;
  133.     return false;
  134. }
  135. happyFn(happy);
  136.  
  137.  
  138.  
  139. // Unlike Comments
  140.  
  141. var sad = document.getElementsByTagName('button'), happy = [], halt = false;
  142.  
  143. for (var i = 0; i < sad.length; i++) {
  144.     if (sad[i] && hasClass(sad[i], 'cmnt_like_link')) {
  145.         var sad_likebutton = sad[i].getElementsByTagName('span');
  146.         for (var j = 0; j < sad_likebutton.length; j++) {
  147.             if (sad_likebutton[j] && hasClass(sad_likebutton[j], 'default_message') && sad_likebutton[j].style.display != 'none' && sad_likebutton[0].innerHTML == 'Unlike') happy.push(sad[i]);
  148.         }
  149.     }
  150. }
  151.  
  152. function hasClass(ele, cls) {
  153.     return ele.className.match(new RegExp('(\\s|^)' + cls + '(\\s|$)'));
  154. }
  155.  
  156. var happyDiv = document.createElement('div');
  157. happyDiv.innerHTML = '<div id=\'happy\' style=\'cursor:pointer;background-color:#ddd;font-size:16px;text-align:center;position:fixed;top:40px;right:40px;width:200px;height:100px;border:4px solid black;z-index:9999;padding-top:15px;\' title="Close" onClick="this.parentNode.removeChild(this)"><span>0</span> of ' + happy.length + ' comments unliked.<div id=\'happyStatus\' style=\'margin-top:30px;\'><a id=\'happyButton\' href=\'#\' style=\'display:block;\' onclick=\'haltFn();\'>Stop it.</a></div></div>';
  158. document.getElementsByTagName('body')[0].appendChild(happyDiv);
  159.  
  160. function happyFn(happy) {
  161.     if (halt || !happy || !happy.length) {
  162.         document.getElementById('happyStatus').innerHTML = 'Done!';
  163.         return;
  164.     }
  165.     happy[0].click();
  166.     happy[0].style.color = '#f00';
  167.     var countSpan = document.querySelector('#happy span');
  168.     countSpan.innerHTML = parseInt(countSpan.innerHTML) + 1;
  169.     window.setTimeout(function () {
  170.         happyFn(happy.splice(1));
  171.     }, 800);
  172. }
  173.  
  174. function haltFn() {
  175.     halt = true;
  176.     return false;
  177. }
  178. happyFn(happy);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement