// ==UserScript== // @name Google Hit Hider by Domain (Search Filter / Block Sites) // @author Jefferson "jscher2000" Scher // @namespace JeffersonScher // @version 2.3.5 // @copyright Copyright 2025 Jefferson Scher // @license BSD-3-Clause // @description Block unwanted sites from your Google, DuckDuckGo, Startpage.com, Bing and Yahoo search results. v2.3.5 2025-03-21 // @include http*://www.google.*/* // @exclude http*://www.google.com/recaptcha/* // @include http*://www.google.co*.*/* // @include http*://news.google.*/* // @include http*://encrypted.google.*/* // @include http*://startpage.com/* // @include http*://*.startpage.com/* // @exclude https://www.startpage.com/*/ads?* // @exclude https://www.startpage.com/*/*/ads* // @exclude https://us-browse.startpage.com/av/proxy?* // @include http*://duckduckgo.com/* // @include http*://start.duckduckgo.com/* // @include http*://safe.duckduckgo.com/* // @include http*://3g2upl4pq6kufc4m.onion/* // @include http*://www.bing.com/* // @include http*://*search.yahoo.com/* // @include http*://search.yahoo.co.jp/* // @include http*://www.yandex.com/* // @include http*://yandex.com/* // @include http*://searx.*/* // @include http*://www.qwant.com/* // @include http*://www.qwantjunior.com/* // @include http*://www.baidu.com/* // @include https://www.ecosia.org/search* // @grant GM_getValue // @grant GM.getValue // @grant GM_setValue // @grant GM.setValue // @grant GM_registerMenuCommand // @grant GM_deleteValue // @grant GM.deleteValue // @grant GM_getResourceURL // @grant GM.getResourceUrl // @resource mycon https://www.jeffersonscher.com/gm/src/gfrk-GHHbD-ver235.png // @downloadURL https://update.greasyfork.icu/scripts/1682/Google%20Hit%20Hider%20by%20Domain%20%28Search%20Filter%20%20Block%20Sites%29.user.js // @updateURL https://update.greasyfork.icu/scripts/1682/Google%20Hit%20Hider%20by%20Domain%20%28Search%20Filter%20%20Block%20Sites%29.meta.js // ==/UserScript== var script_about = "https://greasyfork.org/scripts/1682-google-hit-hider-by-domain-search-filter-block-sites"; /* Copyright (c) 2025 Jefferson Scher. 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: 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. 2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. 3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission. THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ var GM4 = (typeof GM.getValue === "undefined") ? false : true; function GHHbD_addStyle(txt){ var s=document.createElement('style'); s.className = 'GHHbDcss'; s.appendChild(document.createTextNode(txt)); document.body.appendChild(s); } var isch = false, nws = false; function injectBaseCSS(){ // == == == To override the style of the script's buttons and panes, use the custom style feature == == == GHHbD_addStyle("div.ghhider{color:#888;} div.ghhider:hover{background-color:#eee;} " + "button.ghhider{color:#555;background-color:#fcfcfc;font-family:sans-serif;font-size:0.85em;line-height:1.2em;margin:auto 2px;border:1px solid #ccc;border-radius:4px;padding:2px 3px;} h3>button.ghhider{font-size:0.75em;} " + "button.ghhider:hover{color:#000;background:#ff8;} .ghh1time{background:#eee !important;} .ghhdnone{display:none !important;} " + ".ghhpane{position:absolute;color:#333;background-color:#fcfcfc;border:1px solid #ccc;border-radius:4px;padding:0.25em 1.5em;font-size:13px;display:none} " + "#ghhsitelist, #ghhpbanlist{background:#fff;list-style-type:none;padding:0;margin:0;} " + "#ghhsitelist li,#ghhpbanlist li{width:100%;line-height:1.5em;padding:0;position:relative} " + "#ghhsitelist li:nth-of-type(odd),#ghhpbanlist li:nth-of-type(odd){background-color:#fcfcaa} " + ".ghhhost{display:block;padding:0 0.25em;cursor:pointer;} #ghhutil{text-align:center;margin:0.5em 0 1em 0;border:1px solid #ccc;border-radius:4px;padding:3px 0;} " + ".ghhinfo{font-size:12px;line-height:9px;position:absolute;top:0;right:0;z-index:1001;border:4px solid transparent;border-radius:4px;border-bottom-left-radius:8px;border-top-left-radius:8px;margin-top:1px;padding-left:1px} " + ".ghhdel{text-decoration:line-through;color:#333;} .ghhpb{text-decoration:none;color:#f00;} " + ".ghhblk{text-decoration:none;color:#333;} .ghhd{position:relative;line-height:1.2em;cursor:pointer;} " + ".ghhindent{position:absolute;left:350px;top:-3px;} #btnedit p{margin:2px 4px 4px 4px;} #ghhblockform input[type='radio'], #ghhmngform input[type='radio']{vertical-align:baseline !important;margin-top:5px;margin-bottom:1px} " + "#ghhblockform label, #ghhmngform label{display:inline;font-weight:normal;font-size:unset;} .ghhtbl{border:1px solid black;border-collapse:collapse} .ghhtbl td, .ghhtbl th{border:1px solid black;padding:2px 4px;} " + "#ghhtsdiv{margin:0 -1.5em;padding:0 3px 0 8px;border-bottom:1px solid #ccc;} #ghhtstrip{padding-bottom:0;} " + "#ghhtstrip button{color:#555;background-color:#f5f5f5;margin:0 2px 0 0;border:1px solid #ccc;padding:1px 2px;height:22px;border-radius:2px;} " + "#ghhtstrip .ghhCurTab{background-color:#fcfcfc;border-bottom-color:#fcfcfc;} .ghhtab {margin-top:1em;height:17em;overflow-y:scroll;border:1px solid #333;} " + "#mflists>div>p{margin:1em 0;} #ghhmngform{position:fixed;top:65px;right:0;z-index:9001;text-align:left;line-height:1.2em} #ghhblockform{text-align:left;z-index:3005} " + 'h3[wotdonut="true"]{overflow:visible!important} div.divGHHbD{text-align:right;align-self:flex-end;padding:4px;} ' + 'button.imgGHHbD{position:relative;z-index:1000;color:#609beb;background-color:#333;border:1px solid #609beb;} button.imgGHHbD:hover{background-color:#000;color:#0ee;}'); GHHbD_addStyle("@media print {button.ghhider,button.imgGHHbD{display:none;}}"); // Standard image results style block if (location.search.indexOf("tbm=isch") > -1 || location.search.indexOf("udm=2") > -1){ var ghhbd_imgsty = document.createElement("style"); ghhbd_imgsty.id = "ghhStyleImgResults"; ghhbd_imgsty.setAttribute("type", "text/css"); ghhbd_imgsty.appendChild(document.createTextNode('div[imgblock="regular"] img{opacity:0.1 !important} div.isv-r[imgblock="regular"] a div:first-of-type{opacity:0.6 !important} div[imgblock="regular"]:not(.isv-r) a div{display:block !important;opacity:0.6 !important}div[imgblock="regular"] img:hover{opacity:0.5 !important} div[imgblock="pban"]{background-color:#aaa !important;border-radius:6px !important} div[imgblock="pban"] a{display:none !important}')); document.body.appendChild(ghhbd_imgsty); isch=true; } if (location.search.indexOf("tbm=nws") > -1){ //v2.2.6 for News results under www var ghhbd_nwssty = document.createElement("style"); ghhbd_nwssty.id = "ghhStyleNwsResults"; ghhbd_nwssty.setAttribute("type", "text/css"); ghhbd_nwssty.appendChild(document.createTextNode('.ghhb{position:relative; top: -22px; float:right;} g-scrolling-carousel .ghhb{position:static !important; float:none;}')); document.body.appendChild(ghhbd_nwssty); nws=true; } } injectBaseCSS(); var currentG = location.hostname; var engine = 'misc'; function doSiteSpecific(){ if (currentG.indexOf("google") > -1){ engine = 'Google'; // Google: div#res > div#search > div > div#ires > div.srg | ol#rso | div._NId | div.bkWMgd > div.g > div.rc > h3.r > a // 3-21-2024 div#res > div#search > div > div#rso > div // Google in-depth articles: div#res > div#search > div#ires > ol#rso > div > li.g.card-section or li.g.ct-cs > div.rc > div > h3.r > a // 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 // 3-21-2024 div#res > div#search > div > div#rso > div h3 a g-img > img GHHbD_addStyle("#res>#search>div>#rso>div>.ghhider.ghhd,#res>#search>div>#rso>div.ghh1time{margin-block:1em;};"); } if (currentG.indexOf("bing.com") > -1){ engine = 'Bing'; // Bing: div#b_content > main > ol#b-results > li.b_algo > h2 > a // [as of v2.2.7 5/28/2023] true URL found in li.b_algo > div:not(.b_algo_group) cite GHHbD_addStyle("li[ghhresult] h2 button.ghhider{font-size:0.7em !important;} li > h2 {white-space:nowrap !important;}"); } if (currentG.indexOf("duckduckgo") > -1 || currentG.indexOf("3g2upl4pq6kufc4m") > -1){ engine = 'DDG'; // DuckDuckGo: div#links > div.results_links_deep > div.links_main > h2 > a GHHbD_addStyle(".links_main, .result__title{overflow:visible !important;} .result__title{white-space:nowrap !important;} " + ".ghhb{font-size:12px!important;margin-left:4px!important;}@media(min-width:600px){.ghhb {position:absolute;margin-top:4px!important}} " + '@media(max-width:599px){ol.react-results--main li h2 a {display:inline!important;}}' + ".results_links_deep[blocknotice] + .results__sitelink--organics,.ghhdnone + .results__sitelink--organics,.results_links_deep[blocknotice] + .result__sitelinks--organics,.ghhdnone + .result__sitelinks--organics {display:none;}"); // v2.2.3 2022-05-02: div#links > div.nrn-react-div > article > div > h2 > a // not sure what CSS changes might be needed yet // v2.2.5 2023-05-13: ol.react-results--main > li[data-layout="organic"] > article[data-testid="result"][data-nrn="result"] > div > h2 > a GHHbD_addStyle('li[blocknotice] .ghhider.ghhd{padding-left:10px !important;} li[ghhresult="unset"] h2 > a{display:inline-block !important;}'); } if (currentG.indexOf("startpage") > -1){ engine = 'Startpage'; // Startpage: div#results > ol > li > div.result > h3 > a // 11/21/2018: [data-view="results"] div.columns article.column.column--main > div.column.column--main__content > ol.list-flat > li.search-result.search-item > h3.search-item__title > a // 7/03/2019: div.mainline-results__web section.w-gl > div.w-gl__result > a.w-gl__result-title // 5/08/2024: div#main > div.w-gl > div.result > a.result-title.result-link, div#main > div.w-bg > div.result > div.result__main > a.result-title.result-link // 12/08/2024: for news, add: section#main > div.css-ndwlbg > div.article > div.article-left > a[href] GHHbD_addStyle('.w-gl__result{overflow:visible !important;}.ghhb{font-size:12px!important;}@media(min-width:651px){div.w-gl .result, div.w-bg .result{position:relative!important;}' + '.result button.ghhb{position:absolute;right:-30px;margin-top:-28px;} .result .result__main button.ghhb{margin-top:26px;}} .css-ndwlbg button.ghhb{float:right;margin-top:-2.5em;}' + 'div.w-gl__result .ghhd{padding:0 10px 8px 12px}button.ghhider{font-weight:normal;}' + '#ghhblockform input[type="checkbox"], #ghhmngform input[type="checkbox"]{width:unset;height:unset;position:static;margin:unset;border:unset;padding:unset;clip:unset;}' + '#ghhblockform button, #ghhmngform button{font-size:1em;font-weight:normal;border:1px solid #e3e3e3;border-radius:3px;padding:2px 8px;box-shadow:none} #ghhmngform{top:105px !important;}'); } if (currentG.indexOf("yahoo.com") > -1){ engine = 'Yahoo'; // Yahoo (Firefox): div#results > div#cols > div#left > div > div#main > div > div#web > ol > li > div > div > h3 > a // GHHbD_addStyle("div#web > ol.reg, li div.compTitle {overflow:visible !important;} .ghhd{margin: 1em 0px -1em 10px} #ghhmngform{top:80px} li div div h3{white-space:nowrap !important;}"); GHHbD_addStyle("div#web > ol.reg, li div.compTitle {overflow:visible !important; border-top:0.1px solid transparent;} .ghhd{margin: 1em 0px 0px 0px} #ghhmngform{top:80px} li div div h3{white-space:normal !important;}"); // v2.2.1 } if (currentG.indexOf("yahoo.co.jp") > -1){ // Yahoo Japan (OLD): div#contents > div > div > div > div#WS2m > div.w > div.hd > h3 > a // Yahoo Japan: div#contents > div#contents__wrap > div.Contents__inner Contents__inner--main > div.Contents__innerGroupBody > div.sw-CardBase div.sw-Card__title > a > h3 //v2.2.1 GHHbD_addStyle("#WS2m .w{overflow:visible !important;} #ghhmngform{z-index:3001}"); } if (currentG.indexOf("baidu") > -1){ engine = 'Baidu'; // Baidu: (title) #content_left > div.result.c-container > h3 > a; (domain) #content_left > div.result.c-container > div > a.c-showurl // Baidu rich result: (title) #content_left > div.result-op.c-container > h3 > a (or p.op_site_domain_title, div.op_generalqa_main.c-row); (domain) #content_left > div.result-op.c-container[mu] } if (currentG.indexOf("yandex.com") > -1){ // Yandex: div.serp-list | ul.serp-list > div.serp-item | li.serp-item > h2 > a GHHbD_addStyle("h2.serp-item__title{white-space:nowrap;}.ghhb{font-size:0.75em!important;margin-left:4px!important;}"); } if (currentG.indexOf("qwant") > -1){ // Qwant: div.results-column > div.result_fragment > div.result--web | div.result--news > h3 > a GHHbD_addStyle("div[blocknotice]:not(.ghh1time){min-height:1em;padding-left:0;}"); } if (currentG.indexOf("searx") > -1){ // Searx.me: div#main_results > div.result > h4.result_header > a GHHbD_addStyle("h2.serp-item__title{white-space:nowrap;}.ghhb{font-size:0.75em!important;margin-left:4px!important;}"); } if (currentG.indexOf("ecosia") > -1){ engine = 'Ecosia'; // Ecosia: div.results-wrapper > div.container.results ... div.card-web ... div.result-firstline-title > a.result-title // 8/31: section.web__mainline ... div.mainline__result-wrapper:not([data-test-id="mainline-result-ad"]) ... div.result__body > div.result__header > div.result__title > a.result__link GHHbD_addStyle('[ghhresult] h2.result-firstline-title>a.result-title,[ghhresult] div.result__title>a.result__link{display:inline;}' + '.web-result button.ghhb{position:absolute;right:-25px;top:0.5em;z-index:1;}.web-result .ghhdbuttons{position:relative;z-index:1;}' + 'div[blocknotice]:not(.ghh1time)>article{display:none;}'); } } doSiteSpecific(); function injectCustom(){ if (document.getElementById("ghhbdcuststy")) return; var ghhbd_custsty = document.createElement("style"); ghhbd_custsty.setAttribute("type", "text/css"); ghhbd_custsty.id = "ghhbdcuststy"; ghhbd_custsty.appendChild(document.createTextNode(custSty)); document.body.appendChild(ghhbd_custsty); } var custSty; if (!GM4){ custSty = GM_getValue("hiderStyles", ""); if (custSty.length > 0) injectCustom(); } else { GM.getValue("hiderStyles", "").then(function(value){custSty = value; if (custSty.length > 0) injectCustom();}); } // == == == Globals for preferences == == == var blist, defaultTxts, txtsPref, txts, defaultPrefs, ghhPrefs, ghhPrefO, showYN, mpopen, mbstyle, bbstyle, bbpos, addAt, listchgs, bLUopen, bAggress, bAJAX, bMutOb, pref1click, betatest, MutOb, chgMon, opts, kids, needupdate = true, doms = [], t_pb; var patIPv4 = /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/; function checkblist(){ if (blist.length === 0) blist = "|example.com:t|"; if (blist.substr(0,1) != "|") blist = "|" + blist; if (blist.indexOf(":") < 0) convertFormat(); } if (!GM4){ blist = GM_getValue("hideyhosts", ""); checkblist(); } else { GM.getValue("hideyhosts", "").then(function(value){blist = value; checkblist();}); } defaultTxts = { "block":["block","Button next to the result title to call up the block dialog"], "unblock":["Unblock","Green button in results to remove a site from the block list"], "onetime":["Show Hit","Yellow button in results to show a result temporarily"], "pban":["Perma-ban","Red button to move a site to the perma-ban list"], "shownotc":["Show Notices","Button to set the preference for notices to show them"], "hidenotc":["Hide Notices","Button to set the preference for notices to hide them"], "okbtn":["Block Site","Button in the block dialog to block the selected domain"], "cancelbtn":["Cancel","Button in the block dialog to cancel out with making changes"], "savebtn":["Save Lists","Button in the management pane to update the block and perma-ban lists"], "closebtn":["Close","Button in the management pane to close the pane"], "okPbtn":["Perma-ban","Button in the block dialog to perma-ban the selected domain"], "cancelMbtn":["Manage Hiding","Button in the block dialog to open the management pane"], "mngbtn":["Manage Hiding","Button on the right side to open the management pane"], "eximbtn":["Export","Button in the management pane to export the block list"], "utilbtn":["List Util","Button in the management pane to open the utility panel"], "sortbtn":["Sort","Button in the management pane to sort the block list"], "unwwwbtn":["Un-www","Button in the management pane to strip www from blocked domains"], "dedupbtn":["De-Dup","Button in the management pane to de-duplicate the block list"], "impobtn":["Import","Button in the management pane to import domains into the block list"], "sharebtn":["Share","Button in the management pane to post block list to the web"], "addallbtn":["Add All","Button in the management pane to bulk add all unblocked domains to current list"] }; function checktxts(){ if (txtsPref.indexOf(":[") == -1 || txtsPref.indexOf("mngbtn") == -1 || txtsPref.indexOf("eximbtn") == -1 || txtsPref.indexOf("utilbtn") == -1 || txtsPref.indexOf("impobtn") == -1 || txtsPref.indexOf("addallbtn") == -1) { convertTxts(txtsPref); } else { txts = JSON.parse(txtsPref); } } if (!GM4){ txtsPref = GM_getValue("textstrings", JSON.stringify(defaultTxts)); checktxts(); } else { GM.getValue("textstrings", JSON.stringify(defaultTxts)).then(function(value){txtsPref = value; checktxts();}); } defaultPrefs = { "shownotc":["Y","Show hit notices(Y|N)"], "mngpaneopen":["Y-N","Persistence enabled(Y|N),Pane was open(Y|N),Last tab number(1-4)"], "mngbtnstyle":["both-ifrN-R-P-Y-H","Display Manage Hiding button and Block buttons(mng|blk|both),In iframes(ifrN|ifrY),Position(R,T,B),Block button display(P,M),Block button tooltips(Y|N), Block button position(H|C)"], "addtolistpos":["end","Where to add new hits to block lists(end|top|sort)"], "aggressiveblock":["none","Which domains to default to shorter form(none|all|www)"], "usemutation":["on-Y","Listen for mutation events(on|off),Use DOM4 Mutation Observer(Y|N)"], "oneclick":["N-N","One-click blocking(Y|N),Goes to Perma-ban(Y|N)"], "runbeta":["N","Enable incompletely tested features (Y|N)"], "reserved2":["X","Y"] }; function checkprefs(){ if (ghhPrefs.length == 0){ convertPrefs(defaultPrefs, "true"); } else { if (ghhPrefs.indexOf("reserved1")>-1){ convertPrefs(defaultPrefs, "false"); } else { ghhPrefO = JSON.parse(ghhPrefs); } } } if (!GM4){ ghhPrefs = GM_getValue("ghhprefs", ""); checkprefs(); if (engine == 'Startpage') window.setTimeout(GHHbDinit, 300); else GHHbDinit(); } else { GM.getValue("ghhprefs", "").then(function(value){ ghhPrefs = value; checkprefs(); if (engine == 'Startpage') window.setTimeout(GHHbDinit, 300); else GHHbDinit(); }); } function GHHbDinit(){ showYN = ghhPrefO.shownotc[0]; mpopen = ghhPrefO.mngpaneopen[0]; mbstyle = ghhPrefO.mngbtnstyle[0]; if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H"); if (mbstyle.split("-").length < 3){ GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+ "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}"); } else { switch (mbstyle.split("-")[2]){ case "B": GHHbD_addStyle("#ghhMngBtn {position:fixed;bottom:0;right:2px;"+ "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}"); break; case "T": GHHbD_addStyle("#ghhMngBtn {margin:0;padding:4px 6px;z-index:3000;}"); if (document.querySelector("#appbar ol")){ window.setTimeout(function(){document.querySelector("#appbar ol#ab_ctls").appendChild(document.getElementById("ghhMngBtn"))}, 1000); window.setTimeout(function(){var liNew = document.createElement("li");liNew.className="ab_ctl";liNew.appendChild(document.getElementById("ghhMngBtn"));document.querySelector("ol#ab_ctls").appendChild(liNew);}, 1500); } else { window.setTimeout(function(){if (document.querySelector("#appbar ol")){var liNew = document.createElement("li");liNew.className="ab_ctl";liNew.appendChild(document.getElementById("ghhMngBtn"));document.querySelector("ol#ab_ctls").appendChild(liNew);}else{document.getElementById("ghhMngBtn").setAttribute("style","position:absolute;top:8em;right:0")}}, 1500); } break; default: GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+ "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}"); } } if (mbstyle.split("-").length > 3) bbstyle = mbstyle.split("-")[3]; else bbstyle = "P"; if (mbstyle.split("-").length > 5) bbpos = mbstyle.split("-")[5]; else bbpos = "H"; // toggleciteline(bbpos); called by fixuistyle() addAt = ghhPrefO.addtolistpos[0]; listchgs = 0; bLUopen = "N"; bAggress = ghhPrefO.aggressiveblock[0]; bAJAX = ghhPrefO.usemutation[0].split("-")[0]; if (ghhPrefO.usemutation[0].split("-").length > 1) bMutOb = ghhPrefO.usemutation[0].split("-")[1]; else bMutOb = "Y"; pref1click = ghhPrefO.oneclick[0]; betatest = ghhPrefO.runbeta[0]; if (document.body){ // Add buttons, hide unwanted domains hidehits(null,false); if (document.getElementById("GTR")) removePBs(); // Special results layout if (betatest == "Y"){ var itbl = document.querySelector("#res .images_table"); if (itbl) hidebasic(itbl); } // Create skeleton of manage form if (!document.getElementById("ghhmngform")) addManageForm(); // Add manage button if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk"){ if (engine == 'Google'){if(document.getElementById("res") || isch) addMngBtn();} else addMngBtn(); } // Show pane if last open if (mpopen.substr(0,3) == "Y-Y") showManageForm("mngform"); // Add menu item - Legacy Only if (typeof GM_registerMenuCommand != "undefined") GM_registerMenuCommand("Manage Hiding", showManageForm); // Create block form if (!document.getElementById("ghhblockform")) addBlockForm(); // Watch for changes that could be new instant or AJAX search results if (bAJAX == "on") setMutationWatch(); } // Delayed for Ecosia if (engine == 'Ecosia') window.setTimeout(function(){hidehits(document.querySelectorAll('div.mainline__result-wrapper:not([data-test-id="mainline-result-ad"])'));}, 5000); } function setMutationWatch(){ // Prefer MutationObserver (Firefox 14+) over Mutation Events MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver; if (MutOb && bMutOb == "Y"){ chgMon = new MutOb(function(mutationSet){ mutationSet.forEach(function(mutation){ if (mutation.type == "childList"){ for (var i=0; i -1) return; if (el.hasAttribute("id")){if (ignoreIds.indexOf("|"+el.id+"|") > -1) return;} if (el.hasAttribute("class")){ if (ignoreClass.indexOf("|"+el.className+"|") > -1) return; if (el.classList.contains("goog-date")) return; } if (!document.getElementById("ghhmngform")){ addManageForm(); injectBaseCSS(); injectCustom(); if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk"){ if (engine == 'Google'){if(document.getElementById("res")) addMngBtn();} else addMngBtn(); } // Use default button style for now (1.9.3) GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+ "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}"); } checkNode(el); } function checkNode(el){ if (el.parentNode && (el.parentNode.id == 'ghhsitelist' || el.parentNode.id == 'ghhpbanlist')) return; // 2.0.6 duh! // AutoPager extension if (document.querySelector("#navcnt")){ if (t_ap) window.clearTimeout(t_ap); t_ap = window.setTimeout(refreshListeners, 500); } if (el.nodeName == "LI" || (el.nodeName == "DIV" && (el.className == "g" || el.classList.contains("rg_di") || el.className == "rgsh")) || el.nodeName == 'G-INNER-CARD' || el.nodeName == 'G-CARD' || el.classList.contains("isv-r")) var nlist = [el]; else nlist = el.querySelectorAll('li.g, div.g, div.rg_di, div.isv-r'); if (engine != 'Google' && el.nodeName != "LI"){ if (el.nodeName == "DIV" && (el.classList.contains("result--web") || el.classList.contains("result--news") || el.className == "card-mobile" || el.classList.contains('nrn-react-div'))) nlist = [el]; // Qwant, Ecosia, DDG-react else if (el.nodeName == "OL" && el.classList.contains('react-results--main')) nlist = el.querySelectorAll('li'); else if (engine == 'Ecosia') nlist = el.querySelectorAll('div.mainline__result-wrapper:not([data-test-id="mainline-result-ad"])'); else nlist = el.querySelectorAll('div.result, div.result-op, div.links_main, div.serp-item, div.hd, li.b_algo, ol.list-flat > li, div.card-web div.card-mobile'); } if (nlist.length > 0){ if (isch) hidehits(nlist,true); else hidehits(nlist,false); if (document.getElementById("GTR")) removePBs(); } else if (el.nodeName == "DIV" && ( (el.classList.contains("irc_c") || el.classList.contains("irc_bg")) || el.id == 'irc_bg') ) { var buttondivs = el.querySelectorAll('.irc_butc:not([ghhresult]), .irc_but_r:not([ghhresult]), .irc_ab:not([ghhresult]), .irc_but_pdfr:not([ghhresult])'); for (var k=0; k 0 && abtn[0].closest('c-wiz') != null) var alnk = abtn[0].closest('c-wiz').querySelector('a[role="link"][href]'); if (alnk && !alnk.parentNode.hasAttribute('ghhresult')) { alnk.parentNode.setAttribute('ghhresult', 'image-unset'); var dnew = document.createElement("div"); dnew.classList.add('divGHHbD'); // v2.2.8 update horizontal position for flex layout, move styling to classes dnew.innerHTML = ''; alnk.parentNode.insertBefore(dnew, alnk); dnew.firstChild.addEventListener("click", imgblockdialog, false); } } if (document.querySelectorAll('style.GHHbDcss').length === 0){ // Bing losing styles... 2018-10-01 injectBaseCSS(); doSiteSpecific(); GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+ "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}"); } } var parentcard; function hidehits(liels,ovrd){ if (!liels){ if (engine == 'Google'){ liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res div._bkWMgd div.g, #res #rso div.g, #res>#search>div>#rso>div, #res #GTR div.g, #res #isr_mc, g-section-with-header g-scrolling-carousel g-inner-card, g-card div.dbsr, g-card, [data-async-context^=\"query:\"] div.g"); } else { liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep > div.links_main, div#links > div.nrn-react-div, div#b_content ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.sw-CardBase, 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, #content_left > div.result-op.c-container, ol.list-flat > li, div.w-gl__result, div.w-gl > div.result, div.w-bg > div.result, div.css-ndwlbg > div.article, div.card-web div.card-mobile, ol.react-results--main > li'); if (liels.length == 0 && engine == 'Ecosia'){ window.setTimeout(function(){hidehits(document.querySelectorAll('div.mainline__result-wrapper:not([data-test-id="mainline-result-ad"])'), true);}, 250); return; } } if (nws == true) liels = document.querySelectorAll('#res #rso div[class][data-hveid]'); //v2.2.6 for News results under www if (!liels) return; } if (isch && liels.length==0){ liels = document.querySelectorAll('div.rg_di, div.isv-r'); } else if (liels.length==0){ if (engine == 'Google'){ liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res div._bkWMgd div.g, #res #rso div.g, #res>#search>div>#rso>div, #res #GTR div.g, #res #isr_mc, g-section-with-header g-scrolling-carousel g-inner-card, g-card div.dbsr, g-card, [data-async-context^=\"query:\"] div.g"); } else { liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep > div.links_main, div#links > div.nrn-react-div, div#b_content ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.sw-CardBase, 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, #content_left > div.result-op.c-container, ol.list-flat > li, div.w-gl__result, div.w-gl > div.result, div.w-bg > div.result, div.css-ndwlbg > div.article, div.card-web div.card-mobile, ol.react-results--main > li'); } } if (liels.length == 0) return; if (liels.length == 1){ // Google Standard Image Results if(liels[0].id == "isr_mc") liels = liels[0].querySelectorAll(".rg_di"); } // Clean up overselection on Google wiki result pages? v2.3.5 if (engine == 'Google'){ var nlndx, crntNode, nlTemp = [], nltndx, arrEls = []; for (nlndx=0; nlndxh3, h3>a').length > 1){ nlTemp = crntNode.querySelectorAll('a>h3, h3>a'); for (nltndx=0; nltndxh3, h3>a').length == 1) crntNode = crntNode.parentNode; arrEls.push(crntNode); } } else { arrEls.push(liels[nlndx]); } } liels = arrEls; } var hosts, hiders, nhider, i, j, k, hid, ael, ahref, dom, dompart, btn, apar, dgone, pban, linkwidth; hosts = blist; for (i=0; i a, h3 a, div.rc a"); // first link (not useful for video or book blocks),

