Google +1 Remover

A script which removes the google plus +1 sign

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

You will need to install an extension such as Tampermonkey to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

// ==UserScript==
// @name        Google +1 Remover
// @namespace   MegaByteG+R
// @description A script which removes the google plus +1 sign
// @require     http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
// @run-at      document-idle
// @include     *
// @version     0.9.5
// @grant       none
// ==/UserScript==


    if(!('includes' in String.prototype)) {
       	String.prototype.includes = function(str, startIndex) {
            return -1 !== String.prototype.indexOf.call(this, str, startIndex);
       	};
 	}
    String.prototype.replaceAll = function(search, replacement) {
        var target = this;
        return target.split(search).join(replacement);
    };


    this.$ = this.jQuery = jQuery.noConflict(true);

    $.fn.removeWithLog = function() {
       return this.each(function() {
          if(this.length != 0) {
             console.info("Google +1 Remover:"+
                          "\n\tid = " + $(this).attr("id") +
                          "\n\tclass = " + $(this).attr("class") +
                          "\n\thtml = " + $(this).html());
             this.remove();
          }
       });
    };
    

    var attr = ["class", "id", "title", "tooltip"];
    var filter = ["googleplus", "google_plus", "google-plus", "gplus", "g_plus", "g-plus", "google+"];
    var complex_filter = ["[<attr>*=social][<attr>*=plusone]", "[<attr>*=social][<attr>*=google]"];
    
    for(var a of attr) {
        for(var f of filter) $("["+a+"*="+f+"]").removeWithLog();
        for(var cf of complex_filter) $(cf.replaceAll("<attr>", a)).removeWithLog();
    }
    
    
    var site = window.location.href || document.URL;
    if(site.includes("plus.google.com")) {
        var content = $("body > *").detach();
        $("body").append("                                                      \
           <center style='margin-top: 25px;'>              \
              <h1 style='margin-bottom: 10px;'>Are you sure you want to be here?</h1>                        \
              <input type='button' value='Take me Away!' class='_away' />       \
              <input type='button' value='Show site!' class='_show' />          \
           </center>                                                            \
        ");
        $("._show").click(function() {
           $("body > *").remove();
            $("body").append(content);
        });
        $("._away").click(function() {
           window.location.href = document.referrer;
        });
    }