Who the Fuck uses GOOGLE+?

A script which removes the google plus +1 sign

目前为 2016-05-12 提交的版本。查看 最新版本

  1. // ==UserScript==
  2. // @name Who the Fuck uses GOOGLE+?
  3. // @namespace MegaByteWTFUG
  4. // @description A script which removes the google plus +1 sign
  5. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  6. // @run-at document-idle
  7. // @include *
  8. // @version 0.9
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12.  
  13. if(!('contains' in String.prototype)) {
  14. String.prototype.contains = function(str, startIndex) {
  15. return -1 !== String.prototype.indexOf.call(this, str, startIndex);
  16. };
  17. }
  18. String.prototype.replaceAll = function(search, replacement) {
  19. var target = this;
  20. return target.split(search).join(replacement);
  21. };
  22. /*
  23. if (!Array.prototype.forEach) {
  24. Array.prototype.forEach = function(callback, thisArg) {
  25. var T, k;
  26. if (this == null) throw new TypeError(' this is null or not defined');
  27. var O = Object(this);
  28. var len = O.length >>> 0;
  29. if (typeof callback !== "function") throw new TypeError(callback + ' is not a function');
  30. if (arguments.length > 1) T = thisArg;
  31. k = 0;
  32. while (k < len) {
  33. var kValue;
  34. if (k in O) {
  35. kValue = O[k];
  36. callback.call(T, kValue, k, O);
  37. }
  38. k++;
  39. }
  40. };
  41. }
  42. */
  43.  
  44.  
  45. this.$ = this.jQuery = jQuery.noConflict(true);
  46.  
  47. $.fn.removeWithLog = function() {
  48. return this.each(function() {
  49. if(this.length != 0) {
  50. console.info("Who the Fuck uses GOOGLE+? removed:"+
  51. "\n\tid = " + $(this).attr("id") +
  52. "\n\tclass = " + $(this).attr("class") +
  53. "\n\thtml = " + $(this).html());
  54. this.remove();
  55. }
  56. });
  57. };
  58.  
  59. var attr = ["class", "id", "title", "tooltip"];
  60. var filter = ["googleplus", "google_plus", "gplus", "g_plus", "google+"];
  61. var complex_filter = ["*[<attr>*=social][<attr>*=plusone]"];
  62. for(var a of attr) {
  63. for(var f of filter) $("*["+a+"*="+f+"]").removeWithLog();
  64. for(var cf of complex_filter) $(cf.replaceAll("<attr>*", a)).removeWithLog();
  65. }
  66. var site = window.location.href || document.URL;
  67. if(site.contains("plus.google.com")) {
  68. var content = $("body > *").detach();
  69. $("body").append(" \
  70. <center style='margin-top: 25px;'> \
  71. <h1 style='margin-bottom: 10px;'>Are you sure you want to be here?</h1> \
  72. <input type='button' value='Take me Away!' class='_away' /> \
  73. <input type='button' value='Show site!' class='_show' /> \
  74. </center> \
  75. ");
  76. $("._show").click(function() {
  77. $("body > *").remove();
  78. $("body").append(content);
  79. });
  80. $("._away").click(function() {
  81. window.location.href = document.referrer;
  82. });
  83. }