Remove Facebook Like buttons (mod)

Remove Facebook Like buttons (inspired by http://userscripts.org/scripts/show/76037 by rnaud)

  1. // ==UserScript==
  2. // @name Remove Facebook Like buttons (mod)
  3. // @namespace Smiths
  4. // @description Remove Facebook Like buttons (inspired by http://userscripts.org/scripts/show/76037 by rnaud)
  5. // @include http://*
  6. // @include https://*
  7. // @exclude http://*.facebook.com/*
  8. // @exclude https://*.facebook.com/*
  9. // @version 2.0.3
  10. // @grant GM_getValue
  11. // @grant GM_setValue
  12. // @grant GM_addStyle
  13. // @grant GM_log
  14. // @grant GM_xmlhttpRequest
  15. // @grant unsafeWindow
  16. // @attribution changes [d:10.25.12][u:<ul><li>Was wondering when something new would come along I'd have to remove. Adios, Pinterest!</li></ul>]
  17. // ==/UserScript==
  18.  
  19. //note to self: gotta make sure to update the one in the metadata too!
  20. var v = "2.0.3";
  21.  
  22. var scriptNum = "93724";
  23. var scriptName = "Remove Facebook Like buttons (mod1)";
  24.  
  25. //<--Updater Stuff
  26. var isFireFox = navigator.userAgent.indexOf("Firefox") > -1 || navigator.userAgent.indexOf("Iceweasel") > -1;
  27. GM_addStyle("#smgm_bgdiv{ text-align: center;position:fixed;top:0px;left:0px;z-index:9991;width:100%;height:100%;background-color:black;opacity:0.7;display:block;visibility:visible;}");
  28. GM_addStyle("#smgm_dialogbox { vertical-align:middle;left:40px;top:15px;border:3px solid #000 !important;text-align:center !important;background-color:#fff !important;color:#000 !important;font-family:arial,verdana !important;z-Index:9999;position:fixed;width:18%;height:50%;margin-left:auto;margin-right:auto;display:block;visibility:visible;}");
  29. GM_addStyle(".smgm_buttons { color:#000 !important;font: 90% 'arial','trebuchet ms',helvetica,sans-serif !important;background-color:#B2CCFF !important;border:2px solid !important;border-color: #E0EBFF #000 #000 #E0EBFF !important;vertical-align: top !important;}");
  30. GM_addStyle(".smgm_table { margin-bottom:10px !important;border:0px !important;border-collapse:collapse !important;margin-left:auto;margin-right:auto; }");
  31. var remindLaterV = GM_getValue('remindLaterV', remindLaterV);
  32. if (!remindLaterV) { remindLaterV = 0; GM_setValue('remindLaterV',remindLaterV); }
  33.  
  34. var homepageURL = "http://userscripts.org/scripts/show/" + scriptNum ;
  35. var metaURL = "http://userscripts.org/scripts/source/" + scriptNum + ".meta.js";
  36. var scriptJSURL = "http://userscripts.org/scripts/source/" + scriptNum + ".user.js";
  37.  
  38. function doremindLater(clicked,span)
  39. {
  40. if (clicked)
  41. remindLaterV = span;
  42. else
  43. remindLaterV--;
  44. GM_setValue('remindLaterV',remindLaterV);
  45. }
  46.  
  47. function hideUpdate()
  48. {
  49. document.body.removeChild(document.getElementById('smgm_bgdiv'));
  50. document.body.removeChild(document.getElementById('smgm_dialogbox'));
  51. }
  52.  
  53. function checkNew(version)
  54. {
  55. var upgrade = 0;
  56. var verstring = "";
  57. var theHTML = "";
  58. GM_xmlhttpRequest({
  59. method:"GET",
  60. url:metaURL,
  61. onload:function(content){
  62. var aResponse = content.responseText;
  63. var USversion = aResponse.match(/@version.*?(\d[^<]+?)\n/);
  64. aResponse = aResponse.replace(/ \/>/g,'>');
  65. aResponse = aResponse.replace(/\n/g,'');
  66. var changeDate = aResponse.match(/\[d:([0-9]+?\.[0-9]+?\.[0-9]+?)\]/i)[1];
  67. var theChanges = aResponse.match(/\[u:(.*?)\]/i)[1];
  68. vSplit = version.split(".");
  69. vmain = Number(vSplit[0]);
  70. vvsub = Number(vSplit[1]);
  71. vrsub = Number(vSplit[2]);
  72. USsplit = USversion[1].split(".");
  73. USvmain = Number(USsplit[0]);
  74. USvsub = Number(USsplit[1]);
  75. USrsub = Number(USsplit[2]);
  76. verstring = "<div style='padding:5px;border-bottom:1px dotted #000;'>Latest Version on Userscripts: <a href='" + homepageURL + "' target='_new' title='Click to visit script's page'><b>" + USvmain + "." + USvsub + "." + USrsub + "</b></a><br>Your Installed Version: <b>" + vmain + "." + vvsub + "." + vrsub + "</b></div>";
  77. if (USvmain > vmain) upgrade = 1;
  78. if ( (USvsub > vvsub) && (USvmain >= vmain) ) upgrade = 1;
  79. if ( (USrsub > vrsub) && (USvsub == vvsub) && (USvmain >= vmain) ) upgrade = 1;
  80. if (upgrade == 1) //upgrade available, pop a box
  81. {
  82. theHTML += "<div style='padding:5px;border-bottom:1px dotted #000;'>New version of " + scriptName + " available.</div>";
  83. theHTML += verstring + "<p>";
  84. theHTML += "<table class='smgm_table'><tr><td><input type='button' class='smgm_buttons' id='smgm_installButton' onMouseUp=\"document.location.href=\'" + scriptJSURL + "\';\" value='Install'></td>";
  85. theHTML += "<td style='width:25px;'>&nbsp;</td><td><input style='' class='smgm_buttons' type='button' id='smgm_remindButton' value='Remind Me Later'></td>";
  86. theHTML += "</tr></table><div style='background-color:white !important;overflow:auto !important;height:50%;text-align:left;border-top:1px dotted #000;padding:7px;' colspan='5'>Changes (" + changeDate.replace(/\./g,"/") + "):<br><span style='font-style:italic;'>" + theChanges + "</span></div>";
  87. div1 = document.createElement('div');
  88. div1.id = 'smgm_dialogbox';
  89. div1.style.display = "none";
  90. div1.innerHTML = theHTML;
  91. document.body.appendChild(div1);
  92. div2 = document.createElement('div');
  93. div2.id = 'smgm_bgdiv';
  94. div2.style.display = "none";
  95. div2.addEventListener("click",function(){doremindLater(true,15);hideUpdate();},false);
  96. document.body.appendChild(div2);
  97. document.getElementById('smgm_bgdiv').style.display='block';
  98. document.getElementById('smgm_dialogbox').style.display='block';
  99. document.getElementById('smgm_remindButton').addEventListener("click", function(){doremindLater(true,60);hideUpdate();},false);
  100. document.getElementById('smgm_installButton').addEventListener("click", function(){hideUpdate();},false);
  101. }
  102. }
  103. })
  104. }
  105.  
  106. if (isFireFox) //only do update on FFox, Chrome/Tampermonkey are weird
  107. {
  108. doremindLater(false);
  109. if (remindLaterV < 1)
  110. checkNew(v);
  111. }
  112. //end updater stuff-->
  113.  
  114. function removefb(){
  115.  
  116. //common classes - this is enematic to a page
  117. var shareClasses = ['badges_v','pin-it-button','g-plusone','cnn-social','stbutton','eswd','gig-button','gig-reaction','ymsb-','sociable','addthis_button','addthis_toolbox','addthis_counter','a2a_dd','connect_widget','db-wrapper','sharethis','st_digg','st_facebook','st_twitter','cnnfb','cnnsocial','cnnShareThisBox','fb-like','fb_like','twtr-widget'];
  118. for (var i=0;i<shareClasses.length;i++)
  119. {
  120. var elementsWithIt = document.evaluate('//*[contains(@class, "'+shareClasses[i]+'")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  121. for (var j = 0; j < elementsWithIt.snapshotLength; j++) {
  122. elementsWithIt.snapshotItem(j).parentNode.removeChild(elementsWithIt.snapshotItem(j));
  123. }
  124. }
  125. //fbML/gplusone method
  126. var fbtags = ['g:plusone','fb:fan','fb:share-button','fb:activity','fb:add-profile-tab','fb:bookmark','fb:comments','fb:friendpile','fb:like','fb:like-box','fb:live-stream','fb:login-button','fb:pronoun','fb:recommendations','fb:serverFbml','fb:profile-pic','fb:user-status'];
  127. for (var j=0;j<fbtags.length;j++)
  128. {
  129. var fbXML = document.getElementsByTagName(fbtags[j]);
  130. for (var i=0;i<fbXML.length;i++)
  131. fbXML[i].parentNode.removeChild(fbXML[i]);
  132. }
  133. //random divs
  134. var removeIDs = ['stframe','custom-tweet-button','persistent-share','fb-like-article','cnnStryRcmndBtnBtm'];
  135. for (var i = 0; i < removeIDs.length; i++)
  136. {
  137. var fbDiv = document.getElementById(removeIDs[i]);
  138. if (fbDiv)
  139. fbDiv.parentNode.removeChild(fbDiv);
  140. }
  141.  
  142. //hrefs,javascripts,etc
  143. var shareLinks = ['plus.google.com/share','addthis_open(','NPR.socialMedia','stumbleupon.com/submit?url=','tumblr.com/share/','twitter.com/?status=','linkedin.com/shareArticle','reddit.com/submit?url','twitter.com/home?status','twitter.com/intent','google.com/buzz/post','topsy.com/','facebook.com/share','digg.com/submit','twitter.com/share'];
  144. for (var i=0;i<shareLinks.length;i++)
  145. {
  146. var elementsWithIt = document.evaluate('//a[contains(@href, "'+shareLinks[i]+'") or contains(@onmouseover, "'+shareLinks[i]+'") or contains(@onclick, "'+shareLinks[i]+'")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null);
  147. for (var j = 0; j < elementsWithIt.snapshotLength; j++) {
  148. elementsWithIt.snapshotItem(j).parentNode.removeChild(elementsWithIt.snapshotItem(j));
  149. }
  150. }
  151. }
  152.  
  153. var remove = ['pinit-cdn.pinterest.com','sharethis.com/','facebook.com/extern','facebook.com/widgets','facebook.com/plugins','facebook.com/connect/','platform0.twitter.com/','platform.twitter.com/','twitter.com/widgets/','tweetmeme.com','plusone.google.com/','yimg.com/b/social_buttons/','fbshare.me','api.flattr.com/button','addthis.com/static/','stumbleupon.com/badge/','widgets.backtype.com','widget.collecta.com/','reddit.com/static/button/'];
  154.  
  155. if(unsafeWindow.top == unsafeWindow.self) //no run on iframes
  156. {
  157. document.addEventListener('DOMNodeInserted',function(e){
  158. window.setTimeout(function(){
  159. var findLink = document.evaluate('//*[contains(@class, "IN-widget")]', document, null, XPathResult.UNORDERED_NODE_SNAPSHOT_TYPE, null); //LinkedIn is dynamic
  160. for (var j = 0; j < findLink.snapshotLength; j++)
  161. findLink.snapshotItem(j).parentNode.removeChild(findLink.snapshotItem(j));
  162. var iFrames = document.querySelectorAll('iframe');
  163. if (iFrames.length > 0) {
  164. for (var i = 0; i < iFrames.length; i++) {
  165. for (var j = 0; j < remove.length; j++)
  166. {
  167. if (iFrames[i].src.toLowerCase().match(remove[j].toLowerCase())== remove[j].toLowerCase())
  168. if (iFrames[i].parentNode)
  169. iFrames[i].parentNode.removeChild(iFrames[i]);
  170. }
  171. }
  172. }
  173. }, 250);}
  174. , false);
  175. setTimeout(removefb,250);
  176. }
  177.  
  178.  

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址