preferred if (!ael || ael.parentNode.className=='deeplink_title') ael = liels[i].querySelector("h2 a, h4 a"); if (!ael) ael = liels[i].querySelector("a"); if (liels[i].classList.contains("videobox")) ael = liels[i].querySelectorAll("td")[1].querySelector("a"); //video page if (engine == 'Google' && location.search.indexOf('adtest=on') > -1){ ael = liels[i].querySelector('cite'); if(ael){if(!ael.hasAttribute('href')){ if (ael.textContent.indexOf('http://')===-1 && ael.textContent.indexOf('https://')===-1) ael.setAttribute('href', 'http://'+ael.textContent); else ael.setAttribute('href', ael.textContent); }} } if (engine == 'Baidu'){ if(liels[i].hasAttribute('mu')){ liels[i].insertAdjacentHTML('beforeend', '' + liels[i].getAttribute('mu') + ''); } ael = liels[i].querySelector("a.c-showurl"); if(ael){if(!ael.hasAttribute('href')){ if (ael.textContent.indexOf('http://')===-1 && ael.textContent.indexOf('https://')===-1) ael.setAttribute('href', 'http://'+ael.textContent); else ael.setAttribute('href', ael.textContent); }} } if (engine == 'Startpage' && !ael){ ael = liels[i].querySelector('a.result-link'); } if (ael){ahref=ael.getAttribute("href"); if(ahref){if (ahref.search(/http|ftp/i)==0 || ahref.indexOf("/interstitial")==0 || ahref.indexOf("/url?q=")==0 || ahref.indexOf(currentG+"/url?q=")>-1 || ahref.indexOf("/url?sa=")==0 || (ahref.indexOf("/aclk?")==0 && liels[i].classList.contains("psli")) || ahref.indexOf("//r.search.yahoo")==0 || ahref.indexOf(currentG+"/link?url=")>-1 || ahref.indexOf('/rebates/welcome') === 0){ if (engine == 'Bing'){ // v2.2.7 if (ahref.indexOf('https://www.bing.com/') === 0 || ahref.indexOf('/rebates/welcome') === 0){ var citeEl = liels[i].querySelector('div:not(.b_algo_group) cite'); if (citeEl) ahref = citeEl.textContent.trim(); } } dom = ahref.substr(ahref.search(/http|ftp/i)); 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("/url?sa=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("&url=")+5)); 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('http://', '').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 dompart = dom; liels[i].setAttribute("ghhhost",dompart); while (dompart.indexOf(".")> -1) { if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck if (nhider > 0){ // Remove old buttons, notices, etc. for (k=hiders.length-1; k>=0; k--){ hiders[k].remove(); nhider = liels[i].getElementsByClassName("ghhider").length; } } if (liels[i].classList.contains("ghh1time") === false){ if (hosts.indexOf("|"+dompart+":p")<0) { // Regular block if (showYN=="Y"){ if (liels[i].classList.contains("results_links_deep")){ // DDG replaceHit(dompart,ael,liels[i].querySelector(".links_main"),""); } else replaceHit(dompart,ael,liels[i],""); } else replaceHit(dompart,ael,liels[i],"none"); } else { // Perma-ban liels[i].setAttribute("blockhidden",dompart); if (engine != 'Google' && liels[i].classList.contains("ghhdnone") === false){ liels[i].classList.add('ghhdnone'); if (liels[i].classList.contains("links_main")) liels[i].parentNode.classList.add('ghhdnone'); } } if (engine == 'DDG' && liels[i].classList.contains("results_links_deep")) kids = liels[i].lastElementChild.children; //DDG else kids = liels[i].children; for (j=0; j 1) { // Remove previous block & reset nhider if (liels[i].children[0].classList.contains("ghhd")) liels[i].children[0].remove(); // Clean up unblocked one-times if (liels[i].classList.contains("ghh1time")){ liels[i].classList.remove('ghh1time'); dgone = liels[i].getElementsByClassName("ghhd"); if (dgone.length > 0) dgone[0].remove(); dgone = liels[i].getElementsByClassName("ghhdbuttons"); if (dgone.length > 0) dgone[0].remove(); } nhider = liels[i].getElementsByClassName("ghhider").length; } if (hid == false && (nhider == 0 || liels[i].children[0].nodeName.toLowerCase() == 'g-section-with-header')) { // Not blocked, insert block button // First, remove hiding for unblocked domains if (engine == 'DDG' && liels[i].classList.contains("results_links_deep")) kids = liels[i].lastElementChild.children; //DDG else kids = liels[i].children; for (j=0; j -1){ apar = liels[i].querySelector("h3 a, a"); if (!apar.hasAttribute('hreforiginal')) apar.setAttribute('hreforiginal', ael.getAttribute('href')); } else { if (!apar.hasAttribute('hreforiginal')) apar.setAttribute('hreforiginal', apar.href); } } if (engine == 'Baidu'){ apar = liels[i].querySelector("h3 a, .c-result-content a"); if (!apar && liels[i].querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row") != null) apar = liels[i].querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row").firstChild; } if (apar != null && !apar.nextElementSibling){ if (apar.parentNode.nodeName != "LI" && apar.parentNode.nodeName != "TD" && apar.parentNode.nodeName != "H2") apar = apar.parentNode; } if (apar != null && apar != undefined) { if (dom.indexOf(currentG)<0 && (liels[i].parentNode != document.querySelector("#tads ol")) && (liels[i].parentNode != document.querySelector("#bottomads ol")) && (liels[i].parentNode != document.querySelector("#ads div")) && (liels[i].parentNode != document.querySelector("#rhs ol"))){ btn = document.createElement("button"); btn.appendChild(document.createTextNode(txts.block[0])); btn.className="ghhider ghhb"; btn.setAttribute("meta",dom); if (pref1click.substr(0,1) == "Y" && mbstyle.split("-")[4] == "Y"){ //BUG: for 1-click with aggressive (subdomain) settings, dom will be incorrect if (engine == 'Google') btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form / ALT+click to omit"); else btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form"); } else if (mbstyle.split("-")[4] == "Y"){ if (engine == 'Google') btn.setAttribute("title","Block "+dom+" / Show block form / ALT+click to omit"); else btn.setAttribute("title","Block "+dom+" / Show block form"); } btn.addEventListener("click",showbfd,true); // Position button inside the H2 or H3 or H4 if (apar.nodeName == "H3" || apar.nodeName == "H2" || apar.nodeName == "H4" || engine == 'Startpage'){ apar.style.overflow = "visible"; apar.appendChild(btn); // full link text tooltip if (engine == 'Yahoo' && apar.querySelector('a').childNodes[0].nodeName == 'SPAN') apar.querySelector('a').setAttribute("title",apar.querySelector('a').childNodes[1].textContent); else if (engine == 'Startpage' && apar.nodeName == 'A') { apar.parentNode.insertBefore(btn, apar.nextSibling); apar.setAttribute("title",apar.firstElementChild.textContent); } else apar.querySelector('a').setAttribute("title",apar.querySelector('a').textContent); } else if (apar.parentNode.parentNode.nodeName == 'G-CARD'){ apar.parentNode.appendChild(btn); apar.parentNode.parentNode.style.overflowY = 'visible'; apar.parentNode.parentNode.style.height = 'unset'; apar.parentNode.parentNode.style.position = 'relative'; } else if (apar.parentNode.className == 'dbsr') { apar.parentNode.appendChild(btn); parentcard = apar.closest('g-card'); if (parentcard){ parentcard.style.overflowY = 'visible'; parentcard.style.position = 'relative'; } } else { if (apar.nextSibling) apar.parentNode.insertBefore(btn,apar.nextSibling); else apar.parentNode.appendChild(btn); } // Reposition on Google's flex layout v2.3.4 3/15/2025 if (engine == 'Google' && window.getComputedStyle(btn.parentNode).display == "flex"){ btn.parentNode.style.position = 'relative'; btn.setAttribute('style', 'position:absolute;right:0;top:4.25em'); } // Move button to citeline 6/10/2013; updated 8/16/2020 to look for action-menu first if (bbpos == "C") { var axnmenu = liels[i].querySelector(".action-menu"); var citelines = liels[i].querySelectorAll("cite"); if (axnmenu){ // parentNode is a span axnmenu.parentNode.insertBefore(btn, axnmenu); if (citelines.length > 0) axnmenu.parentNode.className = citelines[0].className; } else { if (engine == 'Google' && window.getComputedStyle(btn.parentNode).display == "flex"){ btn.style.top = '1.75em'; } else { for (var citenum=0; citenum 0){ citelines[0].appendChild(btn); btn.removeAttribute("style"); } } } } // Implement Mouseover Option 6/22/2012 if (bbstyle == "M") { btn.style.visibility = "hidden"; liels[i].addEventListener("mouseover",togglebbtn,false); liels[i].addEventListener("mouseout",togglebbtn,false); } // Avoid unhiding garbage span 5/25/2012 for (j=0; j -1) ){ if (!liels[i].hasAttribute("imgblock") || ovrd == true){ // skip if previously processed liels[i].setAttribute("imgblock", "normal"); ael = liels[i].querySelector('a[href*="."]'); if (ael && ael.href.indexOf('/search?') == -1){ if (ael.getAttribute("href").indexOf("imgrefurl")>-1){ // Site showing the image ("visit page") dom = decodeURIComponent(ael.href).match(/imgrefurl=([^&]+)/)[1].split("/")[2]; } else if (ael.getAttribute("href").indexOf("imgurl")>-1){ // Site hosting the image ("view image") dom = decodeURIComponent(ael.href).match(/imgurl=([^&]+)/)[1].split("/")[2]; } else { //sometimes you get a clean URL dom = ael.getAttribute("href").split("/")[2]; } if (dom.length > 0){ if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number dompart = dom; while (dompart.indexOf(".")> -1) { if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck if (hosts.indexOf("|"+dompart+":p")<0) { // Regular block liels[i].setAttribute("imgblock", "regular"); } else { // Perma-ban liels[i].setAttribute("imgblock", "pban"); } break; } else { dompart = dompart.slice(dompart.indexOf(".")+1); if (dompart.indexOf(".") === -1 && dompart != "tld") dompart += '.tld'; } } } } } var imgshuffle = false; // CHANGE TO TRUE TO TURN ON SHUFFLING (CURRENTLY BROKEN) if (imgshuffle){ // Standard image results: move p-banned nodes to the end to maintain overall page length (otherwise, autoloading stops) if (t_gimg) window.clearTimeout(t_gimg); t_gimg = window.setTimeout(fixImagesLayout, 500); } } } } if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk" && document.getElementById("res")) addMngBtn(); if (document.getElementsByClassName("unbtn").length > 1) undupMngBtn(); if (betatest == "Y" && engine == 'Google'){ // BETA - NEW - v1.5.2 // If there are more than two completely invisible results, modify the query to exclude the first hidden site var invis = document.querySelectorAll("li[blockhidden]"); if (invis.length >= 3) reQry("+-site:"+invis[0].getAttribute("blockhidden")); } } function fixImagesLayout(){ // BUGGY: REPLACEMENT IMAGES DO NOT LOAD UNTIL YOU TRIGGER A REPAINT (e.g., open/close Find bar, resize window, zoom in then zoom out) var madeamove = false; var rgshes = document.querySelectorAll(".rgsh"); var lastdatapg = rgshes[rgshes.length-1].getAttribute("data-pg"); var badimg = document.querySelectorAll('div[imgblock="pban"]'); // TODO: Create setting to let user choose to remove regular blocks, too; temporary workaround: uncomment the following line: // var badimg = document.querySelectorAll('div[imgblock="pban"],div[imgblock="regular"]'); if (badimg.length > 0){ for (var bi=0; bi -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number dompart = dom; while (dompart.indexOf(".")> -1) { if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck; mark the cell for now if (hosts.indexOf("|"+dompart+":p")>-1 || showYN=="N") tds[i].setAttribute("ghhaction","delete"); else tds[i].setAttribute("ghhaction","notice"); break; } else { dompart = dompart.slice(dompart.indexOf(".")+1); if (dompart.indexOf(".") === -1 && dompart != "tld") dompart += '.tld'; } } }}} } for (i=0; i a, h3 a, .c-result-content a"); if (!ael && engine == 'DDG') ael = liel.querySelector('article h2 > a'); if (!ael && engine == 'Baidu' && liel.hasAttribute('mu')) ael = liel.querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row").firstChild; if (!ael) ael = liel.querySelector("span.tl a"); // summarized news result if (!ael) ael = liel.querySelector("a"); // other if (liel.classList.contains("videobox")) ael = liel.querySelectorAll("td")[1].querySelector("a"); //video page dabs = e.target.firstElementChild; if (engine != 'Bing'){ if (ael.parentNode.classList.contains('ghh1time')){ ael.parentNode.insertBefore(dabs,ael.nextSibling); } else { if (ael.parentNode.parentNode.nodeName === 'G-INNER-CARD' || ael.parentNode.parentNode.nodeName === 'G-CARD') ael.parentNode.parentNode.insertBefore(dabs,ael.parentNode); else { if (ael.parentNode.nextSibling) ael.parentNode.parentNode.insertBefore(dabs,ael.parentNode.nextSibling); else ael.parentNode.parentNode.appendChild(dabs); } } dabs.className = "ghhdbuttons"; dabs.removeAttribute("style"); if (dabs.nextElementSibling) if (dabs.nextElementSibling.className.indexOf("ghhider") == 0 || dabs.nextElementSibling.innerHTML == "block") dabs.parentNode.removeChild(dabs.nextElementSibling); } else { // TODO dabs is disappearing on Bing when moved -- temporarily, don't move it e.target.style.display=''; dabs.className = "ghhdbuttons"; dabs.removeAttribute("style"); } for (k=1; k 0) s = (hds.length == 1) ? "is 1 blocked hit" : "are "+hds.length+" blocked hits"; else s = "are no blocked hits"; if (confirm("Show titles and buttons for suppressed results? (There "+s+" on this page.)")){ ghhPrefO.shownotc[0] = "Y"; if (!GM4){ GM_setValue("ghhprefs", JSON.stringify(ghhPrefO)); } else { await GM.setValue("ghhprefs", JSON.stringify(ghhPrefO)); } showYN = ghhPrefO.shownotc[0]; togHiderDivs("yes"); } } fixShowHideBtn(); e.target.blur(); } function fixShowHideBtn(){ var chkMP = document.getElementById("chkshownotc"); var chkBF = document.getElementById("chkshownotcbf"); if (showYN == "Y"){ chkMP.setAttribute("checked","checked"); chkMP.checked = true; if (chkBF){ chkBF.setAttribute("checked","checked"); chkBF.checked = true; } } else { chkMP.removeAttribute("checked"); chkMP.checked = false; if (chkBF){ chkBF.removeAttribute("checked"); chkBF.checked = false; } } } function togHiderDivs(sShow){ var dh, i; dh = document.getElementsByClassName("ghhider"); for(i=0;i 0) ghhds[0].remove(); elPar.remove(); } hidehits(null,true); if (document.getElementById("ghhmngform")){ if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList(); } } // Add domain to the Perma-ban list async function permban(e){ if (!confirm("Never see hits for this domain again?")) return; var dpar, sdom, slist, liel; dpar = e.target.parentNode; sdom = dpar.getAttribute("dom"); if (!GM4){ slist = GM_getValue("hideyhosts"); } else { slist = await GM.getValue("hideyhosts"); } if (slist.substr(0,1) != "|") slist = "|" + slist; slist = slist.replace("|"+sdom+":t","|"+sdom+":p"); if (!GM4){ GM_setValue("hideyhosts", slist); } else { await GM.setValue("hideyhosts", slist); } blist = slist; needupdate = true; liel = dpar.closest('[ghhresult]'); if (!liel) alert('Developer error in permban (no liel)'); if ((liel.nodeName =="LI" || liel.nodeName == "DIV" || liel.nodeName == 'G-INNER-CARD' || liel.nodeName == 'G-CARD') && liel.classList.contains("ghh1time")){ liel.classList.remove('ghh1time'); } if(dpar.classList.contains("ghhindent")) dpar = dpar.parentNode; dpar.remove(); hidehits(null,true); if (document.getElementById("GTR")) removePBs(); if (document.getElementById("ghhmngform")){ if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList(); } } // Close this bad result and rehide (to allow indendent open/close, do not run through hidehits) function rehide(e){ var dpar, liel, dompart, ael, j; dpar = e.target.parentNode; liel = dpar.closest('[ghhresult]'); if (!liel) alert('Developer error in rehide (no liel)'); dompart = dpar.getAttribute("dom"); if (engine != 'Bing'){ dpar.remove(); liel.removeChild(liel.querySelector("div.ghhd")); } else { // TODO notice is disappearing on Bing -- temporarily, do not move/remove the buttons div liel.querySelector('div.ghhd > div.ghhdbuttons').style.display = 'none'; } ael = liel.querySelector("h3 a, h2 a, a h2, a h3"); if (!ael) ael = liel.querySelector("a"); liel.classList.remove('ghh1time'); replaceHit(dompart,ael,liel,""); for (j=0; j
' + '

' + '


' + ' ' + '

'; if (engine == 'Google'){ bfdcode += "

Edit query: " + "

"; } bfdcode += "


" + "

"; bfd.innerHTML = bfdcode; document.body.appendChild(bfd); document.getElementById("ghhbf1").addEventListener("click",addblock,false); document.getElementById("ghhbf2").addEventListener("click",ghhcloseform,false); document.getElementById("ghhbf3").addEventListener("click",addblock,false); document.getElementById("ghhbf4").addEventListener("click",ghhcloseform,false); if (engine == 'Google'){ document.getElementById("ghhbf5").addEventListener("click",reQuery,false); document.getElementById("ghhbf6").addEventListener("click",reQuery,false); } document.getElementById("ghhblockform").addEventListener("click",ghhkillevent,false); document.getElementById("chkshownotcbf").addEventListener("change",updtpref,false); document.getElementById("chk1clickbf").addEventListener("change",updt1click,false); document.getElementById("ghhdomadj").addEventListener("click",adjpartdom,false); } function showbfd(e) { var bbtn, bfdiv, fdom, pdom, fspan, pspan, tdiv, lt; e.preventDefault(); bbtn = e.target; fdom = bbtn.getAttribute("meta"); if (!document.getElementById("ghhblockform")) addBlockForm(); fspan = document.getElementById("ghhfulldom"); fspan.textContent = fdom; fspan.previousElementSibling.checked = true; pdom = fdom.substr(fdom.indexOf(".")+1); pspan = document.getElementById("ghhpartdom"); if (pdom.indexOf(".") > -1 && patIPv4.test(fdom) != true) { pspan.textContent = pdom; pspan.parentNode.style.display = ""; switch (bAggress){ case 'all': pspan.previousElementSibling.checked = true; break; case 'www': if (fdom.substr(0,3) == 'www') pspan.previousElementSibling.checked = true; break; default: // default to full domain } document.getElementById("ghhdomadj").style.display = ''; } else { pspan.parentNode.style.display = "none"; document.getElementById("ghhdomadj").style.display = 'none'; } if (e.altKey == true && engine == 'Google'){ reQuery(); return; } bfdiv = document.getElementById("ghhblockform"); tdiv = document.getElementById("ghhtemp"); if (!tdiv){ tdiv = document.createElement("div"); tdiv.id = "ghhtemp"; } if (isch == true){ tdiv.setAttribute("style", "position:absolute;right:0;top:4em;z-index:3000;width:250px;"); bbtn.parentNode.appendChild(tdiv); } else if (e.target.parentNode.parentNode.nodeName == 'G-INNER-CARD' || e.target.parentNode.parentNode.nodeName == 'G-CARD') { tdiv.setAttribute("style", "position:absolute;left:8px;top:8px;z-index:9999;width:100%;"); e.target.parentNode.parentNode.insertBefore(tdiv, e.target.parentNode.parentNode.children[0]); } else if (e.target.parentNode.nodeName == 'G-INNER-CARD' || e.target.parentNode.nodeName == 'G-CARD') { tdiv.setAttribute("style", "position:absolute;left:8px;top:8px;z-index:9999;width:100%;"); e.target.parentNode.insertBefore(tdiv, e.target.parentNode.children[0]); } else if (e.target.parentNode.className == 'dbsr') { tdiv.setAttribute("style", "position:absolute;left:8px;top:8px;z-index:9999;width:100%;"); e.target.parentNode.insertBefore(tdiv, e.target.parentNode.children[0]); } else if(engine == 'Google' && bbpos == 'C') { tdiv.setAttribute("style", "position:absolute;left:8px;top:16px;z-index:9999;width:100%;"); e.target.parentNode.style.position = 'relative'; e.target.parentNode.insertBefore(tdiv, e.target.parentNode.children[0]); } else { lt = bbtn.offsetLeft + bbtn.offsetWidth + 12; if (bbtn.parentNode.previousElementSibling){ if (window.getComputedStyle(bbtn.parentNode.previousElementSibling,null).getPropertyValue("float") != "none" || (bbtn.style.position == "absolute" && bbtn.parentNode.nodeName == "TD")) lt=lt-bbtn.parentNode.offsetLeft; } if (document.querySelector('table#GTR')){ lt-=230; } if (engine != 'Google') lt=lt-bbtn.parentNode.offsetLeft; if (engine == 'Startpage') lt = 16; if (engine == 'Google' && bbtn.closest('div.g') != null){ tdiv.setAttribute("style", "position:relative;left:" + lt + "px;top:-18px;z-index:500;width:250px;"); bbtn.closest('div.g').insertBefore(tdiv, bbtn.closest('div.g').children[0]); } else { tdiv.setAttribute("style", "position:relative;left:" + lt + "px;top:-65px;z-index:500;width:250px;"); if (bbtn.nextElementSibling){ if (bbtn.nextElementSibling.nodeName == "DIV" || bbtn.nextElementSibling.nodeName == "BR") bbtn.parentNode.insertBefore(tdiv,bbtn.nextElementSibling); else bbtn.parentNode.appendChild(tdiv); } else bbtn.parentNode.appendChild(tdiv); } } tdiv.appendChild(bfdiv); if (window.getComputedStyle(tdiv.parentNode).overflowX == "hidden" || window.getComputedStyle(tdiv.parentNode).overflowY == "hidden"){ tdiv.parentNode.style.overflowX = "visible"; tdiv.parentNode.style.overflowY = "visible"; } if (pref1click.substr(0,1) == "Y" && e.shiftKey != true && isch != true){ // 1-click; hold Shift to override if (pref1click.substr(2,1) == "N"){ document.getElementById("ghhbf1").click(); } else { document.getElementById("ghhbf3").click(); } } else { // regular + populating 1-click checkbox var chkBF = document.getElementById("chk1clickbf"); if (pref1click.substr(0,1) == "Y"){ chkBF.setAttribute("checked","checked"); chkBF.checked = true; } else { chkBF.removeAttribute("checked"); chkBF.checked = false; } chkBF = document.getElementById("chkshownotcbf"); if (showYN == "Y"){ chkBF.setAttribute("checked","checked"); chkBF.checked = true; } else { chkBF.removeAttribute("checked"); chkBF.checked = false; } bfdiv.style.display = "block"; document.getElementById("ghhbf1").focus(); } e.stopPropagation(); } function adjpartdom(e){ // v1.8.1 var pspan = document.getElementById("ghhpartdom"); var parts = pspan.textContent.replace('...', '').split("."); if (parts.length <= 2){ if (parts.length == 2 && parts[1].indexOf('tld [all') !== 0){ // offer the entire TLD option v1.9.9 parts.push('tld [all dot-' + parts[1] + '\'s]'); } else { // cycle back to the original partial domain parts = document.getElementById("ghhfulldom").textContent.split("."); } } parts.shift(); // discard leftmost subdomain pspan.textContent = parts.join("."); } async function addblock(e){ var btype, els, i, sdom, tgt; tgt = e.target; btype = tgt.getAttribute("bt"); els = tgt.form.querySelectorAll('input[type="radio"]'); for (i=0; i a[href]'); if (!ael) ael = viewer.querySelector('a[href]'); // Aug. 2019 design if (!ael){ alert('Cannot find the URL in this design.'); return; } var ameta = ael.href.split("/")[2]; if (ael.href.indexOf("&url=")>-1) ameta = decodeURIComponent(ael.href).match(/&url=([^&]+)/)[1].split("/")[2]; if (ameta.indexOf(":")> -1) ameta = ameta.substr(0,ameta.indexOf(":")); // Strip port number e.target.setAttribute("meta", ameta); var dompart = ameta; while (dompart.indexOf(".")> -1) { if (blist.indexOf("|"+dompart+":") > -1){ if (confirm("Unblock " + dompart + "?")){ if (!GM4){ var slist = GM_getValue("hideyhosts"); } else { slist = await GM.getValue("hideyhosts"); } if (slist.substr(0,1) != "|") slist = "|" + slist; slist = slist.replace("|"+dompart+":t","").replace("|"+dompart+":p",""); if (!GM4){ GM_setValue("hideyhosts", slist); } else { await GM.setValue("hideyhosts", slist); } blist = slist; needupdate = true; hidehits(null,true); if (document.getElementById("ghhmngform")){ if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList(); } } e.stopPropagation(); return; } else { dompart = dompart.slice(dompart.indexOf(".")+1); } } showbfd(e); } // Functions relating to the Manage Hiding button function addMngBtn(){ if (mbstyle.split("-")[0] == "blk") return; if (window.self != window.top) if (mbstyle.split("-")[1] == "ifrN") return; var mbtn; mbtn = document.createElement("button"); mbtn.appendChild(document.createTextNode(txts.mngbtn[0])); mbtn.className="ghhider unbtn"; mbtn.setAttribute("title","Manage Google Hit Hider Settings / Ctrl+click to re-hide"); mbtn.id = "ghhMngBtn"; mbtn.addEventListener("click",handleManageButton,true); document.body.appendChild(mbtn); } function undupMngBtn(){ var unbtns = document.getElementsByClassName("unbtn"); while (unbtns.length > 1){ unbtns[unbtns.length - 1].parentNode.removeChild(unbtns[unbtns.length - 1]); } } function handleManageButton(e){ if (e.ctrlKey){ var btnM = e.target; btnM.style.backgroundColor = 'aqua'; hidehits(null, false); window.setTimeout(function(){btnM.style.backgroundColor = ''}, 250); } else { showManageForm(e); } } async function showManageForm(e){ if (window.self != window.top) return; var mfd; if (!document.getElementById("ghhmngform")) addManageForm(); mfd = document.getElementById("ghhmngform"); if (mfd.style.display != "none" && e != "mngform"){ // Toggle to hidden if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H"); if (mpopen.substr(0,3) == "Y-Y"){ mpopen = "Y-N"; ghhPrefO.mngpaneopen[0] = mpopen; if (!GM4){ GM_setValue("ghhprefs", JSON.stringify(ghhPrefO)); } else { await GM.setValue("ghhprefs", JSON.stringify(ghhPrefO)); } } mfd.style.display = "none"; } else { if (needupdate == true) refreshSiteList(); mfd.style.display = "block"; if (mpopen.substr(0,3) == "Y-Y" && mpopen.length == 5){ // Restore last displayed tab var tabnum = mpopen.substr(4,1); if (document.getElementById('ghhmt'+tabnum).style.display == "none"){ togglelist('ghhts'+tabnum); if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("S"); if (typeof e == "object") e.target.blur(); return; } } if (document.getElementById("ghhmt1").style.display != "none" || document.getElementById("ghhmt4").style.display != "none"){ document.getElementById("ghhmf1").setAttribute("disabled","disabled"); document.getElementById("ghhutil").style.display = "none"; } else { if (document.getElementById("ghhmf1").hasAttribute("disabled")) document.getElementById("ghhmf1").removeAttribute("disabled"); if (bLUopen != "N") document.getElementById("ghhutil").style.display = "block"; } setCurrentTab(); if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("S"); } if (typeof e == "object") e.target.blur(); } function setCurrentTab(){ var k, tabnum; var tabset = document.querySelectorAll("#mflists>div"); for (k=0; k
" + "

" + "" + "" + "" + "

" + "
" + "

Welcome to Google Hit Hider! JS

" + "
" + "

Click the block button ( ) " + "next to a hit title to block results from that site. A regular blocked hit becomes a one-line notation, " + "while a Perma-ban disappears completely.

" + "


" + "

" + "

v2.3.5 © 2025 Jefferson Scher. Learn more on " + "this script's page.

" + "

Click to remove from regular block list:

" + "
    \n" + "

    Click to remove from Perma-ban list:

    " + "
      " + "

      Manage script options:

      " + "
      " + "

      Add newly blocked domains:
      " + "
      " + "
      " + "

      " + "

      Block form defaults to:
      " + "
      " + "
      " + "

      " + "

      User interface style:
      " + "
      " + "
      " + "
      " + "
      " + "Manage Hiding button position:
      " + " " + " " + "
      " + "Block button position (reloads):
      " + " " + "
      " + "Display block buttons:
      " + " " + "
      " + "Block button tooltips:
      " + " " + "

      " + "

      Misc Preferences:
      " + "
      " + "
      " + "
      " + "
      " + "

      " + "

      Edit captions:

      " + "

      " + " " + "

      " + "

      Reload to complete changes

      " + "

      Custom style rules:
      " + "

      " + "

      " + " " + " " + "

      " + "

      "; document.body.appendChild(mfd); fixShowHideBtn(); fixuistyle(); fixaddpos(); fixaggblock(); fixajaxstyle(); fixpanepersist(); fix1clickstyle(); fixBeta(); document.getElementById("ghhts1").addEventListener("click",togglelist,true); // tabs document.getElementById("ghhts2").addEventListener("click",togglelist,true); document.getElementById("ghhts3").addEventListener("click",togglelist,true); document.getElementById("ghhts4").addEventListener("click",togglelist,true); document.getElementById("chkshownotc").addEventListener("change",updtpref,true); // home document.getElementById("chk1click").addEventListener("change",updt1click,true); document.getElementById("ghhsitelist").addEventListener("click",togglesite,true); // block document.getElementById("ghhpbanlist").addEventListener("click",togglesite,true); // pban document.getElementById("addradios").addEventListener("change",updtaddpos,true); // options document.getElementById("aggressrads").addEventListener("change",updtaggress,true); document.getElementById("chkajax").addEventListener("change",updtAJAX,true); document.getElementById("chkdom4").addEventListener("change",updtAJAX,true); document.getElementById("chkmpopen").addEventListener("change",updtpersist,true); document.getElementById("chk1pban").addEventListener("change",updt1click,true); document.getElementById("chkbeta").addEventListener("change",updtBeta,true); document.getElementById("btnradios").addEventListener("change",updtuistyle,true); document.getElementById("ghhedit1").addEventListener("click",chgcaption,true); document.getElementById("ghhedit2").addEventListener("click",chgcaption,true); document.getElementById("ghhedit3").addEventListener("click",chgcaption,true); document.getElementById("ghhmfr").addEventListener("click",resetTextStrings,true); document.getElementById("ghhecsr").addEventListener("click",openCustomStyleBar,true); document.getElementById("ghhmf1").addEventListener("click",saveedits,true); // buttons document.getElementById("ghhmf2").addEventListener("click",ghhcloseform,true); document.getElementById("ghhmf3").addEventListener("click",toggleListUtil,true); document.getElementById("ghhmf4").addEventListener("click",exportlist,true); document.getElementById("ghhmf5").addEventListener("click",sortlist,true); document.getElementById("ghhmf6").addEventListener("click",dedup,true); document.getElementById("ghhmf7").addEventListener("click",importlist,true); document.getElementById("ghhmf8").addEventListener("click",addAllNow,true); document.getElementById("ghhmf9").addEventListener("click",unwww,true); // Add JS icon link addBtnLink(); } async function addBtnLink(){ var JSBTN = document.createElement("img"); JSBTN.setAttribute('alt', 'JS'); if (typeof GM.getResourceUrl === "undefined"){ JSBTN.src = GM_getResourceURL("mycon"); } else { /* asynchronous*/ JSBTN.src = await GM.getResourceUrl("mycon"); } document.querySelector("#ghhmt1 a").textContent = ""; document.querySelector("#ghhmt1 a").appendChild(JSBTN); } function togglelist(e){ // Change tabs if (typeof e === 'string'){ var tgtid = e; } else { e.target.blur(); if (e.target.className == "ghhCurTab") return; tgtid = e.target.id; } var tabbtns = document.querySelectorAll("#ghhtstrip>button"); var k, tabnum; for (k=0; k'; } else { pblist += '
    • ' + sarray[i].split(':')[0] + '
    • '; } } ulB = document.getElementById("ghhsitelist"); while (ulB.firstChild) ulB.removeChild(ulB.firstChild); ulB.insertAdjacentHTML('beforeend', slist); ulP = document.getElementById("ghhpbanlist"); while (ulP.firstChild) ulP.removeChild(ulP.firstChild); ulP.insertAdjacentHTML('beforeend', pblist); needupdate = false; } async function updtaddpos(e){ // Implement change for radio buttons re where to add to list var rads = e.target.parentNode.querySelectorAll("input[type='radio']"); for (var i=0; i 0) { if (confirm("You have unsaved changes to your lists. Save changes and sort, or cancel sorting?")){ saveedits(null); } else { fixaddpos(); return; } } sortlist(null); } else { fixaddpos(); return; } } addAt = rads[i].value; ghhPrefO.addtolistpos[0] = addAt; if (!GM4){ GM_setValue("ghhprefs", JSON.stringify(ghhPrefO)); } else { await GM.setValue("ghhprefs", JSON.stringify(ghhPrefO)); } break; } } fixaddpos(); } function fixaddpos(){ // Check appropriate radio button re where to add to list var rads = document.getElementById("addradios").querySelectorAll("input[type='radio']"); for (var i=0; i 0 && input != txts[key][0]){ txts[key][0] = input.replace(/\"/g,"''"); btn.appendChild(document.createTextNode(txts[key][0])); btn.removeChild(btn.firstChild); if (!GM4){ GM_setValue("textstrings", JSON.stringify(txts)); } else { await GM.setValue("textstrings", JSON.stringify(txts)); } } } async function resetTextStrings(e){ // Reset buttons captions to defaults if (confirm("Restore default button captions?")){ txts = defaultTxts; if (!GM4){ GM_setValue("textstrings", JSON.stringify(txts)); } else { await GM.setValue("textstrings", JSON.stringify(txts)); } alert("Please reload to see the changes."); e.target.blur(); } } async function exportlist(e){ // Display and populate export form, clean up from any prior use if (!document.getElementById("ghhexport")) insertExportForm(); var expDiv = document.getElementById("ghhexport"); document.getElementById("ghheximhead").innerHTML = "Export Block List"; document.getElementById("ghheximinfo1").innerHTML = "These boxes display your current block list. " + "

      " + "On the left, you have the list in its native format. By saving this format, you can preserve your regular/Perma-ban " + "block decisions.

      On the right, you have a simple list of domains. " + "This would be a good format for sharing your list with others."; if (!GM4){ var currlist = GM_getValue("hideyhosts"); } else { currlist = await GM.getValue("hideyhosts"); } document.getElementById("ghhtaleft").value = currlist; var domList = currlist.substr(1).replace(/:[tp]\|/g, "\n"); document.getElementById("ghhtaright").value = domList.replace(/\n*$/, ""); if (!GM4){ var preimpolist = GM_getValue("hideyback", ""); } else { preimpolist = await GM.getValue("hideyback", ""); } if (preimpolist.length > 0){ document.getElementById("expgotopreimp").addEventListener("click",exportoldlist,true); document.getElementById("expgotopreimp").style.display = ""; } document.getElementById("ghhleftcontrols").style.display = "none"; document.getElementById("ghhrightcontrols").style.display = "none"; document.getElementById("ghhtbldiv").style.display = "none"; if (document.getElementById("ghhtaright").style.display == "none") document.getElementById("ghhtaright").style.display = ""; expDiv.style.display = "block"; e.target.blur(); } function insertExportForm(){ var dNew, btn, par, ta; dNew = document.createElement("div"); dNew.id = "ghhexport"; dNew.className = "ghhpane"; dNew.setAttribute("style","position:fixed;top:10px;left:5%;width:90%;z-index:10000;background:#ddd;padding:1em;font-size:1.25em;display:none;max-height:90vh;overflow-y:auto;"); dNew.innerHTML = '' + '

      ' + '

      ' + '
      ' + '
      ' + '
      ' + ' ' + '
      '; document.body.appendChild(dNew); document.getElementById('exportclose').addEventListener('click', function(){document.getElementById('ghhexport').style.display = 'none';}, true); } function importlist(e){ // Display import form, clean up from any prior use if (!document.getElementById("ghhexport")) insertExportForm(); var expDiv = document.getElementById("ghhexport"); document.getElementById("ghheximhead").innerHTML = 'Import Block List'; document.getElementById("ghheximinfo1").innerHTML = "As a precaution in case something goes wrong, please use the " + "feature to copy and save your current list as a backup.

      " + "To begin, paste your list into the left box below. Then click the Parse List for Import button. This script can import a list in its own native format, or a plain list of domains with a separate domain on each line, or " + "separated by spaces. (It also converts the Noise Reduction for Google and Google Domain Blocker formats.)"; document.getElementById("ghhtaleft").value = ""; document.getElementById("ghhleftcontrols").style.display = ""; document.getElementById("ghhrightcontrols").style.display = "none"; document.getElementById("ghhexp1").addEventListener("click",parseList,true); document.getElementById("impgotoexp").addEventListener("click",exportlist,true); document.getElementById("ghhtaright").style.display = "none"; document.getElementById("ghhtbldiv").style.display = "none"; document.getElementById("chkimporepl").checked = false; expDiv.style.display = "block"; e.target.blur(); } function parseList(e){ // Parse putative domain list and redisplay cleaned up var txt, sites = [], bHasTypes = 0, i, tbod, thd, rasis, lbpos, rbpos; txt = document.getElementById("ghhtaleft").value; if (txt.length < 4){ alert("Block list too short!"); return; } document.getElementById("ghhtbldiv").innerHTML = ""; // clean up/convert domain list to pipe-delimited txt = txt.replace(/(http|https):/g, ""); txt = txt.replace(/(,|\/|;)/g, "|"); txt = txt.replace(/\s+/g, "|"); txt = txt.replace(/\|+/g, "|"); txt = txt.replace(/[\<\>"'=#\!\u2018\u2019\(\)\{\}]/g, ""); // strip regex txt = txt.replace(/(\+|\*|\$|\\)/g, ""); while (txt.indexOf("[") > -1 && txt.indexOf("]") > -1){ lbpos = txt.indexOf("["); rbpos = txt.indexOf("]"); if (lbpos > 0 && rbpos + 1 < txt.length) txt = txt.substring(0,lbpos) + txt.substring(rbpos+1); else { if (lbpos == 0 && rbpos + 1 < txt.length) txt = txt.substring(rbpos+1); else break; // for some reason, entire list is bracketed?? } } if (txt.indexOf(":") > -1) bHasTypes = 1; sites = txt.split("|"); for (i=0; i 1){ if (sites[i].indexOf(".") == 0) sites[i] = sites[i].substr(1); if (sites[i].indexOf("?") > -1) sites[i] = sites[i].substr(0,sites[i].indexOf("?")); if (bHasTypes == 1){ if (sites[i].indexOf(":t") == sites[i].length - 2 || sites[i].indexOf(":p") == sites[i].length - 2){ sites[i] = "" + sites[i].replace(":t","regular").replace(":p","Perma-ban") + ""; } else { if (sites[i].indexOf(":") > -1) sites[i] = sites[i].substr(0, sites[i].indexOf(":")); sites[i] = "" + sites[i] + "(unspecified)"; } } else { // Plain list sites[i] = "" + sites[i] + ""; } } } tbod = "\n" + sites.join("\n") + ""; if (sites.length == 0){ alert("Unable to parse the list, sorry."); return; } if (bHasTypes == 1) thd = "DomainBlock Type"; else thd = "Domain"; document.getElementById("ghhtbldiv").innerHTML = "" + thd + tbod + "
      "; document.getElementById("ghhtbldiv").style.display = ""; rasis = document.getElementById("ghhrightcontrols").querySelectorAll("input[value='asis']")[0]; if (bHasTypes == 1){ if (rasis.hasAttribute("disabled")) rasis.removeAttribute("disabled"); rasis.checked = true; rasis.parentNode.style.color = ""; } else { rasis.setAttribute("disabled","disabled"); rasis.parentNode.style.color = "rgb(172, 168, 153)"; document.getElementById("ghhrightcontrols").querySelectorAll("input[value='t']")[0].checked = true; } document.getElementById("ghhrightcontrols").style.display = "block"; document.getElementById("ghhexp2").addEventListener("click",doImport,true); e.target.blur(); } async function doImport(e){ // Add sites from cleaned up domain list to script block lists var tbl, rads, i, typeRule, rows, dom, newDoms = ""; tbl = document.getElementById("ghhparsed"); if (!tbl){ alert("Unable to locate table of parsed domains!"); return; } if (tbl.parentNode.style.display == "none"){ alert("Please start the import process again!"); return; } rads = document.getElementById("ghhrightcontrols").querySelectorAll("input[type='radio']"); for (i=0; i 0){ switch (typeRule){ case "asis": if (rows[i].children[1].textContent == "Perma-ban") newDoms += dom + ":p|"; else newDoms += dom + ":t|"; break; default: newDoms += dom + ":" + typeRule + "|"; } rows[i].style.backgroundColor = "#ff0"; } else { rows[i].style.backgroundColor = "#f00"; } } if (newDoms != ""){ // Back up current block list if (!GM4){ GM_setValue("hideyback", blist); } else { await GM.setValue("hideyback", blist); } if (document.getElementById("chkimporepl").checked == true){ if (confirm("Delete current block list and replace it with domains you are importing? (To add to the current block list, click Cancel.)")) { blist = ""; } } if (blist == "") blist = "|" + newDoms; else blist += newDoms; // Persist updated block list if (!GM4){ GM_setValue("hideyhosts", blist); } else { await GM.setValue("hideyhosts", blist); } if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList(); hidehits(null,true); } alert("Import of yellow-highlighted domains completed. Please check the Management Pane to " + "view, sort, and/or de-duplicate your imported domains."); } async function exportoldlist(e){ // Display and populate export form with pre-import list if (!document.getElementById("ghhexport")) insertExportForm(); var expDiv = document.getElementById("ghhexport"); document.getElementById("ghheximhead").innerHTML = "Export Old (Pre-Import) Block List"; document.getElementById("ghheximinfo1").innerHTML = "These boxes display your old block list from before the last import. " + "

      " + "On the left, you have the list in its native format. By saving this format, you can preserve your regular/Perma-ban " + "block decisions.

      On the right, you have a simple list of domains. " + "This would be a good format for sharing your list with others."; if (!GM4){ var preimpolist = GM_getValue("hideyback", ""); } else { preimpolist = await GM.getValue("hideyback", ""); } document.getElementById("ghhtaleft").value = preimpolist; var domList = preimpolist.substr(1).replace(/:[tp]\|/g, "\n"); document.getElementById("ghhtaright").value = domList.replace(/\n*$/, ""); document.getElementById("expgotoblist").addEventListener("click",exportlist,true); document.getElementById("ghhleftcontrols").style.display = "none"; document.getElementById("ghhrightcontrols").style.display = "none"; document.getElementById("ghhtbldiv").style.display = "none"; if (document.getElementById("ghhtaright").style.display == "none") document.getElementById("ghhtaright").style.display = ""; expDiv.style.display = "block"; e.target.blur(); } async function sortlist(e){ // Alpha-sort block list if (listchgs > 0) { if (confirm("You have unsaved changes to your lists. Save changes and sort, or cancel sorting?")){ saveedits(null); } else { return; } } if (blist.substr(0,1) != "|") blist = "|" + blist; var sarray = blist.substr(1,blist.length-2).split("|"); sarray.sort(); // Persist sorted list if (!GM4){ GM_setValue("hideyhosts", "|" + sarray.join("|") + "|"); blist = GM_getValue("hideyhosts"); } else { await GM.setValue("hideyhosts", "|" + sarray.join("|") + "|"); blist = await GM.getValue("hideyhosts"); } refreshSiteList(); if (e) e.target.blur(); } async function dedup(e){ // De-duplicate block lists if (!confirm("If you block example.com, you don't also need to block www.example.com. Remove unnecessary domains from the block list?")) return; var barray, i, j, iadd, smain, stest, sremd = "", sques = ""; if (blist.substr(0,1) != "|") blist = "|" + blist; barray = blist.substr(1,blist.length-2).split("|"); for (i=0; i -1){ barray[i] = barray[i].substr(0,barray[i].indexOf(":")).split(".").reverse().join(".") + "!t"; } else { if (barray[i].indexOf(":p") > -1){ barray[i] = barray[i].substr(0,barray[i].indexOf(":")).split(".").reverse().join(".") + "!p"; } else { barray[i] = barray[i].split(".").reverse().join(".") + "!t"; } } } barray.sort(); for (i=0; i 0) ghhPrefO.shownotc[0] = tmp; GM_deleteValue("shownotc"); } tmp = GM_getValue("mngpaneopen"); if (tmp){ if (tmp.length > 0) ghhPrefO.mngpaneopen[0] = tmp; GM_deleteValue("mngpaneopen"); } tmp = GM_getValue("mngbtnstyle"); if (tmp){if (tmp.length > 0){ if (tmp.indexOf("-")>-1) tmp = "both"; // default ancient pref ghhPrefO.mngbtnstyle[0] = tmp; GM_deleteValue("mngbtnstyle"); }} tmp = GM_getValue("addtolistpos"); if (tmp){ if (tmp.length > 0) ghhPrefO.addtolistpos[0] = tmp; GM_deleteValue("addtolistpos"); } tmp = GM_getValue("aggressiveblock"); if (tmp){ if (tmp.length > 0) ghhPrefO.aggressiveblock[0] = tmp; GM_deleteValue("aggressiveblock"); } tmp = GM_getValue("usemutation"); if (tmp){ if (tmp.length > 0) ghhPrefO.usemutation[0] = tmp; GM_deleteValue("usemutation"); } } else { if (ghhPrefs.indexOf("reserved1")>-1){ var oldPrefs = JSON.parse(ghhPrefs); ghhPrefO.shownotc[0] = oldPrefs.shownotc[0]; ghhPrefO.mngpaneopen[0] = oldPrefs.mngpaneopen[0]; ghhPrefO.mngbtnstyle[0] = oldPrefs.mngbtnstyle[0]; ghhPrefO.addtolistpos[0] = oldPrefs.addtolistpos[0]; ghhPrefO.aggressiveblock[0] = oldPrefs.aggressiveblock[0]; ghhPrefO.usemutation[0] = oldPrefs.usemutation[0]; ghhPrefO.oneclick[0] = oldPrefs.oneclick[0]; } } GM_setValue("ghhprefs", JSON.stringify(ghhPrefO)); // requires Fx 3.5+ } function togglebbtn(e){ var bbtn = e.currentTarget.querySelector('.ghhb'); if (bbtn){ if (e.type == "mouseover") bbtn.style.visibility = ""; else bbtn.style.visibility = "hidden"; } } function reQuery(e){ var ss, rads, i; if (e){ if (e.target.id == "ghhbf5") ss = "+site:"; else ss = "+-site:"; rads = e.target.form.querySelectorAll('input[type="radio"]'); } else { ss = "+-site:"; // ALT omit rads = document.querySelector('#ghhblockform form').querySelectorAll('input[type="radio"]'); } if (rads.length > 0){ for (i=0; i-1 || q.indexOf(d+"&")>-1)) return; // try to block dups, may be overinclusive var qa = q.split("&"); var has_q = false; for (var j=qa.length-1; j>=0; j--){ if (qa[j].split("=")[0] == "q"){ qa[j] += d; has_q = true; break; } else { if (qa[j].indexOf("#q=") > -1){ qa[j] += d; has_q = true; break; } } } if (has_q) window.location.href = window.location.href.substr(0, window.location.href.indexOf("?")+1) + qa.join("&"); else console.log("LOG:Unable to add new search term to URL"); } function toggleciteline(posit) { var ghhbd_sty = document.getElementById("bbposciteline"); if (posit == "C"){ if (!ghhbd_sty){ ghhbd_sty = document.createElement("style"); ghhbd_sty.id = "bbposciteline"; ghhbd_sty.setAttribute("type", "text/css"); document.body.appendChild(ghhbd_sty); } // "inline" the action menu ghhbd_sty.appendChild(document.createTextNode(".action-menu {vertical-align:baseline !important;} .action-menu .clickable-dropdown-arrow, .action-menu .ab_button, .action-menu > a {display:none !important;} .action-menu-panel, .action-menu-panel ul, .action-menu-panel ol, .action-menu-item {display:inline !important; visibility: visible !important; border:none !important; box-shadow:none !important; background-color:transparent !important; margin:0 !important; padding:0 !important; top:0 !important; height:auto !important; line-height:auto !important;} .action-menu-item a.fl, .action-menu-button {padding:0 0 0 6px !important; display:inline !important;} .action-menu-panel {position:static;} .action-menu-item a.fl:hover {text-decoration:underline !important;} .action-menu + .crc {margin-right: 9px !important;} .action-menu + .crc ._Bs {margin-left: 1px !important;}")); // restyle the block button ghhbd_sty.appendChild(document.createTextNode(".ghhb {border:none!important; text-decoration:none!important; font-size:1em!important; color:#333!important; padding:0!important; margin-left:8px!important;} .ghhb:hover {background:transparent!important; text-decoration:underline !important;}")); } else { // remove citeline rules if (ghhbd_sty){ while(ghhbd_sty.firstChild) ghhbd_sty.removeChild(ghhbd_sty.firstChild); } } } function openCustomStyleBar(e){ // Create fixed div with text input and buttons: Save, Test, Close var csb = document.getElementById("ghhcsb"); if (csb){ csb.style.display = "block"; } else { csb = document.createElement("div"); csb.id = "ghhcsb"; csb.setAttribute("style","position:fixed;bottom:0;left:0;z-index:750;width:100%;background-color:#afa;"); csb.innerHTML = "

      " + " " + " " + "

      "; document.body.appendChild(csb); document.getElementById("ghhcsb1").addEventListener("click",saveCustomStyle,true); document.getElementById("ghhcsb2").addEventListener("click",testCustomStyle,true); document.getElementById("ghhcsb3").addEventListener("click",closeCustomStyleBar,true); } document.getElementById("ghhcsbrule").value = custSty; } async function saveCustomStyle(e){ // Update preferences and apply change to style#ghhbdcuststy custSty = document.getElementById("ghhcsbrule").value; if (!GM4){ GM_setValue("hiderStyles", custSty); } else { await GM.setValue("hiderStyles", custSty); } injectCustom(); document.getElementById("ghhbdcuststy").innerHTML = ""; document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(custSty)); } function testCustomStyle(e){ // Add/Edit style#ghhbdcuststy injectCustom(); document.getElementById("ghhbdcuststy").innerHTML = ""; document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(document.getElementById("ghhcsbrule").value)); } function closeCustomStyleBar(e){ // Turn off display and reapply saved style to style#ghhbdcuststy document.getElementById("ghhcsb").style.display = "none"; injectCustom(); document.getElementById("ghhbdcuststy").innerHTML = ""; document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(custSty)); } function removePBs(e){ // GoogleMonkeyR layout only // Schedule Permaban removal (prevent simultaneous/conflicting runs) var PBsBlanks = document.querySelectorAll("table#GTR li[blockhidden], table#GTR div.g[blockhidden], table#GTR td:empty"); if (PBsBlanks.length < 1) return; if (t_pb) window.clearTimeout(t_pb); t_pb = window.setTimeout(GMRshuffle, 100); } function GMRshuffle(){ // GoogleMonkeyR layout only // Delete Permaban hits var PBs = document.querySelectorAll("table#GTR li[blockhidden], table#GTR div.g[blockhidden]"); if (PBs.length > 0){ for (var i=PBs.length; i>0; i--) PBs[i-1].remove(); } // Check entire table for empty cells and shuffle contents var tbl, row, cell, empties; tbl = document.getElementById("GTR"); for (row=0; row 0 && empties < tbl.rows[row].cells.length){ for (cell=0; cell 0) tgt.appendChild(src.childNodes[0]); } function getNextCell(aCell, blnNonEmpty){ var startcell = aCell; var retcell; var i=0; while (i<1000) { if (startcell.nextElementSibling){ // not the last cell in the row retcell = startcell.nextElementSibling; } else { if (startcell.parentNode.nextElementSibling){ // last cell in row and there's another row retcell = startcell.parentNode.nextElementSibling.cells[0]; } else { return null; // end of table } } if (!retcell){ return null; // corrupted table structure } if (blnNonEmpty){ if (retcell.querySelector("li")){ return retcell; } else { startcell = retcell; } } else { return retcell; } i++; } } // "Add All" feature 2.0.9 async function addAllNow(e){ var unb = document.querySelectorAll('[ghhresult="unset"][ghhhost]'), dom = '', pdom = '', domlist = ''; for (var i=0; i -1 && patIPv4.test(dom) != true){ switch (bAggress){ case 'all': dom = pdom; break; case 'www': if (dom.substr(0,3) == 'www') dom = pdom; break; default: // default to full domain } } // Add dom to doms arrray (avoiding duplicates) if (doms.includes(dom) !== true) doms.push(dom); } // Add new domains to the currently displayed block list if (document.querySelector('button.ghhCurTab').id == 'ghhts3'){ // pban domlist = doms.join(':p|') + ':p'; } else { // regular domlist = doms.join(':t|') + ':t'; } if (blist.substr(0,1) != '|') blist = '|' + blist; if (addAt == 'end') blist += domlist + '|'; else blist = '|' + domlist + blist; needupdate = true; // Store the list if (!GM4){ GM_setValue('hideyhosts', blist); } else { await GM.setValue('hideyhosts', blist); } // Apply the change to the results hidehits(null,true); if (document.getElementById('GTR')) removePBs(); // Update the dialog if (addAt == 'sort') sortlist(null); refreshSiteList(); }