Who the Fuck uses GOOGLE+?

A script which removes the google plus +1 sign

当前为 2016-05-11 提交的版本,查看 最新版本

  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.2.1
  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. /*
  19. if (!Array.prototype.forEach) {
  20. Array.prototype.forEach = function(callback, thisArg) {
  21. var T, k;
  22. if (this == null) throw new TypeError(' this is null or not defined');
  23. var O = Object(this);
  24. var len = O.length >>> 0;
  25. if (typeof callback !== "function") throw new TypeError(callback + ' is not a function');
  26. if (arguments.length > 1) T = thisArg;
  27. k = 0;
  28. while (k < len) {
  29. var kValue;
  30. if (k in O) {
  31. kValue = O[k];
  32. callback.call(T, kValue, k, O);
  33. }
  34. k++;
  35. }
  36. };
  37. }
  38. */
  39.  
  40. this.$ = this.jQuery = jQuery.noConflict(true);
  41. var attr = ["class", "id", "title", "tooltip"];
  42. var filter = ["googleplus", "google_plus", "gplus", "g_plus", "google+"];
  43. var complex_filter = ["[<attr>*=social][<attr>*=plusone]"];
  44. var full_filter = "";
  45. for(var a in attr) {
  46. for(var f in filter) full_filter += "["+a+"*="+f+"], ";
  47. for(var cf in complex_filter) full_filter += cf.replace("<attr>", a)+", ";
  48. }
  49.  
  50. full_filter = full_filter.slice(0, -2);
  51. $(full_filter).remove();
  52. console.log("Google+ Remover was active [filter = "+full_filter+"]");
  53. var site = window.location.href || document.URL;
  54. if(site.contains("plus.google.com")) {
  55. var content = $("body > *");
  56. content.remove();
  57. $("body").append(" \
  58. <center style='margin-top: 25px;'> \
  59. <h1 style='margin-bottom: 10px;'>Are you sure you want to be here?</h1> \
  60. <input type='button' value='Take me Away!' class='_away' /> \
  61. <input type='button' value='Show site!' class='_show' /> \
  62. </center> \
  63. ");
  64. $("._show").click(function() {
  65. $("body > *").remove();
  66. $("body").append(content);
  67. });
  68. $("._away").click(function() {
  69. window.location.href = document.referrer;
  70. });
  71. }