Google Hit Hider by Domain (Search Filter / Block Sites)

Block unwanted sites from your Google, DuckDuckGo, Startpage.com, Bing and Yahoo search results. v2.2.8 2023-07-19

Old: v1.9.1 - 2017-12-13 - Transition from GM_addStyle to local function for better cross-engine compatibility
New: v1.9.2 - 2018-01-20 - Fix GHHbD button on Google Image results, initial support for Baidu

  • --- /tmp/diffy20240419-3324103-69j0sm 2024-04-19 06:14:03.553729139 +0000
  • +++ /tmp/diffy20240419-3324103-yip6gu 2024-04-19 06:14:03.553729139 +0000
  • @@ -2,10 +2,10 @@
  • // @name Google Hit Hider by Domain (Search Filter / Block Sites)
  • // @author Jefferson "jscher2000" Scher
  • // @namespace JeffersonScher
  • -// @version 1.9.1
  • -// @copyright Copyright 2017 Jefferson Scher
  • +// @version 1.9.2
  • +// @copyright Copyright 2018 Jefferson Scher
  • // @license BSD-3-Clause
  • -// @description Block unwanted sites from your Google, DuckDuckGo, Startpage.com, Bing and Yahoo search results. For Firefox+Greasemonkey or Chrome+Tampermonkey. v1.9.1 2017-12-13
  • +// @description Block unwanted sites from your Google, DuckDuckGo, Startpage.com, Bing and Yahoo search results. v1.9.2 2018-01-20
  • // @include http*://www.google.*/*
  • // @include http*://news.google.*/*
  • // @include http*://images.google.*/*
  • @@ -22,6 +22,7 @@
  • // @include http*://searx.*/*
  • // @include http*://www.qwant.com/*
  • // @include http*://www.qwantjunior.com/*
  • +// @include http*://www.baidu.com/*
  • // @grant GM_getValue
  • // @grant GM.getValue
  • // @grant GM_setValue
  • @@ -31,11 +32,11 @@
  • // @grant GM.deleteValue
  • // @grant GM_getResourceURL
  • // @grant GM.getResourceUrl
  • -// @resource mycon http://www.jeffersonscher.com/gm/src/gfrk-GHHbD-ver191.png
  • +// @resource mycon http://www.jeffersonscher.com/gm/src/gfrk-GHHbD-ver192.png
  • // ==/UserScript==
  • var script_about = "https://greasyfork.org/scripts/1682-google-hit-hider-by-domain-search-filter-block-sites";
  • /*
  • -Copyright (c) 2017 Jefferson Scher. All rights reserved.
  • +Copyright (c) 2018 Jefferson Scher. All rights reserved.
  • Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met and subject to the following restriction:
  • @@ -60,6 +61,7 @@
  • Google Images (default): div#res > div#search > div > div#ires > div#rso > div#isr_mc > div > div#rg > div#rg_s > div.rg_di.rg_el.ivg-ig > a > img
  • Searx.me: div#main_results > div.result > h4.result_header > a
  • Qwant: div.results-column > div.result_fragment > div.result--web | div.result--news > h3 > a
  • +Baidu: (title) #content_left > div.result.c-container > h3 > a; (domain) #content_left > div.result.c-container > div > a.c-showurl
  • */
  • var GM4 = (typeof GM_getValue === "undefined") ? true : false;
  • function GHHbD_addStyle(txt){
  • @@ -359,7 +361,7 @@
  • if (document.getElementById("GTR")) removePBs();
  • } else {
  • if (el.nodeName == "DIV" && (el.className.indexOf("irc_c") > -1 || el.className.indexOf("irc_bg") > -1)) {
  • - var buttondivs = el.querySelectorAll('.irc_butc:not([ghhresult])');
  • + var buttondivs = el.querySelectorAll('.irc_butc:not([ghhresult]), .irc_but_r:not([ghhresult])');
  • for (var k=0; k<buttondivs.length; k++){
  • buttondivs[k].setAttribute("ghhresult", "image-unset");
  • buttondivs[k].style.position = "relative";
  • @@ -376,7 +378,7 @@
  • if (currentG.indexOf("google") > -1){ //Google
  • liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res #rso div.g, #res #GTR div.g, #res #isr_mc");
  • } else {
  • - liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep, div#b_content > ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news');
  • + liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep, div#b_content > ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news, #content_left > div.result.c-container');
  • }
  • if (!liels) return;
  • }
  • @@ -384,7 +386,7 @@
  • if (currentG.indexOf("google") > -1){ //Google
  • liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res #rso div.g, #res #GTR div.g, #res #isr_mc");
  • } else {
  • - liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep, div#b_content > ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news');
  • + liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep, div#b_content > ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news, #content_left > div.result.c-container');
  • }
  • }
  • if (liels.length == 0) return;
  • @@ -412,15 +414,18 @@
  • if (!ael) ael = liels[i].querySelector("h2 a, h4 a");
  • if (!ael) ael = liels[i].querySelector("a");
  • if (liels[i].className.indexOf("videobox")>-1) ael = liels[i].querySelectorAll("td")[1].querySelector("a"); //video page
  • + if (currentG.indexOf("baidu") > -1) ael = liels[i].querySelector("a.c-showurl");
  • if (ael){ahref=ael.getAttribute("href"); if(ahref){if (ahref.indexOf("http")==0 || ahref.indexOf("/interstitial")==0 ||
  • - ahref.indexOf("/url?q=")==0 || ahref.indexOf(currentG+"/url?q=")>-1 || (ahref.indexOf("/aclk?")==0 && liels[i].className.indexOf("psli")>-1)
  • - || ahref.indexOf("//r.search.yahoo")==0){
  • + ahref.indexOf("/url?q=")==0 || ahref.indexOf(currentG+"/url?q=")>-1 ||
  • + (ahref.indexOf("/aclk?")==0 && liels[i].className.indexOf("psli")>-1)
  • + || ahref.indexOf("//r.search.yahoo")==0 || ahref.indexOf(currentG+"/link?url=")>-1){
  • dom = ahref.substr(ahref.indexOf("http"));
  • if (ael.hasAttribute("data-href")) dom = ael.getAttribute("data-href").substr(ael.getAttribute("data-href").indexOf("http"));
  • if (dom.indexOf(currentG+"/aclk?")>-1) dom = ahref.substr(ahref.indexOf("http", 10));
  • if (ahref.indexOf("r.search.yahoo.com/_ylt=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("RU=http")+3));
  • if (dom.indexOf("search.yahoo.co.jp/r/FOR=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("/**http")+3));
  • if (dom.indexOf("https://ixquick-proxy.com/do/spg/highlight.pl")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("&u=http")+3));
  • + if (currentG.indexOf("baidu") > -1) dom = '//' + ael.textContent.replace('https://', '').replace('....', '');
  • // if (dom.indexOf("imgrefurl")>-1) dom = dom.match(/imgrefurl=([^&]+)/)[1];
  • dom = dom.split("/")[2];
  • if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
  • @@ -495,6 +500,7 @@
  • if (liels[i].hasAttribute("blocknotice")) liels[i].removeAttribute("blocknotice");
  • // Insert block button
  • apar = ael;
  • + if (currentG.indexOf("baidu") > -1) apar = liels[i].querySelector("h3 a");
  • if (!apar.nextElementSibling){
  • if (apar.parentNode.nodeName != "LI" &&
  • apar.parentNode.nodeName != "TD" &&
  • @@ -1041,7 +1047,7 @@
  • e.stopPropagation();
  • }
  • function adjpartdom(e){ // v1.8.1
  • - var pspan = document.getElementById("ghhpartdom");
  • + var pspan = document.getElementById("ghhpartdom").replace('...', '');
  • var parts = pspan.textContent.split(".");
  • if (parts.length <= 2){ // cycle back to the original partial domain
  • parts = document.getElementById("ghhfulldom").textContent.split(".");
  • @@ -1264,7 +1270,7 @@
  • "for regular blocked hits\"><input type=\"checkbox\" name=\"chkshownotc\" id=\"chkshownotc\"> Show hidden hit notices</label><br>" +
  • "<label title=\"Switch between block dialog and one-click blocking\"><input type=\"checkbox\" name=\"chk1click\" " +
  • "id=\"chk1click\"> Enable 1-click blocking</label></p>" +
  • - "<p style=\"border-top:1px solid #000; padding:0.25em;margin:0.25em\">v1.9.1 &copy; 2017 Jefferson Scher. Learn more on " +
  • + "<p style=\"border-top:1px solid #000; padding:0.25em;margin:0.25em\">v1.9.2 &copy; 2018 Jefferson Scher. Learn more on " +
  • "<a href=\"" + script_about + "\">this script's page</a>.</p></div></div>" +
  • "<div id=\"ghhmt2\" style=\"display:none\"><p>Click to remove from regular block list:</p>" +
  • "<div class=\"ghhtab\"><ul id=\"ghhsitelist\"></ul></div></div>\n" +