v.1.01 - Thanks Google, very cool!
- basically a full fucking rewrite because of another Google Image search minor design change no one asked for.
This commit is contained in:
parent
7ba47690f9
commit
54697d7a8d
|
@ -1,27 +1,59 @@
|
|||
// ==UserScript==
|
||||
// @name Google Images filter
|
||||
// @namespace https://fem.mint.lgbt/f.strw
|
||||
// @version v1
|
||||
// @version v1.01
|
||||
// @description Block certain websites from appearing on Google Images search result.
|
||||
// @author f.strw
|
||||
// @include *
|
||||
// @include *
|
||||
// @grant none
|
||||
// ==/UserScript==
|
||||
|
||||
(function() {
|
||||
'use strict';
|
||||
if (window.location.search.indexOf('&tbm=isch') > -1) {
|
||||
var blockedDomains = ["redbubble.com", "etsy.com", "amazon.com", "amazon.de", "aliexpress.com", "teepublic.com", "badgeland.com", "ebay.com"];
|
||||
var links = document.getElementsByTagName("a");
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
for (var j = 0; j < blockedDomains.length; j++) {
|
||||
if (links[i].href.indexOf(blockedDomains[j]) !== -1) {
|
||||
var parentDiv = links[i].closest("div");
|
||||
if (parentDiv) {
|
||||
parentDiv.remove();
|
||||
|
||||
function isButtonSelected(btnName) {
|
||||
var buttons = document.querySelectorAll('div[jsname="bVqjv"]');
|
||||
|
||||
for (let btn of buttons) {
|
||||
if (btn.hasAttribute('selected')) {
|
||||
var btnText = btn.getElementsByTagName('span');
|
||||
for (let text of btnText) {
|
||||
if (text.textContent == btnName) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
function removeImages() {
|
||||
if (isButtonSelected("Images")) {
|
||||
var blockedDomains = ["redbubble.com", "etsy.com", "amazon.com", "amazon.de", "amazon.sg", "aliexpress.com", "teepublic.com", "badgeland.com", "ebay.com"];
|
||||
var links = document.getElementsByTagName("a");
|
||||
for (var i = 0; i < links.length; i++) {
|
||||
for (var j = 0; j < blockedDomains.length; j++) {
|
||||
if (links[i].href.indexOf(blockedDomains[j]) !== -1) {
|
||||
var parentDiv = links[i].closest("div");
|
||||
if (parentDiv && parentDiv.parentElement && parentDiv.parentElement) {
|
||||
var grampsDiv = parentDiv.parentElement;
|
||||
grampsDiv.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function run() {
|
||||
if (document.readyState === "complete" || document.readyState === "interactive") {
|
||||
removeImages();
|
||||
}
|
||||
else {
|
||||
setTimeout(run, 100);
|
||||
}
|
||||
}
|
||||
|
||||
run();
|
||||
})();
|
Loading…
Reference in a new issue