Skip to content

Instantly share code, notes, and snippets.

@syoichi
Forked from fuba/googlefilter.user.js
Created February 16, 2011 06:37
Show Gist options
  • Save syoichi/828964 to your computer and use it in GitHub Desktop.
Save syoichi/828964 to your computer and use it in GitHub Desktop.
Googleアカウントにログインしていないと動作しなかった問題を修正した。また、コードを書き直した。AutoPagerize 0.0.58(GM)・0.6.6(Fx)・0.2.7(Cr)、AutoPatchWork 1.8.1に対応。Firefox 3.6.13(Greasemonkey 0.9.1)、Chrome 9.0.597.98で動作を確認した。
// ==UserScript==
// @name Google Filter
// @namespace hirak99
// @description Filters out search entries from specific sites from Google
// @include http://www.google.com/search*
// @include http://www.google.co.jp/search*
// @include http://www.google.co.uk/search*
// @include http://www.google.co.in/search*
// @version 2.0 - fixed for new google on 25 Oct, 2009
// ==/UserScript==
// 2.15.2011 modified for autopagerize by fuba
var f = [
'www\.unkar\.org/',
'unkar\.org/',
'2ch\.net/'
], l = f.length, b = [], d = document, e = d.createElement('div'), i = d.getElementById('ires'), t, c;
function toggleDisplay(a) {
i = b.length;
a && (t = !t);
if (i) {
e.textContent = '('+ i + ' item' + (~-i ? 's' : '') + ' filtered out by Google Filter - Click to ' + (t ? 'hide' : 'show') + ')';
if (t) while (i) b[--i].style.cssText = 'background-color: #E0E0E0;';
else while (i) b[--i].style.cssText = 'display: none;';
}
}
function googleFilter(a) {
var x = a.getElementsByClassName('l'),
s = x.length,
g = a.getElementsByClassName('g');
while (s) {
for (i = l, c = x[--s].href; i;) {
if (~c.search(f[--i])) {
b.push(g[s]);
break;
}
}
}
toggleDisplay();
}
i.insertBefore(e, i.firstChild);
e.style.cssText = 'font-size: x-small; color: #7070FF;';
googleFilter(i);
e.addEventListener('click', function () {
toggleDisplay(1);
}, false);
addEventListener('AutoPagerize_DOMNodeInserted', function (e) {
googleFilter(e.target);
}, false);
addEventListener('AutoPatchWork.DOMNodeInserted', function (e) {
googleFilter(e.target);
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment