// ==UserScript== // @name Google Images filter // @namespace https://fem.mint.lgbt/f.strw // @version v1.01 // @description Block certain websites from appearing on Google Images search result. // @author f.strw // @match *://*.google.com/* // @grant none // ==/UserScript== (function() { 'use strict'; 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(); })();