A script which removes the google plus +1 sign
当前为
// ==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.1
// @grant none
// ==/UserScript==
if(!('contains' in String.prototype)) {
String.prototype.contains = 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);
};
/*
if (!Array.prototype.forEach) {
Array.prototype.forEach = function(callback, thisArg) {
var T, k;
if (this == null) throw new TypeError(' this is null or not defined');
var O = Object(this);
var len = O.length >>> 0;
if (typeof callback !== "function") throw new TypeError(callback + ' is not a function');
if (arguments.length > 1) T = thisArg;
k = 0;
while (k < len) {
var kValue;
if (k in O) {
kValue = O[k];
callback.call(T, kValue, k, O);
}
k++;
}
};
}
*/
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", "gplus", "g_plus", "google+"];
var complex_filter = ["*[<attr>*=social][<attr>*=plusone]"];
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.contains("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;
});
}