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

Block unwanted sites from your Google, DuckDuckGo and Startpage.com search results. For Firefox+Greasemonkey or Chrome+Tampermonkey. v1.6.4 2014-07-22

当前为 2014-07-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Google Hit Hider by Domain (Search Filter / Block Sites)
  3. // @author Jefferson "jscher2000" Scher
  4. // @namespace JeffersonScher
  5. // @version 1.6.4
  6. // @copyright Copyright 2014 Jefferson Scher
  7. // @license BSD with restriction
  8. // @description Block unwanted sites from your Google, DuckDuckGo and Startpage.com search results. For Firefox+Greasemonkey or Chrome+Tampermonkey. v1.6.4 2014-07-22
  9. // @include http*://www.google.*/*
  10. // @include http*://news.google.*/*
  11. // @include http*://images.google.*/*
  12. // @include http*://video.google.*/*
  13. // @include http*://encrypted.google.*/*
  14. // @include http*://startpage.com/*
  15. // @include http*://*.startpage.com/*
  16. // @include http*://duckduckgo.com/*
  17. // @grant GM_addStyle
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_registerMenuCommand
  21. // @grant GM_deleteValue
  22. // @grant GM_log
  23. // @grant GM_xmlhttpRequest
  24. // @resource mycon http://www.jeffersonscher.com/gm/src/gfrk-GHHbD-ver164.png
  25. // ==/UserScript==
  26. var script_about = "https://gf.qytechs.cn/scripts/1682-google-hit-hider-by-domain-search-filter-block-sites";
  27. /*
  28. Copyright (c) 2014 Jefferson Scher. All rights reserved.
  29.  
  30. 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:
  31.  
  32. 1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
  33.  
  34. 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.
  35.  
  36. 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.
  37.  
  38. RESTRICTION: USE WITH ANY @include or @match THAT COVERS FACEBOOK.COM IS PROHIBITED AND UNLICENSED.
  39.  
  40. 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.
  41. */
  42.  
  43. /* SITE RESULTS STRUCTURE as of 2/15/2014
  44. Google: div#res > div#search > div#ires > ol#rso > li.g > div.rc > h3.r > a
  45. Startpage: div#results > ol > li > div.result > h3 > a
  46. DuckDuckGo: div#links > div.results_links_deep > div.links_main > h2 > a
  47. DETECTED on 7/17/2014
  48. 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
  49. */
  50.  
  51. // == == == To override the style of the script's buttons and panes, use the custom style feature == == ==
  52. GM_addStyle("div.ghhider{color:#888;} div.ghhider:hover{background-color:#eee;} " +
  53. "button.ghhider{color:#555;background-color:#fcfcfc;font-family:sans-serif;font-size:0.85em;margin:auto 2px;border:1px solid #ccc;border-radius:4px;-moz-border-radius:4px;padding:2px 3px;} " +
  54. "button.ghhider:hover{color:#000;background:#ff8;} .ghh1time{background:#eee;} .inlinediv{display:inline;} .ghhdnone{display:none !important;} " +
  55. ".ghhpane{position:absolute;color:#333;background-color:#fcfcfc;border:1px solid #ccc;border-radius:4px;-moz-border-radius:4px;padding:0.25em 1.5em;font-size:13px;display:none} " +
  56. "#ghhsitelist, #ghhpbanlist{background:#fff;list-style-type:none;padding:0;margin:0;} " +
  57. "#ghhsitelist li,#ghhpbanlist li{width:100%;line-height:1.5em;padding:0;position:relative} " +
  58. ".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;-moz-border-radius:4px;padding:3px 0;} " +
  59. ".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;-moz-border-radius-bottomleft:8px;-moz-border-radius-topleft:8px;margin-top:1px;padding-left:1px} " +
  60. ".ghhdel{text-decoration:line-through;color:#333;} .ghhpb{text-decoration:none;color:#f00;} " +
  61. ".ghhblk{text-decoration:none;color:#333;} .ghhd{position:relative;line-height:1.2em;cursor:pointer;} " +
  62. ".ghhindent{position:absolute;left:350px;top:-3px;} #btnedit p{margin:2px 4px 4px 4px;} #ghhblockform input[type='radio'], #ghhmngform input[type='radio']{vertical-align:bottom;margin-top:5px;margin-bottom:1px} " +
  63. ".ghhtbl{border:1px solid black;border-collapse:collapse} .ghhtbl td, .ghhtbl th{border:1px solid black;padding:2px 4px;} " +
  64. "#ghhtsdiv{margin:0 -1.5em;padding:0 3px 0 8px;border-bottom:1px solid #ccc;} #ghhtstrip{padding-bottom:0;} " +
  65. "#ghhtstrip button{color:#555;background-color:#f5f5f5;margin:0 2px 0 0;border:1px solid #ccc;padding:1px 2px;height:22px;border-radius:2px;-moz-border-radius:2px;} " +
  66. "#ghhtstrip .ghhCurTab{background-color:#fcfcfc;border-bottom-color:#fcfcfc;} .ghhtab {margin-top:1em;height:17em;overflow-y:scroll;border:1px solid #333;} " +
  67. "#mflists>div>p{margin:1em 0;} #ghhmngform{position:fixed;top:90px;right:0;z-index:1001;}");
  68. GM_addStyle("@media print {button.ghhider{display:none;}}");
  69.  
  70. // Style override example: .ghhd{font-size:0.8em;text-decoration:line-through;}
  71. var custSty = GM_getValue("hiderStyles");
  72. if (!custSty || custSty.length == 0){
  73. custSty = "";
  74. GM_setValue("hiderStyles",custSty);
  75. }
  76. var ghhbd_custsty = document.createElement("style");
  77. ghhbd_custsty.setAttribute("type", "text/css");
  78. ghhbd_custsty.id = "ghhbdcuststy";
  79. ghhbd_custsty.appendChild(document.createTextNode(custSty));
  80. document.body.appendChild(ghhbd_custsty);
  81.  
  82. var currentG;
  83. if (location.host.indexOf("google.") > -1) currentG = location.host.substr(location.host.indexOf("google."));
  84. else currentG = location.hostname;
  85. if (currentG.indexOf("duckduckgo") > -1) GM_addStyle(".links_main{overflow:visible !important;} .ghhb{font-size:12px!important;margin-left:4px!important;} .result__a{display:inline!important;}");
  86.  
  87. // == == == Globals for preferences == == ==
  88. 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;
  89. blist = GM_getValue("hideyhosts");
  90. if (!blist || blist.length == 0){
  91. blist = "|bigresource.com:t|";
  92. GM_setValue("hideyhosts",blist);
  93. } else {
  94. if (blist.substr(0,1) != "|") blist = "|" + blist;
  95. if (blist.indexOf(":") < 0) convertFormat();
  96. }
  97. defaultTxts = {
  98. "block":["block","Button next to the result title to call up the block dialog"],
  99. "unblock":["Unblock","Green button in results to remove a site from the block list"],
  100. "onetime":["Show Hit","Yellow button in results to show a result temporarily"],
  101. "pban":["Perma-ban","Red button to move a site to the perma-ban list"],
  102. "shownotc":["Show Notices","Button to set the preference for notices to show them"],
  103. "hidenotc":["Hide Notices","Button to set the preference for notices to hide them"],
  104. "okbtn":["Block Site","Button in the block dialog to block the selected domain"],
  105. "cancelbtn":["Cancel","Button in the block dialog to cancel out with making changes"],
  106. "savebtn":["Save Lists","Button in the management pane to update the block and perma-ban lists"],
  107. "closebtn":["Close","Button in the management pane to close the pane"],
  108. "okPbtn":["Perma-ban","Button in the block dialog to perma-ban the selected domain"],
  109. "cancelMbtn":["Manage Hiding","Button in the block dialog to open the management pane"],
  110. "mngbtn":["Manage Hiding","Button on the right side to open the management pane"],
  111. "eximbtn":["Export","Button in the management pane to export the block list"],
  112. "utilbtn":["List Util","Button in the management pane to open the utility panel"],
  113. "sortbtn":["Sort","Button in the management pane to sort the block list"],
  114. "unwwwbtn":["Un-www","Button in the management pane to strip www from blocked domains"],
  115. "dedupbtn":["De-Dup","Button in the management pane to de-duplicate the block list"],
  116. "impobtn":["Import","Button in the management pane to import domains into the block list"],
  117. "sharebtn":["Share","Button in the management pane to post block list to the web"]
  118. };
  119. txtsPref = GM_getValue("textstrings");
  120. if (!txtsPref || txtsPref.length == 0){
  121. txts = defaultTxts;
  122. GM_setValue("textstrings",JSON.stringify(txts));
  123. } else {
  124. if (txtsPref.indexOf(":[") == -1 || txtsPref.indexOf("mngbtn") == -1 ||
  125. txtsPref.indexOf("eximbtn") == -1 || txtsPref.indexOf("utilbtn") == -1 ||
  126. txtsPref.indexOf("impobtn") == -1){
  127. convertTxts(txtsPref);
  128. } else {
  129. txts = JSON.parse(txtsPref);
  130. }
  131. }
  132. defaultPrefs = {
  133. "shownotc":["Y","Show hit notices(Y|N)"],
  134. "mngpaneopen":["Y-N","Persistence enabled(Y|N),Pane was open(Y|N),Last tab number(1-4)"],
  135. "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)"],
  136. "addtolistpos":["end","Where to add new hits to block lists(end|top|sort)"],
  137. "aggressiveblock":["none","Which domains to default to shorter form(none|all|www)"],
  138. "usemutation":["on-Y","Listen for mutation events(on|off),Use DOM4 Mutation Observer(Y|N)"],
  139. "oneclick":["N-N","One-click blocking(Y|N),Goes to Perma-ban(Y|N)"],
  140. "runbeta":["N","Enable incompletely tested features (Y|N)"],
  141. "reserved2":["X","Y"]
  142. };
  143. ghhPrefs = GM_getValue("ghhprefs");
  144. if (!ghhPrefs || ghhPrefs.length == 0){
  145. convertPrefs(defaultPrefs, "true");
  146. } else {
  147. if (ghhPrefs.indexOf("reserved1")>-1){
  148. convertPrefs(defaultPrefs, "false");
  149. } else {
  150. ghhPrefO = JSON.parse(ghhPrefs);
  151. }
  152. }
  153. showYN = ghhPrefO.shownotc[0];
  154. mpopen = ghhPrefO.mngpaneopen[0];
  155. mbstyle = ghhPrefO.mngbtnstyle[0];
  156. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H");
  157. if (mbstyle.split("-").length < 3){
  158. GM_addStyle("#ghhMngBtn {position:fixed;top:200px;right:-2.8em;-moz-transform:rotate(-90deg);"+
  159. "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;padding:6px 0 6px 0;z-index:100;}");
  160. } else {
  161. switch (mbstyle.split("-")[2]){
  162. case "B":
  163. GM_addStyle("#ghhMngBtn {position:fixed;bottom:0;right:2px;"+
  164. "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;padding:6px 0 6px 0;z-index:100;}");
  165. break;
  166. case "T":
  167. GM_addStyle("#ghhMngBtn {margin:0;padding:4px 6px;z-index:1001;}");
  168. if (document.querySelector("#appbar ol")){
  169. window.setTimeout(function(){document.querySelector("#appbar ol#ab_ctls").appendChild(document.getElementById("ghhMngBtn"))}, 1000);
  170. 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);
  171. } else {
  172. 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);
  173. }
  174. break;
  175. default:
  176. GM_addStyle("#ghhMngBtn {position:fixed;top:200px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+
  177. "border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;-moz-border-radius-bottomleft:0;-moz-border-radius-bottomright:0;padding:6px 0 6px 0;z-index:100;}");
  178. }
  179. }
  180. if (mbstyle.split("-").length > 3) bbstyle = mbstyle.split("-")[3];
  181. else bbstyle = "P";
  182. if (mbstyle.split("-").length > 5) bbpos = mbstyle.split("-")[5];
  183. else ppbos = "H";
  184. // toggleciteline(bbpos); called by fixuistyle()
  185. addAt = ghhPrefO.addtolistpos[0];
  186. listchgs = 0;
  187. bLUopen = "N";
  188. bAggress = ghhPrefO.aggressiveblock[0];
  189. bAJAX = ghhPrefO.usemutation[0].split("-")[0];
  190. if (ghhPrefO.usemutation[0].split("-").length > 1) bMutOb = ghhPrefO.usemutation[0].split("-")[1];
  191. else bMutOb = "Y";
  192. pref1click = ghhPrefO.oneclick[0];
  193. betatest = ghhPrefO.runbeta[0];
  194. if (document.body){
  195. // Add buttons, hide unwanted domains
  196. hidehits(null,false);
  197. //removePBs();
  198. // Special results layout
  199. if (betatest == "Y"){
  200. var itbl = document.querySelector("#res .images_table");
  201. if (itbl) hidebasic(itbl);
  202. }
  203. // Create skeleton of manage form
  204. if (!document.getElementById("ghhmngform")) addManageForm();
  205. // Add manage button
  206. if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk"){
  207. if (currentG.indexOf("google") > -1 && document.getElementById("res")) addMngBtn();
  208. if (currentG.indexOf("google") < 0) addMngBtn();
  209. }
  210. // Show pane if last open
  211. if (mpopen.substr(0,3) == "Y-Y") showManageForm("mngform");
  212. // Add menu item
  213. GM_registerMenuCommand("Manage Hiding", showManageForm);
  214. // Create block form
  215. if (!document.getElementById("ghhblockform")) addBlockForm();
  216. // Watch for changes that could be new instant or AJAX search results
  217. if (bAJAX == "on") setMutationWatch();
  218. }
  219. function setMutationWatch(){
  220. // Prefer MutationObserver (Firefox 14+) over Mutation Events
  221. MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
  222. if (MutOb && bMutOb == "Y"){
  223. chgMon = new MutOb(function(mutationSet){
  224. mutationSet.forEach(function(mutation){
  225. for (var i=0; i<mutation.addedNodes.length; i++){
  226. if (mutation.addedNodes[i].nodeType == 1){
  227. checkNode(mutation.addedNodes[i]);
  228. }
  229. }
  230. });
  231. });
  232. // attach chgMon to document.body
  233. opts = {childList: true, subtree: true};
  234. chgMon.observe(document.body, opts);
  235. } else { // Legacy browser support
  236. document.body.addEventListener("DOMSubtreeModified", checkOlist, false);
  237. }
  238. }
  239. // == == == Main Event Loops == == ==
  240. var ignoreNodeNames = "|BODY|#text|#comment|INPUT|BUTTON|SCRIPT|LI|A|FORM|";
  241. var ignoreIds = "|leftnav|leftnavc|foot|ghhtemp|ghhblockform|ghhmanageform|ghhsitelist|ghhpbanlist|rhs|rhscol|";
  242. var ignoreClass = "|ghhider|inlinediv|ghh1time|";
  243. var t_ap;
  244.  
  245. function checkOlist(e){ // Check for new results
  246. // AutoPager extension
  247. if (e.target.id){if (e.target.id == "navcnt"){if (e.target.getElementsByClassName("ghhider").length>0){
  248. if (t_ap) window.clearTimeout(t_ap);
  249. t_ap = window.setTimeout(refreshListeners, 500);
  250. return;
  251. }}}
  252. // Ignore events on some elements
  253. if (ignoreNodeNames.indexOf("|"+e.target.nodeName+"|") > -1) return;
  254. if (e.target.hasAttribute("id")){if (ignoreIds.indexOf("|"+e.target.id+"|") > -1) return;}
  255. if (e.target.hasAttribute("class")){
  256. if (ignoreClass.indexOf("|"+e.target.className+"|") > -1) return;
  257. if (e.target.className.indexOf("goog-date") > -1) return;
  258. }
  259. // Standard results layout
  260. var liels = e.target.getElementsByTagName("li");
  261. if (!liels) return;
  262. if (liels.length == 0) return;
  263. // Hide hits if list is visible now
  264. var rslt = document.querySelectorAll("#res");
  265. if (rslt){
  266. if (window.getComputedStyle(rslt[rslt.length-1],null).getPropertyValue("visibility") == "visible" &&
  267. window.getComputedStyle(rslt[rslt.length-1],null).getPropertyValue("display") != "none"){
  268. var nlist = rslt[rslt.length-1].getElementsByTagName("li");
  269. hidehits(nlist,false);
  270. //removePBs();
  271. }
  272. }
  273. }
  274. function checkNode(el){
  275. // AutoPager extension
  276. if (document.querySelector("#navcnt")){
  277. if (t_ap) window.clearTimeout(t_ap);
  278. t_ap = window.setTimeout(refreshListeners, 500);
  279. }
  280. if (el.nodeName == "LI") var nlist = [el];
  281. else var nlist = el.querySelectorAll('li');
  282. if (currentG.indexOf("google") < 0) var nlist = el.querySelectorAll('div.result, div.links_main');
  283. if (nlist.length > 0){
  284. hidehits(nlist,false);
  285. //removePBs();
  286. }
  287. }
  288. function hidehits(liels,ovrd){
  289. if (!liels){
  290. if (currentG.indexOf("google") > -1){ //Google
  291. liels = document.querySelectorAll("#res li");
  292. if (!liels) liels = document.querySelectorAll("#ires li");
  293. } else {
  294. liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep');
  295. }
  296. if (!liels) return;
  297. // if (liels.length == 1){if(liels[0].firstElementChild.id == "rg") liels = liels[0].querySelectorAll(".rg_di");}
  298. }
  299. //GM_log("LOG:liels.length="+liels.length); //DEBUG ONLY
  300. var hosts, hiders, nhider, i, j, k, hid, ael, ahref, dom, dompart, btn, apar, dgone, pban, linkwidth;
  301. hosts = blist;
  302. for (i=0; i<liels.length; i++){
  303. if ((liels[i].parentNode.nodeName == "OL" ||
  304. liels[i].parentNode.nodeName == "TD" ||
  305. (liels[i].className.indexOf("card-section")>1) ||(liels[i].className.indexOf("ct-cs")>1) ||
  306. (liels[i].parentNode.nodeName == "DIV" && liels[i].parentNode.className.indexOf("srg") > -1) ||
  307. (currentG.indexOf("google") < 0 && liels[i].parentNode.nodeName == "DIV")) &&
  308. liels[i].className.indexOf("gbt")!=0 &&
  309. liels[i].className.indexOf("gplusgrid")<0 &&
  310. liels[i].className.indexOf("mitem")<0) {
  311. hiders = liels[i].getElementsByClassName("ghhider");
  312. nhider = hiders.length;
  313. if (nhider == 0 || ovrd == true){ // skip if a button is there
  314. hid = false;
  315. ael = liels[i].querySelector("h3 a"); // first link (not useful for video or book blocks), <h3> preferred
  316. if (!ael) ael = liels[i].querySelector("h2 a");
  317. if (!ael) ael = liels[i].querySelector("a");
  318. if (liels[i].className.indexOf("videobox")>-1) ael = liels[i].querySelectorAll("td")[1].querySelector("a"); //video page
  319. if (ael){ahref=ael.getAttribute("href"); if(ahref){if (ahref.indexOf("http")==0 || ahref.indexOf("/interstitial")==0 ||
  320. ahref.indexOf("/url?q=")==0 || ahref.indexOf(currentG+"/url?q=")>-1 || (ahref.indexOf("/aclk?")==0 && liels[i].className.indexOf("psli")>-1)){
  321. dom = ahref.substr(ahref.indexOf("http"));
  322. if (ael.hasAttribute("data-href")) dom = ael.getAttribute("data-href").substr(ael.getAttribute("data-href").indexOf("http"));
  323. if (dom.indexOf(currentG+"/aclk?")>-1) dom = ahref.substr(ahref.indexOf("http", 10));
  324. // if (dom.indexOf("imgrefurl")>-1) dom = dom.match(/imgrefurl=([^&]+)/)[1];
  325. dom = dom.split("/")[2];
  326. if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
  327. dompart = dom;
  328. while (dompart.indexOf(".")> -1) {
  329. if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck
  330. if (nhider > 0){ // Remove old buttons, notices, etc.
  331. for (k=hiders.length-1; k>=0; k--){
  332. hiders[k].parentNode.removeChild(hiders[k]);
  333. nhider = liels[i].getElementsByClassName("ghhider").length;
  334. }
  335. }
  336. if (liels[i].className.indexOf("ghh1time")<0){
  337. if (hosts.indexOf("|"+dompart+":p")<0) { // Regular block
  338. if (showYN=="Y"){
  339. if (liels[i].className.indexOf("results_links_deep")>-1){ // DDG
  340. replaceHit(dompart,ael,liels[i].querySelector(".links_main"),"");
  341. }
  342. else replaceHit(dompart,ael,liels[i],"");
  343. }
  344. else replaceHit(dompart,ael,liels[i],"none");
  345. } else { // Perma-ban
  346. liels[i].setAttribute("blockhidden",dompart);
  347. if (currentG.indexOf("google") < 0 && liels[i].className.indexOf("ghhdnone")<0){
  348. liels[i].className += " ghhdnone";
  349. if (liels[i].className.indexOf("links_main")>-1) liels[i].parentNode.className += " ghhdnone wtf";
  350. }
  351. }
  352. if (currentG.indexOf("google") < 0 && liels[i].className.indexOf("results_links_deep")>-1) kids = liels[i].lastElementChild.children; //DDG
  353. else kids = liels[i].children;
  354. for (j=0; j<kids.length; j++){ // Hide Google result
  355. if (kids[j].className.indexOf("ghhider")<0 && kids[j].className.indexOf("ghhdnone")<0){
  356. if (kids[j].className.length > 0) kids[j].className += " ghhdnone";
  357. else kids[j].className = "ghhdnone";
  358. }
  359. }
  360. }
  361. if (liels[i].className.indexOf("psli")>-1) liels[i].style.padding = "0"; // Shopping results
  362. hid = true;
  363. break;
  364. }
  365. else {
  366. dompart = dompart.slice(dompart.indexOf(".")+1);
  367. }
  368. }
  369. if (hid == false && nhider > 1) { // Remove previous block & reset nhider
  370. liels[i].removeChild(liels[i].children[0]);
  371. // Clean up unblocked one-times
  372. if (liels[i].className.indexOf("ghh1time")>-1){
  373. liels[i].className = liels[i].className.replace(/\s*ghh1time/,"");
  374. dgone = liels[i].getElementsByClassName("ghhd")[0];
  375. if (dgone) dgone.parentNode.removeChild(dgone);
  376. dgone = liels[i].getElementsByClassName("inlinediv")[0];
  377. if (dgone) dgone.parentNode.removeChild(dgone);
  378. }
  379. nhider = liels[i].getElementsByClassName("ghhider").length;
  380. }
  381. if (hid == false && nhider == 0) { // Not blocked, insert block button
  382. // First, remove hiding for unblocked domains
  383. if (currentG.indexOf("google") < 0 && liels[i].className.indexOf("results_links_deep")>-1) kids = liels[i].lastElementChild.children; //DDG
  384. else kids = liels[i].children;
  385. for (j=0; j<kids.length; j++){
  386. if (kids[j].className.indexOf("ghhdnone")>-1){
  387. kids[j].className = kids[j].className.replace(/\s*ghhdnone/, "");
  388. }
  389. }
  390. if (liels[i].hasAttribute("blockhidden")){
  391. liels[i].removeAttribute("blockhidden");
  392. liels[i].className = liels[i].className.replace(/\s*ghhdnone/, "");
  393. if (currentG.indexOf("google") < 0 && liels[i].className.indexOf("links_main")>-1) liels[i].parentNode.className.replace(/\s*ghhdnone/, "");
  394. }
  395. if (liels[i].hasAttribute("blocknotice")) liels[i].removeAttribute("blocknotice");
  396. // Insert block button
  397. apar = ael;
  398. if (!apar.nextElementSibling){
  399. if (apar.parentNode.nodeName != "LI" &&
  400. apar.parentNode.nodeName != "TD" &&
  401. apar.parentNode.nodeName != "H2") apar = apar.parentNode;
  402. }
  403. if (apar != undefined) { if (dom.indexOf(currentG)<0 &&
  404. (liels[i].parentNode != document.querySelector("#tads ol")) &&
  405. (liels[i].parentNode != document.querySelector("#bottomads ol")) &&
  406. (liels[i].parentNode != document.querySelector("#ads div")) &&
  407. (liels[i].parentNode != document.querySelector("#rhs ol"))){
  408. btn = document.createElement("button");
  409. btn.appendChild(document.createTextNode(txts.block[0]));
  410. btn.className="ghhider ghhb";
  411. btn.setAttribute("meta",dom);
  412. if (pref1click.substr(0,1) == "Y" && mbstyle.split("-")[4] == "Y"){ //BUG: for 1-click with aggressive (subdomain) settings, dom will be incorrect
  413. if (currentG.indexOf("google") > -1) btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form / ALT+click to omit");
  414. else btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form");
  415. } else if (mbstyle.split("-")[4] == "Y"){
  416. if (currentG.indexOf("google") > -1) btn.setAttribute("title","Block "+dom+" / Show block form / ALT+click to omit");
  417. else btn.setAttribute("title","Block "+dom+" / Show block form");
  418. }
  419. btn.addEventListener("click",showbfd,true);
  420. if (apar.nextSibling) apar.parentNode.insertBefore(btn,apar.nextSibling);
  421. else apar.parentNode.appendChild(btn);
  422. // Reposition button to prevent wrapping 3/25/2012
  423. if (apar.nodeName == "H3"){
  424. linkwidth = apar.querySelector('a').offsetWidth;
  425. if (apar.offsetLeft > 0 && apar.offsetLeft < 50) linkwidth += apar.offsetLeft; // fix rare weirdness 2/4/2013
  426. if (apar.parentNode.offsetWidth - linkwidth - btn.offsetWidth > 4) {
  427. apar.style.display = "inline"; // button wraps to end of link
  428. } else {
  429. if (linkwidth > 509) linkwidth = 509; // fix rare weirdness 2/4/2013
  430. btn.setAttribute("style","position:absolute;top:0;right:"+((-1 * btn.offsetWidth)+(apar.parentNode.offsetWidth-linkwidth)-3)+"px;margin-right:0;z-index:100;"); // position past end of link
  431. if (apar.parentNode.nodeName=="LI"||apar.parentNode.nodeName=="DIV") apar.parentNode.style.position="relative";
  432. }
  433. apar.querySelector('a').setAttribute("title",apar.querySelector('a').textContent); // full link text tooltip
  434. }
  435. // Move button to citeline 6/10/2013
  436. if (bbpos == "C") {
  437. var citeline = liels[i].querySelector("cite");
  438. if (citeline) {
  439. citeline.parentNode.appendChild(btn);
  440. btn.removeAttribute("style");
  441. }
  442. }
  443. // Implement Mouseover Option 6/22/2012
  444. if (bbstyle == "M") {
  445. btn.style.visibility = "hidden";
  446. liels[i].addEventListener("mouseover",togglebbtn,false);
  447. liels[i].addEventListener("mouseout",togglebbtn,false);
  448. }
  449. // Avoid unhiding garbage span 5/25/2012
  450. for (j=0; j<liels[i].children.length; j++){
  451. if (liels[i].children[j].className.indexOf("ghhider")<0){
  452. if (liels[i].children[j].style.display=="none") liels[i].children[j].setAttribute("wasdisplaynone","wasdisplaynone");
  453. }
  454. }
  455. }}
  456. }
  457. }}}
  458. }
  459. } else { // BETA - STANDARD image results - doesn't yet support BASIC image results
  460. if (liels[i].parentNode.nodeName == "UL" && betatest == "Y"){
  461. if (!liels[i].hasAttribute("block")){ // skip if previously processed
  462. liels[i].setAttribute("block","normal");
  463. ael = liels[i].getElementsByTagName("a")[0];
  464. if (ael){if(ael.hasAttribute("href")){if (ael.getAttribute("href").indexOf("imgrefurl")>-1){
  465. dom = ael.href.match(/imgrefurl=([^&]+)/)[1].split("/")[2];
  466. if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
  467. dompart = dom;
  468. while (dompart.indexOf(".")> -1) {
  469. if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck
  470. liels[i].setAttribute("block","hidden");
  471. liels[i].style.display = "none";
  472. break;
  473. } else {
  474. dompart = dompart.slice(dompart.indexOf(".")+1);
  475. }
  476. }
  477. }}}
  478. }
  479. }
  480. }
  481. }
  482. if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk" && document.getElementById("res")) addMngBtn();
  483. if (document.getElementsByClassName("unbtn").length > 1) undupMngBtn();
  484. if (betatest == "Y" && currentG !=0){ // BETA - NEW - v1.5.2
  485. // If there are more than two completely invisible results, modify the query to exclude the first hidden site
  486. var invis = document.querySelectorAll("li[blockhidden]");
  487. if (invis.length >= 3) reQry("+-site:"+invis[0].getAttribute("blockhidden"));
  488. }
  489. }
  490. function replaceHit(sdomain,oa,oli,ddis){
  491. var fc, dnew, dset, btn;
  492. fc = oli.querySelector('h3, h2');
  493. if (!fc) fc = oli.firstChild;
  494. if (fc.nodeName=="DIV" && fc.className.indexOf("ghhider")>-1) return;
  495. dnew = document.createElement("div");
  496. dnew.appendChild(document.createTextNode(oa.textContent+" on "+sdomain));
  497. dnew.className="ghhider ghhd";
  498. dnew.setAttribute("title","Click to view, unblock or Perma-ban");
  499. dnew.style.display = ddis;
  500. if (ddis == "none"){
  501. oli.setAttribute("blockhidden",sdomain);
  502. if (oli.hasAttribute("blocknotice")) oli.removeAttribute("blocknotice");
  503. } else {
  504. oli.setAttribute("blocknotice",sdomain);
  505. if (oli.hasAttribute("blockhidden")) oli.removeAttribute("blockhidden");
  506. oli.className = oli.className.replace(/\s*ghhdnone/, "");
  507. if (oli.parentNode.className.indexOf("results_links_deep")>-1){
  508. oli.parentNode.setAttribute("blocknotice",sdomain);
  509. if (oli.parentNode.hasAttribute("blockhidden")) oli.parentNode.removeAttribute("blockhidden");
  510. oli.parentNode.className = oli.parentNode.className.replace(/\s*ghhdnone/, "");
  511. }
  512. }
  513. dnew.addEventListener("click",reshow,false);
  514. oli.insertBefore(dnew,oli.firstChild);
  515. dset = document.createElement("div");
  516. dset.className = "ghhider ghhindent";
  517. dset.setAttribute("dom",sdomain);
  518. dset.style.display = "none";
  519. btn = document.createElement("button");
  520. btn.appendChild(document.createTextNode(txts.unblock[0]));
  521. btn.className="ghhider";
  522. btn.setAttribute("title","Unblock this site");
  523. btn.style.backgroundColor="#9f6";
  524. btn.addEventListener("click",unblock,false);
  525. dset.appendChild(btn);
  526. btn = document.createElement("button");
  527. btn.appendChild(document.createTextNode(txts.pban[0]));
  528. btn.className="ghhider";
  529. btn.setAttribute("title","Permanently hide this site");
  530. btn.style.backgroundColor="#f66";
  531. btn.addEventListener("click",permban,false);
  532. dset.appendChild(btn);
  533. btn = document.createElement("button");
  534. btn.appendChild(document.createTextNode("close"));
  535. btn.className="ghhider";
  536. btn.setAttribute("title","Re-hide this hit");
  537. btn.style.backgroundColor="#eee";
  538. btn.addEventListener("click",rehide,false);
  539. dset.appendChild(btn);
  540. dnew.appendChild(dset);
  541. if (dnew.parentNode.style.overflow == "hidden" || dnew.parentNode.style.overflowX == "hidden"){
  542. dnew.insertBefore(document.createElement("br"), dnew.firstChild);
  543. }
  544. dset.addEventListener("click",ghhkillevent,false);
  545. if (oli.className.indexOf("psli")>-1) dnew.style.margin = "1em 0"; // Shopping results
  546. }
  547. function hidebasic(tbl){ // BASIC IMAGE RESULTS, BETA ONLY, NON-AJAX
  548. var hosts, tds, i, j, k, hid, ael, dom, dompart, btn, apar, dgone;
  549. hosts = blist;
  550. tds = tbl.querySelectorAll("td");
  551. for (i=0; i<tds.length; i++){
  552. ael = tds[i].querySelector("a");
  553. if (ael){if(ael.hasAttribute("href")){if (ael.getAttribute("href").indexOf("imgrefurl=")>-1){
  554. dom = ael.getAttribute("href").substr(ael.getAttribute("href").indexOf("imgrefurl=")+7).split("/")[2];
  555. if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
  556. dompart = dom;
  557. while (dompart.indexOf(".")> -1) {
  558. if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck; mark the cell for now
  559. if (hosts.indexOf("|"+dompart+":p")>-1 || showYN=="N") tds[i].setAttribute("ghhaction","delete");
  560. else tds[i].setAttribute("ghhaction","notice");
  561. break;
  562. } else {
  563. dompart = dompart.slice(dompart.indexOf(".")+1);
  564. }
  565. }
  566. }}}
  567. }
  568. for (i=0; i<tds.length; i++){
  569. switch (tds[i].getAttribute("ghhaction")){
  570. case "delete":
  571. // TODO implement deletion
  572. tds[i].innerHTML = "delete cell";
  573. break;
  574. case "notice":
  575. // TODO implement clickable notices
  576. tds[i].style.textDecoration = "line-through";
  577. tds[i].style.opacity = "0.3";
  578. break;
  579. default:
  580. // TODO add block button
  581. }
  582. }
  583. }
  584. // == == == Other Functions == == ==
  585. function reshow(e){ // Show hit without unblocking
  586. var liel, ael, dabs, k;
  587. liel = e.target.parentNode;
  588. while ((currentG.indexOf("google") > -1 || currentG.indexOf("startpage") > -1) && liel.nodeName != "LI"){
  589. liel=liel.parentNode;
  590. if (liel.nodeName == "BODY") return;
  591. }
  592. while ((currentG.indexOf("google") < 0 && currentG.indexOf("startpage") < 0) && liel.nodeName != "DIV"){
  593. liel=liel.parentNode;
  594. if (liel.nodeName == "BODY") return;
  595. }
  596. liel.className += " ghh1time";
  597. // Hide notice, move action buttons, then show hit
  598. e.target.style.display="none";
  599. ael = liel.querySelector("h3 a");
  600. if (!ael) ael = liel.querySelector("span.tl a"); // summarized news result
  601. if (!ael) ael = liel.querySelector("a"); // other
  602. if (liel.className.indexOf("videobox")>-1) ael = liel.querySelectorAll("td")[1].querySelector("a"); //video page
  603. dabs = e.target.firstElementChild;
  604. if (ael.parentNode.nextSibling) ael.parentNode.parentNode.insertBefore(dabs,ael.parentNode.nextSibling);
  605. else ael.parentNode.parentNode.appendChild(dabs);
  606. dabs.className = "inlinediv";
  607. dabs.removeAttribute("style");
  608. if (dabs.nextElementSibling) if (dabs.nextElementSibling.className.indexOf("ghhider") == 0 || dabs.nextElementSibling.innerHTML == "block") dabs.parentNode.removeChild(dabs.nextElementSibling);
  609. for (k=1; k<liel.children.length; k++){
  610. liel.children[k].className = liel.children[k].className.replace(/\s*ghhdnone/, "");
  611. }
  612. e.stopPropagation();
  613. }
  614. // Hide or Show hit notices
  615. function updtpref(e){
  616. var btns, j, hds, s;
  617. if (showYN == "Y"){
  618. if (confirm("No longer show titles or buttons for suppressed results?")){
  619. ghhPrefO.shownotc[0] = "N";
  620. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  621. showYN = ghhPrefO.shownotc[0];
  622. togHiderDivs("no");
  623. }
  624. } else {
  625. hds = document.getElementsByClassName("ghhd");
  626. if (hds.length > 0) s = (hds.length == 1) ? "is 1 blocked hit" : "are "+hds.length+" blocked hits";
  627. else s = "are no blocked hits";
  628. if (confirm("Show titles and buttons for suppressed results? (There "+s+" on this page.)")){
  629. ghhPrefO.shownotc[0] = "Y";
  630. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  631. showYN = ghhPrefO.shownotc[0];
  632. togHiderDivs("yes");
  633. }
  634. }
  635. fixShowHideBtn();
  636. e.target.blur();
  637. }
  638. function fixShowHideBtn(){
  639. var chkMP = document.getElementById("chkshownotc");
  640. var chkBF = document.getElementById("chkshownotcbf");
  641. if (showYN == "Y"){
  642. chkMP.setAttribute("checked","checked");
  643. chkMP.checked = true;
  644. if (chkBF){
  645. chkBF.setAttribute("checked","checked");
  646. chkBF.checked = true;
  647. }
  648. } else {
  649. chkMP.removeAttribute("checked");
  650. chkMP.checked = false;
  651. if (chkBF){
  652. chkBF.removeAttribute("checked");
  653. chkBF.checked = false;
  654. }
  655. }
  656. }
  657. function togHiderDivs(sShow){
  658. var dh, i;
  659. dh = document.getElementsByClassName("ghhider");
  660. for(i=0;i<dh.length;i++) {
  661. if (dh[i].nodeName == "DIV" && dh[i].className.indexOf("ghhindent")<0) {
  662. if (sShow == "yes") dh[i].style.display = "";
  663. else dh[i].style.display = "none";
  664. }
  665. }
  666. }
  667. // Remove domain from the block list
  668. function unblock(e){
  669. var elPar, sdom, slist, liel, tgt;
  670. elPar = e.target.parentNode;
  671. sdom = elPar.getAttribute("dom");
  672. if (!sdom || sdom.length<4){
  673. alert("Problem with domain to unblock");
  674. return;
  675. }
  676. slist = GM_getValue("hideyhosts");
  677. if (slist.substr(0,1) != "|") slist = "|" + slist;
  678. slist = slist.replace("|"+sdom+":t","");
  679. GM_setValue("hideyhosts",slist);
  680. blist = GM_getValue("hideyhosts");
  681. liel = elPar.parentNode;
  682. while (currentG.indexOf("google") > -1 && liel.nodeName != "LI"){
  683. liel=liel.parentNode;
  684. if (liel.nodeName == "BODY") break;
  685. }
  686. if (currentG.indexOf("google") > -1 && liel.nodeName =="LI" && liel.className.indexOf("ghh1time")>-1){
  687. liel.className = liel.className.replace(/\s*ghh1time/,"");
  688. liel.removeChild(liel.getElementsByClassName("ghhd")[0]);
  689. elPar.parentNode.removeChild(elPar);
  690. }
  691. while (currentG.indexOf("google") < 0 && liel.nodeName != "DIV"){
  692. liel=liel.parentNode;
  693. if (liel.nodeName == "BODY") break;
  694. }
  695. if (currentG.indexOf("google") < 0 && liel.nodeName =="DIV" && liel.className.indexOf("ghh1time")>-1){
  696. liel.className = liel.className.replace(/\s*ghh1time/,"");
  697. liel.removeChild(liel.getElementsByClassName("ghhd")[0]);
  698. elPar.parentNode.removeChild(elPar);
  699. }
  700. hidehits(null,true);
  701. if (document.getElementById("ghhmngform")){
  702. if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList();
  703. }
  704. }
  705. // Add domain to the Perma-ban list
  706. function permban(e){
  707. if (!confirm("Never see hits for this domain again?")) return;
  708. var dpar, sdom, slist, liel;
  709. dpar = e.target.parentNode;
  710. sdom = dpar.getAttribute("dom");
  711. slist = GM_getValue("hideyhosts");
  712. if (slist.substr(0,1) != "|") slist = "|" + slist;
  713. slist = slist.replace("|"+sdom+":t","|"+sdom+":p");
  714. GM_setValue("hideyhosts",slist);
  715. blist = GM_getValue("hideyhosts");
  716. liel = dpar.parentNode;
  717. while (currentG.indexOf("google") > -1 && liel.nodeName != "LI"){
  718. liel=liel.parentNode;
  719. if (liel.nodeName == "BODY") break;
  720. }
  721. if (currentG.indexOf("google") > -1 && liel.nodeName == "LI" && liel.className.indexOf("ghh1time")>-1){
  722. liel.className = liel.className.replace(/\s*ghh1time/,"");
  723. }
  724. while (currentG.indexOf("google") < 0 && liel.nodeName != "DIV"){
  725. liel=liel.parentNode;
  726. if (liel.nodeName == "BODY") break;
  727. }
  728. if (currentG.indexOf("google") < 0 && liel.nodeName == "DIV" && liel.className.indexOf("ghh1time")>-1){
  729. liel.className = liel.className.replace(/\s*ghh1time/,"");
  730. }
  731. if(dpar.className.indexOf("ghhindent")>-1) dpar = dpar.parentNode;
  732. dpar.parentNode.removeChild(dpar);
  733. hidehits(null,true);
  734. if (document.getElementById("ghhmngform")){
  735. if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList();
  736. }
  737. }
  738. // Close this bad result and rehide (to allow indendent open/close, do not run through hidehits)
  739. function rehide(e){
  740. var dpar, liel, dompart, ael, j;
  741. dpar = e.target.parentNode;
  742. liel = dpar.parentNode;
  743. while ((currentG.indexOf("google") > -1 || currentG.indexOf("startpage") > -1) && liel.nodeName != "LI"){
  744. liel=liel.parentNode;
  745. if (liel.nodeName == "BODY") break;
  746. }
  747. while ((currentG.indexOf("google") < 0 && currentG.indexOf("startpage") < 0) && liel.nodeName != "DIV"){
  748. liel=liel.parentNode;
  749. if (liel.nodeName == "BODY") break;
  750. }
  751. dompart = dpar.getAttribute("dom");
  752. dpar.parentNode.removeChild(dpar);
  753. ael = liel.querySelector("h3 a, h2 a");
  754. if (!ael) ael = liel.querySelector("a");
  755. liel.className = liel.className.replace(/\s*ghh1time/,"");
  756. liel.removeChild(liel.querySelector("div.ghhd"));
  757. replaceHit(dompart,ael,liel,"");
  758. for (j=0; j<liel.children.length; j++){ // Hide Google result
  759. if (liel.children[j].className.indexOf("ghhider")<0 && liel.children[j].className.indexOf("ghhdnone")<0){
  760. if (liel.children[j].className.length > 0) liel.children[j].className += " ghhdnone";
  761. else liel.children[j].className = "ghhdnone";
  762. }
  763. }
  764. }
  765. // Functions relating to the Block form
  766. function addBlockForm(){
  767. var bfd = document.createElement("div");
  768. bfd.id = "ghhblockform";
  769. bfd.className = "ghhpane";
  770. bfd.setAttribute("style","z-index:105;")
  771. bfd.innerHTML = "<form onsubmit=\"return false;\"><p style=\"margin:0.75em 0;\"><strong>Add to blocklist:</strong></p><p><label " +
  772. "style=\"white-space:pre\"><input type=\"radio\" name=\"ghhdom\" value=\"f\"> <span id=\"ghhfulldom\"></span></label><br>" +
  773. "<label><input type=\"radio\" name=\"ghhdom\" value=\"p\"> <span id=\"ghhpartdom\"></span></label></p>" +
  774. "<p style=\"text-align:center;white-space:pre;line-height:2em;margin:0.75em 0\"><button id=\"ghhbf1\" bt=\"t\"> " + txts.okbtn[0] +
  775. " </button> <button id=\"ghhbf3\" bt=\"p\"> " + txts.okPbtn[0] + " </button><br>" +
  776. "<button id=\"ghhbf2\" mng=\"N\"> " + txts.cancelbtn[0] + " </button> " +
  777. "<button id=\"ghhbf4\" mng=\"Y\">" + txts.cancelMbtn[0] + "</button></p>";
  778. if (currentG.indexOf("google") > -1){
  779. bfd.innerHTML += "<p style=\"border-top:1px solid #aaa;text-align:center;white-space:pre;line-height:2em;margin:0.75em 0;padding-top:0.5em;\">Edit query: <button id=\"ghhbf5\" title=\"This site only\"> +site: </button> " +
  780. "<button id=\"ghhbf6\" title=\"Exclude this site\"> -site: </button></p>"
  781. }
  782. bfd.innerHTML += "<p style=\"margin:0.75em 0;\"><label title=\"Switch between showing and hiding result titles for regular blocked hits\"><input " +
  783. "type=\"checkbox\" name=\"chkshownotcbf\" id=\"chkshownotcbf\"> Show hidden hit notices</label><br>" +
  784. "<label title=\"Switch between block dialog and one-click blocking\"><input type=\"checkbox\" name=\"chk1clickbf\" " +
  785. "id=\"chk1clickbf\"> Enable 1-click blocking</label></p></form>";
  786. document.body.appendChild(bfd);
  787. document.getElementById("ghhbf1").addEventListener("click",addblock,false);
  788. document.getElementById("ghhbf2").addEventListener("click",ghhcloseform,false);
  789. document.getElementById("ghhbf3").addEventListener("click",addblock,false);
  790. document.getElementById("ghhbf4").addEventListener("click",ghhcloseform,false);
  791. if (currentG.indexOf("google") > -1){
  792. document.getElementById("ghhbf5").addEventListener("click",reQuery,false);
  793. document.getElementById("ghhbf6").addEventListener("click",reQuery,false);
  794. }
  795. document.getElementById("ghhblockform").addEventListener("click",ghhkillevent,false);
  796. document.getElementById("chkshownotcbf").addEventListener("change",updtpref,false);
  797. document.getElementById("chk1clickbf").addEventListener("change",updt1click,false);
  798. }
  799. function showbfd(e) {
  800. var bbtn, bfdiv, fdom, pdom, fspan, pspan, tdiv, lt;
  801. bbtn = e.target;
  802. fdom = bbtn.getAttribute("meta");
  803. if (!document.getElementById("ghhblockform")) addBlockForm();
  804. fspan = document.getElementById("ghhfulldom");
  805. fspan.textContent = fdom;
  806. fspan.previousElementSibling.checked = true;
  807. pdom = fdom.substr(fdom.indexOf(".")+1);
  808. pspan = document.getElementById("ghhpartdom");
  809. if (pdom.indexOf(".") > -1) {
  810. pspan.textContent = pdom;
  811. pspan.parentNode.style.display = "";
  812. switch (bAggress){
  813. case "all":
  814. pspan.previousElementSibling.checked = true;
  815. case "www":
  816. if (fdom.substr(0,3) == "www") pspan.previousElementSibling.checked = true;
  817. default:
  818. // default to full domain
  819. }
  820. } else {
  821. pspan.parentNode.style.display = "none";
  822. }
  823. if (e.altKey == true && currentG.indexOf("google") > -1){
  824. reQuery(); return;
  825. }
  826. bfdiv = document.getElementById("ghhblockform");
  827. tdiv = document.getElementById("ghhtemp");
  828. if (!tdiv){
  829. tdiv = document.createElement("div");
  830. tdiv.id = "ghhtemp";
  831. }
  832. lt = bbtn.offsetLeft + bbtn.offsetWidth + 12;
  833. if (bbtn.parentNode.previousElementSibling){
  834. if (window.getComputedStyle(bbtn.parentNode.previousElementSibling,null).getPropertyValue("float") != "none" ||
  835. (bbtn.style.position == "absolute" && bbtn.parentNode.nodeName == "TD")) lt=lt-bbtn.parentNode.offsetLeft;
  836. }
  837. if (currentG.indexOf("google") < 0) lt=lt-bbtn.parentNode.offsetLeft;
  838. tdiv.setAttribute("style", "position:relative;left:" + lt + "px;top:-65px;z-index:100;width:250px;");
  839. if (bbtn.nextElementSibling){
  840. if (bbtn.nextElementSibling.nodeName == "DIV") bbtn.parentNode.insertBefore(tdiv,bbtn.nextElementSibling);
  841. else bbtn.parentNode.appendChild(tdiv);
  842. }
  843. else bbtn.parentNode.appendChild(tdiv);
  844. tdiv.appendChild(bfdiv);
  845. if (tdiv.parentNode.style.overflowX == "hidden" || tdiv.parentNode.style.overflowY == "hidden"){
  846. tdiv.parentNode.style.overflowX = "visible";
  847. tdiv.parentNode.style.overflowY = "visible";
  848. }
  849. if (pref1click.substr(0,1) == "Y" && e.shiftKey != true){ // 1-click; hold Shift to override
  850. if (pref1click.substr(2,1) == "N"){
  851. document.getElementById("ghhbf1").click();
  852. } else {
  853. document.getElementById("ghhbf3").click();
  854. }
  855. } else { // regular + populating 1-click checkbox
  856. var chkBF = document.getElementById("chk1clickbf");
  857. if (pref1click.substr(0,1) == "Y"){
  858. chkBF.setAttribute("checked","checked");
  859. chkBF.checked = true;
  860. } else {
  861. chkBF.removeAttribute("checked");
  862. chkBF.checked = false;
  863. }
  864. chkBF = document.getElementById("chkshownotcbf");
  865. if (showYN == "Y"){
  866. chkBF.setAttribute("checked","checked");
  867. chkBF.checked = true;
  868. } else {
  869. chkBF.removeAttribute("checked");
  870. chkBF.checked = false;
  871. }
  872. bfdiv.style.display = "block";
  873. document.getElementById("ghhbf1").focus();
  874. }
  875. e.stopPropagation();
  876. }
  877. function addblock(e){
  878. var btype, els, i, sdom, tgt;
  879. tgt = e.target;
  880. btype = tgt.getAttribute("bt");
  881. els = tgt.form.querySelectorAll('input[type="radio"]');
  882. for (i=0; i<els.length; i++){
  883. if(els[i].checked == true){
  884. sdom = els[i].nextElementSibling.textContent;
  885. break;
  886. }
  887. }
  888. ghhcloseform(e);
  889. if (blist.substr(0,1) != "|") blist = "|" + blist;
  890. if (!btype) btype == "t";
  891. if (addAt == "end") blist += sdom + ":" + btype + "|";
  892. else blist = "|" + sdom + ":" + btype + blist;
  893. GM_setValue("hideyhosts",blist);
  894. hidehits(null,true);
  895. if (addAt == "sort") sortlist(null);
  896. if (document.getElementById("ghhmngform")){
  897. if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList();
  898. }
  899. }
  900. function ghhcloseform(e){
  901. if (!e) return;
  902. if (typeof(e) == "object" && e.target){
  903. if(e.target.id.indexOf("ghhbf") == 0){
  904. var mng = e.target.getAttribute("mng");
  905. var bfdiv = document.getElementById("ghhblockform");
  906. var tdiv = document.getElementById("ghhtemp");
  907. bfdiv.style.display = "none";
  908. document.body.appendChild(bfdiv);
  909. tdiv.parentNode.removeChild(tdiv);
  910. if (mng == "Y") showManageForm("mngform");
  911. }
  912. if(e.target.id.indexOf("ghhmf") == 0){
  913. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H");
  914. document.getElementById("ghhmngform").style.display = "none";
  915. if (mpopen.substr(0,3) == "Y-Y"){
  916. mpopen = "Y-N";
  917. ghhPrefO.mngpaneopen[0] = mpopen;
  918. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  919. }
  920. }
  921. } else {
  922. if(e == "mngform"){
  923. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H");
  924. document.getElementById("ghhmngform").style.display = "none";
  925. if (mpopen.substr(0,3) == "Y-Y"){
  926. mpopen = "Y-N";
  927. ghhPrefO.mngpaneopen[0] = mpopen;
  928. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  929. }
  930. }
  931. }
  932. e.stopPropagation();
  933. }
  934. // Functions relating to the Manage Hiding button
  935. function addMngBtn(){
  936. if (mbstyle.split("-")[0] == "blk") return;
  937. if (window.self != window.top) if (mbstyle.split("-")[1] == "ifrN") return;
  938. var mbtn;
  939. mbtn = document.createElement("button");
  940. mbtn.appendChild(document.createTextNode(txts.mngbtn[0]));
  941. mbtn.className="ghhider unbtn";
  942. mbtn.setAttribute("title","Manage Google Hit Hider Settings");
  943. mbtn.id = "ghhMngBtn";
  944. mbtn.addEventListener("click",showManageForm,true);
  945. document.body.appendChild(mbtn);
  946. }
  947. function undupMngBtn(){
  948. var unbtns = document.getElementsByClassName("unbtn");
  949. while (unbtns.length > 1){
  950. unbtns[unbtns.length - 1].parentNode.removeChild(unbtns[unbtns.length - 1]);
  951. }
  952. }
  953. function showManageForm(e){
  954. if (window.self != window.top) return;
  955. var mfd;
  956. if (!document.getElementById("ghhmngform")) addManageForm();
  957. mfd = document.getElementById("ghhmngform");
  958. if (mfd.style.display != "none" && e != "mngform"){ // Toggle to hidden
  959. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H");
  960. if (mpopen.substr(0,3) == "Y-Y"){
  961. mpopen = "Y-N";
  962. ghhPrefO.mngpaneopen[0] = mpopen;
  963. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  964. }
  965. mfd.style.display = "none";
  966. } else {
  967. refreshSiteList();
  968. mfd.style.display = "block";
  969. if (mpopen.substr(0,3) == "Y-Y" && mpopen.length == 5){ // Restore last displayed tab
  970. var tabnum = mpopen.substr(4,1);
  971. if (document.getElementById("ghhmt"+tabnum).style.display == "none"){
  972. var synth = document.createEvent("MouseEvents");
  973. synth.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  974. document.getElementById("ghhts"+tabnum).dispatchEvent(synth);
  975. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("S");
  976. if (typeof e == "object") e.target.blur();
  977. return
  978. }
  979. }
  980. if (document.getElementById("ghhmt1").style.display != "none" || document.getElementById("ghhmt4").style.display != "none"){
  981. document.getElementById("ghhmf1").setAttribute("disabled","disabled");
  982. document.getElementById("ghhutil").style.display == "none";
  983. }
  984. else {
  985. if (document.getElementById("ghhmf1").hasAttribute("disabled")) document.getElementById("ghhmf1").removeAttribute("disabled");
  986. if (bLUopen != "N") document.getElementById("ghhutil").style.display = "block";
  987. }
  988. setCurrentTab();
  989. if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("S");
  990. }
  991. if (typeof e == "object") e.target.blur();
  992. }
  993. function setCurrentTab(){
  994. var k, tabnum;
  995. var tabset = document.querySelectorAll("#mflists>div");
  996. for (k=0; k<tabset.length; k++){
  997. tabnum = tabset[k].getAttribute("id");
  998. tabnum = tabnum.substr(tabnum.length-1);
  999. if (tabset[k].style.display != "none"){
  1000. document.getElementById("ghhts"+tabnum).className = "ghhCurTab";
  1001. if (mpopen.substr(0,1) == "Y"){
  1002. mpopen = "Y-Y-"+tabnum;
  1003. ghhPrefO.mngpaneopen[0] = mpopen;
  1004. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1005. }
  1006. }
  1007. else document.getElementById("ghhts"+tabnum).className = "";
  1008. }
  1009. }
  1010. // Functions relating to the Manage GHH form
  1011. function addManageForm(){
  1012. var mfd = document.createElement("div");
  1013. mfd.id = "ghhmngform";
  1014. mfd.className = "ghhpane";
  1015. mfd.setAttribute("style","display:none;");
  1016. mfd.innerHTML = "<form onsubmit=\"return false;\"><div id=\"ghhtsdiv\">" +
  1017. "<p style=\"margin:6px 0 -1px 0\" id=\"ghhtstrip\">" +
  1018. "<button id=\"ghhts1\" title=\"General Use and Notices\">Home</button>" +
  1019. "<button id=\"ghhts2\" title=\"Regular Block List\">Block</button>" +
  1020. "<button id=\"ghhts3\" title=\"Perma-ban List\">Perma-ban</button>" +
  1021. "<button id=\"ghhts4\" title=\"Manage Script Options\">Options</button></p></div>" +
  1022. "<div id=\"mflists\" style=\"width:230px\">" +
  1023. "<div id=\"ghhmt1\"><p>Welcome to Google Hit Hider!</p>" +
  1024. "<div class=\"ghhtab\">" +
  1025. "<p style=\"padding:0.25em;margin:0.25em\">Click the block button ( <button class=\"ghhider\" onclick=\"return false;\">" + txts.block[0] + "</button> ) " +
  1026. "next to a hit title to block results from that site. A <b>regular</b> blocked hit becomes a one-line notation, " +
  1027. "while a <b>Perma-ban</b> disappears completely.</p>" +
  1028. "<p style=\"border-top:1px solid #000; padding:0.25em;margin:0.25em\"><label title=\"Switch between showing and hiding result titles " +
  1029. "for regular blocked hits\"><input type=\"checkbox\" name=\"chkshownotc\" id=\"chkshownotc\"> Show hidden hit notices</label><br>" +
  1030. "<label title=\"Switch between block dialog and one-click blocking\"><input type=\"checkbox\" name=\"chk1click\" " +
  1031. "id=\"chk1click\"> Enable 1-click blocking</label></p>" +
  1032. "<p style=\"border-top:1px solid #000; padding:0.25em;margin:0.25em\">v1.6.4 &copy; 2014 Jefferson Scher. Learn more on " +
  1033. "<a href=\"" + script_about + "\">this script's page</a>.</p></div></div>" +
  1034. "<div id=\"ghhmt2\" style=\"display:none\"><p>Click to remove from regular block list:</p>" +
  1035. "<div class=\"ghhtab\"><ul id=\"ghhsitelist\"></ul></div></div>\n" +
  1036. "<div id=\"ghhmt3\" style=\"display:none\"><p>Click to remove from Perma-ban list:</p>" +
  1037. "<div class=\"ghhtab\"><ul id=\"ghhpbanlist\"></ul></div></div>" +
  1038. "<div id=\"ghhmt4\" style=\"display:none\"><p>Manage script options:</p>" +
  1039. "<div class=\"ghhtab\" id=\"btnedit\">" +
  1040. "<p id=\"addradios\">Add newly blocked domains:<br>" +
  1041. "<label><input type=\"radio\" name=\"addpos\" value=\"end\"> at the end of the list</label><br>" +
  1042. "<label><input type=\"radio\" name=\"addpos\" value=\"top\"> at the top of the list</label><br>" +
  1043. "<label><input type=\"radio\" name=\"addpos\" value=\"sort\"> in alphabetical order</label></p>" +
  1044. "<p id=\"aggressrads\" style=\"border-top:1px solid #000;padding-top:0.25em;margin-bottom:8px\">Block form defaults to:<br>" +
  1045. "<label><input type=\"radio\" name=\"agglevel\" value=\"none\"> always the full domain</label><br>" +
  1046. "<label><input type=\"radio\" name=\"agglevel\" value=\"all\"> always the partial domain</label><br>" +
  1047. "<label><input type=\"radio\" name=\"agglevel\" value=\"www\"> partial domain for www only</label></p>" +
  1048. "<p id=\"btnradios\" style=\"border-top:1px solid #000;padding-top:0.25em;margin-bottom:8px\">User interface style:<br>" +
  1049. "<label><input type=\"radio\" name=\"uistyle\" value=\"both\"> Show Manage Hiding &amp; " + txts.block[0] + "</label><br>" +
  1050. "<label>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;<input type=\"checkbox\" name=\"mbiframe\" id=\"mbiframe\"> Manage Hiding in iframes</label><br>" +
  1051. "<label title=\"You can click a " + txts.block[0] + " button to open this dialog\"><input type=\"radio\" name=\"uistyle\" value=\"blk\"> Hide Manage Hiding button</label><br>" +
  1052. "<label title=\"" + txts.block[0] + " buttons will appear only when this dialog is displayed\"><input type=\"radio\" name=\"uistyle\" value=\"mng\"> Hide " + txts.block[0] + " buttons</label><br>" +
  1053. "<span style=\"display:inline-block;margin-top:4px;\">Manage Hiding button position:</span><br>" +
  1054. "<label><input type=\"radio\" name=\"mngbtnpos\" value=\"R\"> Side</label> " +
  1055. "<label><input type=\"radio\" name=\"mngbtnpos\" value=\"T\"> Top</label> " +
  1056. "<label><input type=\"radio\" name=\"mngbtnpos\" value=\"B\"> Bottom</label><br>" +
  1057. "<span style=\"display:inline-block;margin-top:4px;\">Block button position <i>(reloads)</i>:</span><br>" +
  1058. "<label><input type=\"radio\" name=\"blockposit\" value=\"H\"> Headline</label> " +
  1059. "<label><input type=\"radio\" name=\"blockposit\" value=\"C\"> Cite line</label><br>" +
  1060. "<span style=\"display:inline-block;margin-top:4px;\">Display block buttons:</span><br>" +
  1061. "<label><input type=\"radio\" name=\"blockdisp\" value=\"P\"> Always</label> " +
  1062. "<label><input type=\"radio\" name=\"blockdisp\" value=\"M\"> On Mouseover</label><br>" +
  1063. "<span style=\"display:inline-block;margin-top:4px;\">Block button tooltips:</span><br>" +
  1064. "<label><input type=\"radio\" name=\"blockttip\" value=\"Y\"> Full Detail</label> " +
  1065. "<label><input type=\"radio\" name=\"blockttip\" value=\"N\"> None</label></p>" +
  1066. "<p id=\"miscpref\" style=\"border-top:1px solid #000;padding-top:0.25em;margin-bottom:8px\">Misc Preferences:<br>" +
  1067. "<label><input type=\"checkbox\" name=\"chkajax\" id=\"chkajax\"> Instant/AJAX/Autopager</label><br>" +
  1068. "<label><input type=\"checkbox\" name=\"chkdom4\" id=\"chkdom4\"> DOM4 Mutation Observer</label><br>" +
  1069. "<label><input type=\"checkbox\" name=\"chkmpopen\" id=\"chkmpopen\"> Re-open Management Pane</label><br>" +
  1070. "<label><input type=\"checkbox\" name=\"chk1pban\" id=\"chk1pban\"> 1-click to Perma-ban list</label><br>" +
  1071. "<label title=\"Try out features that haven't been completely tested\"><input type=\"checkbox\" name=\"chkbeta\" " +
  1072. "id=\"chkbeta\"> Enable beta features</label></p>" +
  1073. "<p style=\"border-top:1px solid #000;padding-top:0.25em;margin-bottom:8px\">Edit captions:</p>" +
  1074. "<p><button class=\"ghhider\" id=\"ghhedit1\" key=\"block\">" + txts.block[0] + "</button> " +
  1075. "<button class=\"ghhider\" id=\"ghhedit3\" key=\"unblock\" style=\"background:#9f6\">" + txts.unblock[0] + "</button> " +
  1076. "<button class=\"ghhider\" id=\"ghhedit2\" key=\"pban\" style=\"background:#f66\">" + txts.pban[0] + "</button></p>" +
  1077. "<p><i>Reload to complete changes</i></p><p><button id=\"ghhmfr\">Restore default captions</button></p>" +
  1078. "<p style=\"border-top:1px solid #000;padding-top:0.25em;margin-bottom:8px\">Custom style rules:<br>" +
  1079. "<button id=\"ghhecsr\">Edit Custom Style Rules</button></p></div></div>" +
  1080. "</div><p style=\"text-align:center;white-space:pre;margin:1em 0\">" +
  1081. "<button id=\"ghhmf1\">" + txts.savebtn[0] + "<span id=\"numchgs\"></span></button> " +
  1082. "<button id=\"ghhmf3\" title=\"Display additional buttons for list management\">List Util" +
  1083. "</button> <button id=\"ghhmf2\">" + txts.closebtn[0] + "</button></p><p id=\"ghhutil\" style=\"display:none\">" +
  1084. "<button id=\"ghhmf4\" title=\"Display block list for copying to backup or share\">" +
  1085. txts.eximbtn[0] + "</button> <button id=\"ghhmf7\" title=\"Import domains to the block list\">" +
  1086. txts.impobtn[0] + "</button> <button id=\"ghhmf8\" title=\"Post block list to the web\" disabled=\"disabled\">" +
  1087. txts.sharebtn[0] + "</button><br /><button id=\"ghhmf5\" title=\"Sort list in alphabetical order\">" +
  1088. txts.sortbtn[0] + "</button> <button id=\"ghhmf6\" title=\"De-duplicate block list by removing unnecessary domains\">" +
  1089. txts.dedupbtn[0] + "</button> <button id=\"ghhmf9\" title=\"Remove www from blocked domains\">" +
  1090. txts.unwwwbtn[0] + "</button></p></form>";
  1091. document.body.appendChild(mfd);
  1092. fixShowHideBtn();
  1093. fixuistyle();
  1094. fixaddpos();
  1095. fixaggblock();
  1096. fixajaxstyle();
  1097. fixpanepersist();
  1098. fix1clickstyle();
  1099. fixBeta();
  1100. document.getElementById("ghhts1").addEventListener("click",togglelist,true); // tabs
  1101. document.getElementById("ghhts2").addEventListener("click",togglelist,true);
  1102. document.getElementById("ghhts3").addEventListener("click",togglelist,true);
  1103. document.getElementById("ghhts4").addEventListener("click",togglelist,true);
  1104. document.getElementById("chkshownotc").addEventListener("change",updtpref,true); // home
  1105. document.getElementById("chk1click").addEventListener("change",updt1click,true);
  1106. document.getElementById("ghhsitelist").addEventListener("click",togglesite,true); // block
  1107. document.getElementById("ghhpbanlist").addEventListener("click",togglesite,true); // pban
  1108. document.getElementById("addradios").addEventListener("change",updtaddpos,true); // options
  1109. document.getElementById("aggressrads").addEventListener("change",updtaggress,true);
  1110. document.getElementById("chkajax").addEventListener("change",updtAJAX,true);
  1111. document.getElementById("chkdom4").addEventListener("change",updtAJAX,true);
  1112. document.getElementById("chkmpopen").addEventListener("change",updtpersist,true);
  1113. document.getElementById("chk1pban").addEventListener("change",updt1click,true);
  1114. document.getElementById("chkbeta").addEventListener("change",updtBeta,true);
  1115. document.getElementById("btnradios").addEventListener("change",updtuistyle,true);
  1116. document.getElementById("ghhedit1").addEventListener("click",chgcaption,true);
  1117. document.getElementById("ghhedit2").addEventListener("click",chgcaption,true);
  1118. document.getElementById("ghhedit3").addEventListener("click",chgcaption,true);
  1119. document.getElementById("ghhmfr").addEventListener("click",resetTextStrings,true);
  1120. document.getElementById("ghhecsr").addEventListener("click",openCustomStyleBar,true);
  1121. document.getElementById("ghhmf1").addEventListener("click",saveedits,true); // buttons
  1122. document.getElementById("ghhmf2").addEventListener("click",ghhcloseform,true);
  1123. document.getElementById("ghhmf3").addEventListener("click",toggleListUtil,true);
  1124. document.getElementById("ghhmf4").addEventListener("click",exportlist,true);
  1125. document.getElementById("ghhmf5").addEventListener("click",sortlist,true);
  1126. document.getElementById("ghhmf6").addEventListener("click",dedup,true);
  1127. document.getElementById("ghhmf7").addEventListener("click",importlist,true);
  1128. document.getElementById("ghhmf9").addEventListener("click",unwww,true);
  1129. }
  1130. function togglelist(e){ // Change tabs
  1131. e.target.blur();
  1132. if (e.target.className == "ghhCurTab") return;
  1133. var tabbtns = document.querySelectorAll("#ghhtstrip>button");
  1134. var k, tabnum;
  1135. for (k=0; k<tabbtns.length; k++){
  1136. tabnum = tabbtns[k].id;
  1137. tabnum = tabnum.substr(tabnum.length-1);
  1138. if (e.target.id == tabbtns[k].id){
  1139. document.getElementById("ghhmt"+tabnum).style.display = "";
  1140. } else {
  1141. document.getElementById("ghhmt"+tabnum).style.display = "none";
  1142. }
  1143. }
  1144. if (document.getElementById("ghhmt1").style.display != "none" || document.getElementById("ghhmt4").style.display != "none"){
  1145. document.getElementById("ghhmf1").setAttribute("disabled","disabled");
  1146. document.getElementById("ghhutil").style.display = "none";
  1147. } else {
  1148. if (document.getElementById("ghhmf1").hasAttribute("disabled")) document.getElementById("ghhmf1").removeAttribute("disabled");
  1149. if (bLUopen != "N") document.getElementById("ghhutil").style.display = "block";
  1150. }
  1151. setCurrentTab();
  1152. }
  1153. function toggleListUtil(e){ // Display/close extra set of buttons
  1154. e.target.blur();
  1155. var p = document.getElementById("ghhutil");
  1156. if (!p) return;
  1157. // If not displaying a list now, move to a list
  1158. if (document.getElementById("ghhmt1").style.display != "none" || document.getElementById("ghhmt4").style.display != "none"){
  1159. var synth = document.createEvent("MouseEvents");
  1160. synth.initMouseEvent("click", true, true, window, 0, 0, 0, 0, 0, false, false, false, false, 0, null);
  1161. document.getElementById("ghhts2").dispatchEvent(synth);
  1162. p.style.display = "block"; // Always open button pane
  1163. bLUopen = "Y";
  1164. } else {
  1165. if (p.style.display != "block"){ // Toggle when list already was displayed
  1166. p.style.display = "block";
  1167. bLUopen = "Y";
  1168. } else {
  1169. p.style.display = "none";
  1170. bLUopen = "N";
  1171. }
  1172. }
  1173. }
  1174. function togglesite(e){ // Designate list items for unblock, pban or block
  1175. var t, l, s, pid;
  1176. t = e.target;
  1177. if (t.className == "ghhinfo") t = t.nextElementSibling;
  1178. l = t.parentNode;
  1179. pid = l.parentNode.id;
  1180. switch (t.className){
  1181. case "ghhhost ghhpb":
  1182. t.className = "ghhhost ghhblk"; // toggle to block
  1183. if (l.nodeName == "LI"){
  1184. if (pid == "ghhsitelist"){
  1185. l.children[0].style.display = "none";
  1186. listchgs = listchgs - 1;
  1187. } else {
  1188. l.children[0].style.display = "inline";
  1189. l.children[0].textContent = "to " + txts.block[0];
  1190. l.children[0].style.backgroundColor = "#ccc";
  1191. listchgs = listchgs + 1;
  1192. }
  1193. }
  1194. break;
  1195. case "ghhhost ghhdel":
  1196. t.className = "ghhhost ghhpb"; // toggle to perma-ban
  1197. if (l.nodeName == "LI"){
  1198. if (pid == "ghhpbanlist"){
  1199. l.children[0].style.display = "none";
  1200. listchgs = listchgs - 1;
  1201. } else {
  1202. l.children[0].style.display = "inline";
  1203. l.children[0].textContent = "to " + txts.pban[0];
  1204. l.children[0].style.backgroundColor = "#f66";
  1205. }
  1206. }
  1207. break;
  1208. default:
  1209. t.className = "ghhhost ghhdel"; // toggle to unblock
  1210. if (l.nodeName == "LI"){
  1211. l.children[0].style.display = "inline";
  1212. l.children[0].textContent = "to " + txts.unblock[0];
  1213. l.children[0].style.backgroundColor = "#9f6";
  1214. if (pid == "ghhsitelist"){
  1215. listchgs = listchgs + 1;
  1216. }
  1217. }
  1218. }
  1219. }
  1220. function saveedits(e){ // Save changes made on tabs 2 and 3
  1221. if (e){
  1222. if (listchgs == 0){
  1223. if (!confirm("No changes detected. Save anyway?")){
  1224. e.target.blur();
  1225. return;
  1226. }
  1227. } else {
  1228. if (!confirm("Save changes to block list?")){
  1229. e.target.blur();
  1230. return;
  1231. }
  1232. }
  1233. }
  1234. var slist, i, sp, ttemp, ptemp;
  1235. slist = document.getElementById("ghhsitelist");
  1236. ttemp = "";
  1237. ptemp = "";
  1238. for (i=0;i<slist.children.length;i++){
  1239. if (slist.children[i].nodeName == "LI") {
  1240. sp = slist.children[i].children[1];
  1241. switch (sp.className){
  1242. case "ghhhost ghhblk":
  1243. ttemp += sp.textContent + ":t|";
  1244. break;
  1245. case "ghhhost ghhpb":
  1246. ptemp += sp.textContent + ":p|";
  1247. break;
  1248. default:
  1249. // to be unblocked
  1250. }
  1251. }
  1252. }
  1253. slist = document.getElementById("ghhpbanlist");
  1254. for (i=0;i<slist.children.length;i++){
  1255. if (slist.children[i].nodeName == "LI") {
  1256. sp = slist.children[i].children[1];
  1257. switch (sp.className){
  1258. case "ghhhost ghhblk":
  1259. ttemp += sp.textContent + ":t|";
  1260. break;
  1261. case "ghhhost ghhpb":
  1262. ptemp += sp.textContent + ":p|";
  1263. break;
  1264. default:
  1265. // to be unblocked
  1266. }
  1267. }
  1268. }
  1269. GM_setValue("hideyhosts", "|" + ttemp + ptemp);
  1270. blist = GM_getValue("hideyhosts");
  1271. hidehits(null,true);
  1272. refreshSiteList();
  1273. listchgs = 0;
  1274. if (e) e.target.blur();
  1275. }
  1276. function refreshSiteList(){ // Rebuild lists for tabs 2 and 3
  1277. var sarray, slist, pblist, i, j, k, litem;
  1278. if (blist.substr(0,1) != "|") blist = "|" + blist;
  1279. sarray = blist.substr(1).split("|");
  1280. slist = document.getElementById("ghhsitelist");
  1281. slist.innerHTML = "";
  1282. pblist = document.getElementById("ghhpbanlist");
  1283. pblist.innerHTML = "";
  1284. j = 0; k = 0;
  1285. for (i=0; i<sarray.length-1; i++){
  1286. if (sarray[i].indexOf(":p")<0) {
  1287. litem = document.createElement("li");
  1288. if(sarray[i].indexOf(":")>0){
  1289. litem.innerHTML = "<span class=\"ghhinfo\"></span><span class=\"ghhhost ghhblk\">" + sarray[i].substr(0, sarray[i].indexOf(":")) + "</span>";
  1290. } else{
  1291. litem.innerHTML = "<span class=\"ghhinfo\"></span><span class=\"ghhhost ghhblk\">" + sarray[i] + "</span>";
  1292. }
  1293. if (j % 2 == 0) litem.style.background = "#fcfcaa";
  1294. slist.appendChild(litem);
  1295. j += 1;
  1296. } else {
  1297. litem = document.createElement("li");
  1298. litem.innerHTML = "<span class=\"ghhinfo\"></span><span class=\"ghhhost ghhpb\">" + sarray[i].substr(0, sarray[i].indexOf(":")) + "</span>";
  1299. if (k % 2 == 0) litem.style.background = "#fcfcaa";
  1300. pblist.appendChild(litem);
  1301. k += 1;
  1302. }
  1303. }
  1304. }
  1305. function updtaddpos(e){ // Implement change for radio buttons re where to add to list
  1306. var rads = e.target.parentNode.querySelectorAll("input[type='radio']");
  1307. for (var i=0; i<rads.length; i++){
  1308. if (rads[i].checked){
  1309. if (rads[i].value == "sort"){
  1310. if(confirm("Sort lists now? Sorting is irreversible.")){
  1311. if (listchgs > 0) {
  1312. if (confirm("You have unsaved changes to your lists. Save changes and sort, or cancel sorting?")){
  1313. saveedits(null);
  1314. } else {
  1315. fixaddpos();
  1316. return;
  1317. }
  1318. }
  1319. sortlist(null);
  1320. } else {
  1321. fixaddpos();
  1322. return;
  1323. }
  1324. }
  1325. addAt = rads[i].value;
  1326. ghhPrefO.addtolistpos[0] = addAt;
  1327. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1328. break;
  1329. }
  1330. }
  1331. fixaddpos();
  1332. }
  1333. function fixaddpos(){ // Check appropriate radio button re where to add to list
  1334. var rads = document.getElementById("addradios").querySelectorAll("input[type='radio']");
  1335. for (i=0; i<rads.length; i++){
  1336. if (rads[i].value == addAt){
  1337. rads[i].setAttribute("checked","checked");
  1338. rads[i].checked = true;
  1339. }
  1340. else{
  1341. if (rads[i].hasAttribute("checked")){
  1342. rads[i].removeAttribute("checked");
  1343. rads[i].checked = false;
  1344. }
  1345. }
  1346. }
  1347. }
  1348. function updtaggress(e){ // Implement change for radio buttons re default domain to block
  1349. var rads = e.target.parentNode.querySelectorAll("input[type='radio']");
  1350. for (var i=0; i<rads.length; i++){
  1351. if (rads[i].checked){
  1352. bAggress = rads[i].value;
  1353. ghhPrefO.aggressiveblock[0] = bAggress;
  1354. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1355. break;
  1356. }
  1357. }
  1358. fixaggblock();
  1359. }
  1360. function fixaggblock(){ // Check appropriate radio button re default domain to block
  1361. var rads = document.getElementById("aggressrads").querySelectorAll("input[type='radio']");
  1362. for (i=0; i<rads.length; i++){
  1363. if (rads[i].value == bAggress){
  1364. rads[i].setAttribute("checked","checked");
  1365. rads[i].checked = true;
  1366. }
  1367. else{
  1368. if (rads[i].hasAttribute("checked")){
  1369. rads[i].removeAttribute("checked");
  1370. rads[i].checked = false;
  1371. }
  1372. }
  1373. }
  1374. }
  1375. function updtuistyle(e){ // Store settings for buttons to display
  1376. var mbparts = mbstyle.split("-");
  1377. if (mbparts.length == 1) mbparts.push("ifrN");
  1378. if (mbparts.length == 2) mbparts.push("R");
  1379. if (mbparts.length == 3) mbparts.push("P");
  1380. if (mbparts.length == 4) mbparts.push("Y");
  1381. if (mbparts.length == 5) mbparts.push("H");
  1382. if (e.target.id == "mbiframe") { // Handle iframe checkbox
  1383. var chk = e.target;
  1384. if (chk.checked){
  1385. mbparts[1] = "ifrY";
  1386. } else {
  1387. mbparts[1] = "ifrN";
  1388. }
  1389. mbstyle = mbparts.join("-");
  1390. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1391. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1392. } else { // Handle radio buttons
  1393. if (e.target.getAttribute("name") == "uistyle"){
  1394. var rads = e.target.parentNode.querySelectorAll("input[name='uistyle']");
  1395. for (var i=0; i<rads.length; i++){
  1396. if (rads[i].checked){
  1397. switch (rads[i].value){
  1398. case "blk":
  1399. mbparts[0] = rads[i].value;
  1400. document.getElementById("ghhMngBtn").parentNode.removeChild(document.getElementById("ghhMngBtn"));
  1401. alert("After you close the management pane, click any block button to open it again.");
  1402. break;
  1403. case "mng":
  1404. if(confirm("Display block buttons only when this dialog is open?")) mbparts[0] = "mng";
  1405. else e.target.checked = false;
  1406. break;
  1407. default:
  1408. mbparts[0] = "both";
  1409. if (!document.getElementById("ghhMngBtn")) addMngBtn();
  1410. }
  1411. mbstyle = mbparts.join("-");
  1412. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1413. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1414. break;
  1415. }
  1416. }
  1417. } else { // Handle Management Button position and block button display style
  1418. var rads = e.target.parentNode.querySelectorAll("input[name='mngbtnpos']");
  1419. for (var i=0; i<rads.length; i++){
  1420. if (rads[i].checked){
  1421. mbparts[2] = rads[i].value;
  1422. mbstyle = mbparts.join("-");
  1423. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1424. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1425. break;
  1426. }
  1427. }
  1428. rads = e.target.parentNode.querySelectorAll("input[name='blockdisp']");
  1429. for (i=0; i<rads.length; i++){
  1430. if (rads[i].checked){
  1431. mbparts[3] = rads[i].value;
  1432. mbstyle = mbparts.join("-");
  1433. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1434. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1435. break;
  1436. }
  1437. }
  1438. rads = e.target.parentNode.querySelectorAll("input[name='blockttip']");
  1439. for (i=0; i<rads.length; i++){
  1440. if (rads[i].checked){
  1441. mbparts[4] = rads[i].value;
  1442. mbstyle = mbparts.join("-");
  1443. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1444. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1445. break;
  1446. }
  1447. }
  1448. rads = e.target.parentNode.querySelectorAll("input[name='blockposit']");
  1449. for (i=0; i<rads.length; i++){
  1450. if (rads[i].checked){
  1451. mbparts[5] = rads[i].value;
  1452. mbstyle = mbparts.join("-");
  1453. ghhPrefO.mngbtnstyle[0] = mbstyle;
  1454. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1455. window.location.reload();
  1456. break;
  1457. }
  1458. }
  1459. }
  1460. }
  1461. fixuistyle();
  1462. }
  1463. function fixuistyle(){ // Check appropriate radio button re buttons to display
  1464. if (mbstyle.split("-").length == 1) mbstyle = mbstyle + "-ifrN-R-P-Y-H";
  1465. if (mbstyle.split("-").length == 2) mbstyle = mbstyle + "-R-P-Y-H";
  1466. if (mbstyle.split("-").length == 3) mbstyle = mbstyle + "-P-Y-H";
  1467. if (mbstyle.split("-").length == 4) mbstyle = mbstyle + "-Y-H";
  1468. if (mbstyle.split("-").length == 5) mbstyle = mbstyle + "-H";
  1469. var rads = document.getElementById("btnradios").querySelectorAll("input[name^='uistyle']");
  1470. for (i=0; i<rads.length; i++){
  1471. if (rads[i].value == mbstyle.split("-")[0]){
  1472. rads[i].setAttribute("checked","checked");
  1473. rads[i].checked = true;
  1474. }
  1475. else{
  1476. if (rads[i].hasAttribute("checked")){
  1477. rads[i].removeAttribute("checked");
  1478. rads[i].checked = false;
  1479. }
  1480. }
  1481. }
  1482. var chk = document.getElementById("mbiframe");
  1483. if (mbstyle.split("-")[1] == "ifrY"){
  1484. chk.setAttribute("checked","checked");
  1485. chk.checked = true;
  1486. } else {
  1487. chk.removeAttribute("checked");
  1488. chk.checked = false;
  1489. }
  1490. var rads = document.getElementById("btnradios").querySelectorAll("input[name^='mngbtnpos']");
  1491. for (i=0; i<rads.length; i++){
  1492. if (rads[i].value == mbstyle.split("-")[2]){
  1493. rads[i].setAttribute("checked","checked");
  1494. rads[i].checked = true;
  1495. }
  1496. else{
  1497. if (rads[i].hasAttribute("checked")){
  1498. rads[i].removeAttribute("checked");
  1499. rads[i].checked = false;
  1500. }
  1501. }
  1502. }
  1503. var rads = document.getElementById("btnradios").querySelectorAll("input[name^='blockdisp']");
  1504. for (i=0; i<rads.length; i++){
  1505. if (rads[i].value == mbstyle.split("-")[3]){
  1506. rads[i].setAttribute("checked","checked");
  1507. rads[i].checked = true;
  1508. }
  1509. else{
  1510. if (rads[i].hasAttribute("checked")){
  1511. rads[i].removeAttribute("checked");
  1512. rads[i].checked = false;
  1513. }
  1514. }
  1515. }
  1516. var rads = document.getElementById("btnradios").querySelectorAll("input[name^='blockttip']");
  1517. for (i=0; i<rads.length; i++){
  1518. if (rads[i].value == mbstyle.split("-")[4]){
  1519. rads[i].setAttribute("checked","checked");
  1520. rads[i].checked = true;
  1521. }
  1522. else{
  1523. if (rads[i].hasAttribute("checked")){
  1524. rads[i].removeAttribute("checked");
  1525. rads[i].checked = false;
  1526. }
  1527. }
  1528. }
  1529. var rads = document.getElementById("btnradios").querySelectorAll("input[name^='blockposit']");
  1530. for (i=0; i<rads.length; i++){
  1531. if (rads[i].value == mbstyle.split("-")[5]){
  1532. rads[i].setAttribute("checked","checked");
  1533. rads[i].checked = true;
  1534. }
  1535. else{
  1536. if (rads[i].hasAttribute("checked")){
  1537. rads[i].removeAttribute("checked");
  1538. rads[i].checked = false;
  1539. }
  1540. }
  1541. }
  1542. toggleciteline(mbstyle.split("-")[5]);
  1543. }
  1544. function updtAJAX(e){ // Store settings for AJAX preferences
  1545. var chk = e.target;
  1546. if (chk.id == "chkajax"){
  1547. if (chk.checked){
  1548. bAJAX = "on";
  1549. if (chgMon) chgMon.disconnect();
  1550. else document.body.removeEventListener("DOMSubtreeModified", checkOlist, false);
  1551. setMutationWatch();
  1552. } else {
  1553. bAJAX = "off";
  1554. if (chgMon) chgMon.disconnect();
  1555. else document.body.removeEventListener("DOMSubtreeModified", checkOlist, false);
  1556. }
  1557. } else {
  1558. if (chk.checked){
  1559. bMutOb = "Y";
  1560. if (!chgMon){
  1561. if (bAJAX){
  1562. document.body.removeEventListener("DOMSubtreeModified", checkOlist, false);
  1563. setMutationWatch();
  1564. }
  1565. }
  1566. } else {
  1567. bMutOb = "N";
  1568. if (chgMon) chgMon.disconnect();
  1569. if (bAJAX){
  1570. document.body.removeEventListener("DOMSubtreeModified", checkOlist, false);
  1571. setMutationWatch();
  1572. }
  1573. }
  1574. }
  1575. ghhPrefO.usemutation[0] = bAJAX + "-" + bMutOb;
  1576. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1577. fixajaxstyle();
  1578. }
  1579. function fixajaxstyle(){ // Check boxes for AJAX preferences
  1580. var chk = document.getElementById("chkajax");
  1581. if (bAJAX == "on"){
  1582. chk.setAttribute("checked","checked");
  1583. chk.checked = true;
  1584. } else {
  1585. chk.removeAttribute("checked");
  1586. chk.checked = false;
  1587. }
  1588. var chk = document.getElementById("chkdom4");
  1589. if (bMutOb == "Y"){
  1590. chk.setAttribute("checked","checked");
  1591. chk.checked = true;
  1592. } else {
  1593. chk.removeAttribute("checked");
  1594. chk.checked = false;
  1595. }
  1596. }
  1597. function updtpersist(e){ // Store setting for persistence preference
  1598. var chk = e.target;
  1599. if (chk.checked){
  1600. mpopen = "Y" + mpopen.substr(1);
  1601. } else {
  1602. mpopen = "N" + mpopen.substr(1);
  1603. }
  1604. ghhPrefO.mngpaneopen[0] = mpopen;
  1605. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1606. fixpanepersist();
  1607. }
  1608. function fixpanepersist(){ // Check box for persistence preference
  1609. var chk = document.getElementById("chkmpopen");
  1610. if (mpopen.substr(0,1) == "Y"){
  1611. chk.setAttribute("checked","checked");
  1612. chk.checked = true;
  1613. } else {
  1614. chk.removeAttribute("checked");
  1615. chk.checked = false;
  1616. }
  1617. }
  1618. function updt1click(e){ // Store setting for 1-click preferences
  1619. var chk = e.target;
  1620. if (chk.id == "chk1click" || chk.id == "chk1clickbf"){
  1621. if (chk.checked){
  1622. pref1click = "Y" + pref1click.substr(1,2);
  1623. } else {
  1624. pref1click = "N" + pref1click.substr(1,2);
  1625. }
  1626. } else {
  1627. if (chk.checked){
  1628. pref1click = pref1click.substr(0,2) + "Y";
  1629. } else {
  1630. pref1click = pref1click.substr(0,2) + "N";
  1631. }
  1632. }
  1633. ghhPrefO.oneclick[0] = pref1click;
  1634. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1635. e.stopPropagation();
  1636. fix1clickstyle();
  1637. }
  1638. function fix1clickstyle(){ // Check boxes for one-click preferences
  1639. var chkMP = document.getElementById("chk1click");
  1640. var chkBF = document.getElementById("chk1clickbf");
  1641. if (pref1click.substr(0,1) == "Y"){
  1642. chkMP.setAttribute("checked","checked");
  1643. chkMP.checked = true;
  1644. if (chkBF){
  1645. chkBF.setAttribute("checked","checked");
  1646. chkBF.checked = true;
  1647. }
  1648. } else {
  1649. chkMP.removeAttribute("checked");
  1650. chkMP.checked = false;
  1651. if (chkBF){
  1652. chkBF.removeAttribute("checked");
  1653. chkBF.checked = false;
  1654. }
  1655. }
  1656. chk = document.getElementById("chk1pban");
  1657. if (pref1click.substr(2,1) == "Y"){
  1658. chk.setAttribute("checked","checked");
  1659. chk.checked = true;
  1660. } else {
  1661. chk.removeAttribute("checked");
  1662. chk.checked = false;
  1663. }
  1664. }
  1665. function updtBeta(e){ // Store setting for runbeta preference
  1666. var chk = e.target;
  1667. if (chk.checked){
  1668. betatest = "Y";
  1669. } else {
  1670. betatest = "N";
  1671. }
  1672. ghhPrefO.runbeta[0] = betatest;
  1673. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO));
  1674. fixBeta();
  1675. }
  1676. function fixBeta(){ // Check box for runbeta preference
  1677. var chk = document.getElementById("chkbeta");
  1678. if (betatest == "Y"){
  1679. chk.setAttribute("checked","checked");
  1680. chk.checked = true;
  1681. } else {
  1682. chk.removeAttribute("checked");
  1683. chk.checked = false;
  1684. }
  1685. }
  1686. function chgcaption(e){ // Store button caption changes (but do not immediately refresh)
  1687. var btn, key, input;
  1688. btn = e.target;
  1689. key = e.target.getAttribute("key");
  1690. e.target.blur();
  1691. input = prompt(txts[key][1], txts[key][0]);
  1692. if (!input) return;
  1693. if (input.length > 0 && input != txts[key][0]){
  1694. txts[key][0] = input.replace(/\"/g,"''");
  1695. btn.appendChild(document.createTextNode(txts[key][0]));
  1696. btn.removeChild(btn.firstChild);
  1697. GM_setValue("textstrings",JSON.stringify(txts));
  1698. }
  1699. }
  1700. function resetTextStrings(e){ // Reset buttons captions to defaults
  1701. if (confirm("Restore default button captions?")){
  1702. txts = defaultTxts;
  1703. GM_setValue("textstrings",JSON.stringify(txts)); // requires Fx 3.5+
  1704. alert("Please reload to see the changes.");
  1705. e.target.blur();
  1706. }
  1707. }
  1708. function exportlist(e){ // Display and populate export form, clean up from any prior use
  1709. if (!document.getElementById("ghhexport")) insertExportForm();
  1710. var expDiv = document.getElementById("ghhexport");
  1711. document.getElementById("ghheximhead").innerHTML = "Export Block List";
  1712. document.getElementById("ghheximinfo1").innerHTML = "These boxes display your current block list. <br /><br />" +
  1713. "On the left, you have the list in its native format. By saving this format, you can preserve your regular/Perma-ban " +
  1714. "block decisions. <br /><br />On the right, you have a simple list of domains. " +
  1715. "This would be a good format for sharing your list with others.";
  1716. document.getElementById("ghhtaleft").value = GM_getValue("hideyhosts");
  1717. var domList = GM_getValue("hideyhosts").substr(1).replace(/:[tp]\|/g, "\n");
  1718. document.getElementById("ghhtaright").value = domList.replace(/\n*$/, "");
  1719. document.getElementById("ghhleftcontrols").style.display = "none";
  1720. document.getElementById("ghhrightcontrols").style.display = "none";
  1721. document.getElementById("ghhtbldiv").style.display = "none";
  1722. if (document.getElementById("ghhtaright").style.display == "none") document.getElementById("ghhtaright").style.display = "";
  1723. expDiv.style.display = "block";
  1724. e.target.blur();
  1725. }
  1726. function insertExportForm(){
  1727. var dNew, btn, par, ta;
  1728. dNew = document.createElement("div");
  1729. dNew.id = "ghhexport";
  1730. dNew.className = "ghhpane";
  1731. dNew.setAttribute("style","position:fixed;top:10%;left:5%;width:90%;z-index:1001;background:#ddd;padding:1em;font-size:1.25em;display:none");
  1732. dNew.innerHTML = "<button onclick=\"this.parentNode.style.display='none'\" style=\"float: right; margin: 0 0 4px 4px;\" class=\"ghhider\">Close</button>" +
  1733. "<p style=\"margin-top:0; font-weight: bold;\" id=\"ghheximhead\"></p>" +
  1734. "<p id=\"ghheximinfo1\"></p>" +
  1735. "<div id=\"ghhleft\" style=\"width:49%;float:left\"><textarea id=\"ghhtaleft\" " +
  1736. "spellcheck=\"false\" style=\"width:100%;height:300px;overflow-y:scroll\"></textarea>" +
  1737. "<div id=\"ghhleftcontrols\" style=\"clear:left;display:none\"><p><button id=\"ghhexp1\">Parse List for Import</button></p></div></div>" +
  1738. "<div id=\"ghhright\" style=\"width:49%;float:right\"><textarea id=\"ghhtaright\" " +
  1739. "spellcheck=\"false\" style=\"width:100%;height:300px;overflow-y:scroll\"></textarea>" +
  1740. "<div id=\"ghhtbldiv\" style=\"height:298px;overflow-y:scroll;overflow-x:scroll;background:#fff;padding:4px 0 0 4px;border:1px solid #aac;margin-top:1px;display:none\"></div> " +
  1741. "<div id=\"ghhrightcontrols\" style=\"clear:right;display:none\"><p id=\"impradios\">Please review the above list for accuracy. If correct, add domains to: <br>" +
  1742. "<label><input type=\"radio\" name=\"impbtype\" value=\"asis\">&nbsp;the list specified under Block Type</label> <br />" +
  1743. "<label><input type=\"radio\" name=\"impbtype\" value=\"t\">&nbsp;the regular block list</label> <br />" +
  1744. "<label><input type=\"radio\" name=\"impbtype\" value=\"p\">&nbsp;the Perma-ban list</label> &nbsp; " +
  1745. "<button id=\"ghhexp2\">Import</button></p></div></div>";
  1746. document.body.appendChild(dNew);
  1747. }
  1748. function importlist(e){ // Display import form, clean up from any prior use
  1749. if (!document.getElementById("ghhexport")) insertExportForm();
  1750. var expDiv = document.getElementById("ghhexport");
  1751. document.getElementById("ghheximhead").innerHTML = "Import Block List";
  1752. document.getElementById("ghheximinfo1").innerHTML = "<strong>As a precaution in case something goes wrong, please use the Export feature to copy " +
  1753. "and save your current list as a backup.</strong> <br /><br />" +
  1754. "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 " +
  1755. "separated by spaces. (It also converts the Noise Reduction for Google and Google Domain Blocker formats.)";
  1756. document.getElementById("ghhtaleft").value = "";
  1757. document.getElementById("ghhleftcontrols").style.display = "";
  1758. document.getElementById("ghhexp1").addEventListener("click",parseList,true);
  1759. document.getElementById("ghhtaright").style.display = "none";
  1760. document.getElementById("ghhtbldiv").style.display = "none";
  1761. expDiv.style.display = "block";
  1762. e.target.blur();
  1763. }
  1764. function parseList(e){ // Parse putative domain list and redisplay cleaned up
  1765. var txt, sites = [], bHasTypes = 0, i, tbod, thd, rasis, lbpos, rbpos;
  1766. txt = document.getElementById("ghhtaleft").value;
  1767. if (txt.length < 4){
  1768. alert("Block list too short!");
  1769. return;
  1770. }
  1771. document.getElementById("ghhtbldiv").innerHTML = "";
  1772. // clean up/convert domain list to pipe-delimited
  1773. txt = txt.replace(/(http|https):/g, "");
  1774. txt = txt.replace(/(,|\/|;)/g, "|");
  1775. txt = txt.replace(/\s+/g, "|");
  1776. txt = txt.replace(/\|+/g, "|");
  1777. txt = txt.replace(/[\<\>"'=#\!\u2018\u2019\(\)\{\}]/g, "");
  1778. // strip regex
  1779. txt = txt.replace(/(\+|\*|\$|\\)/g, "");
  1780. while (txt.indexOf("[") > -1 && txt.indexOf("]") > -1){
  1781. lbpos = txt.indexOf("[");
  1782. rbpos = txt.indexOf("]")
  1783. if (lbpos > 0 && rbpos + 1 < txt.length) txt = txt.substring(0,lbpos) + txt.substring(rbpos+1);
  1784. else {
  1785. if (lbpos == 0 && rbpos + 1 < txt.length) txt = txt.substring(rbpos+1);
  1786. else break; // for some reason, entire list is bracketed??
  1787. }
  1788. }
  1789. if (txt.indexOf(":") > -1) bHasTypes = 1;
  1790. sites = txt.split("|");
  1791. for (i=0; i<sites.length; i++){
  1792. if (sites[i].length > 1){
  1793. if (sites[i].indexOf(".") == 0) sites[i] = sites[i].substr(1);
  1794. if (sites[i].indexOf("?") > -1) sites[i] = sites[i].substr(0,sites[i].indexOf("?"));
  1795. if (bHasTypes == 1){
  1796. if (sites[i].indexOf(":t") == sites[i].length - 2 || sites[i].indexOf(":p") == sites[i].length - 2){
  1797. sites[i] = "<tr><td>" + sites[i].replace(":t","</td><td>regular").replace(":p","</td><td>Perma-ban") + "</td></tr>";
  1798. } else {
  1799. if (sites[i].indexOf(":") > -1) sites[i] = sites[i].substr(0, sites[i].indexOf(":"));
  1800. sites[i] = "<tr><td>" + sites[i] + "</td><td>(unspecified)</td></tr>";
  1801. }
  1802. } else { // Plain list
  1803. sites[i] = "<tr><td>" + sites[i] + "</td></tr>";
  1804. }
  1805. }
  1806. }
  1807. tbod = "<tbody>\n" + sites.join("\n") + "</tbody>";
  1808. if (sites.length == 0){
  1809. alert("Unable to parse the list, sorry."); return;
  1810. }
  1811. if (bHasTypes == 1) thd = "<thead><tr><th>Domain</th><th>Block Type</th></tr></thead>";
  1812. else thd = "<thead><tr><th>Domain</th></tr></thead>";
  1813. document.getElementById("ghhtbldiv").innerHTML = "<table cellspacing=\"0\" class=\"ghhtbl\" id=\"ghhparsed\">" + thd + tbod + "</table>";
  1814. document.getElementById("ghhtbldiv").style.display = "";
  1815. rasis = document.getElementById("ghhrightcontrols").querySelectorAll("input[value='asis']")[0];
  1816. if (bHasTypes == 1){
  1817. if (rasis.hasAttribute("disabled")) rasis.removeAttribute("disabled");
  1818. rasis.checked = true;
  1819. rasis.parentNode.style.color = "";
  1820. } else {
  1821. rasis.setAttribute("disabled","disabled");
  1822. rasis.parentNode.style.color = "rgb(172, 168, 153)";
  1823. document.getElementById("ghhrightcontrols").querySelectorAll("input[value='t']")[0].checked = true;
  1824. }
  1825. document.getElementById("ghhrightcontrols").style.display = "block";
  1826. document.getElementById("ghhexp2").addEventListener("click",doImport,true);
  1827. e.target.blur();
  1828. }
  1829. function doImport(e){ // Add sites from cleaned up domain list to script block lists
  1830. var tbl, rads, i, typeRule, rows, dom, newDoms = "";
  1831. tbl = document.getElementById("ghhparsed");
  1832. if (!tbl){
  1833. alert("Unable to locate table of parsed domains!");
  1834. return;
  1835. }
  1836. if (tbl.parentNode.style.display == "none"){
  1837. alert("Please start the import process again!");
  1838. return;
  1839. }
  1840. rads = document.getElementById("ghhrightcontrols").querySelectorAll("input[type='radio']");
  1841. for (i=0; i<rads.length; i++){
  1842. if (rads[i].checked){
  1843. typeRule = rads[i].value;
  1844. break;
  1845. }
  1846. }
  1847. rows = tbl.getElementsByTagName("tbody")[0].getElementsByTagName("tr");
  1848. for (i=0; i<rows.length; i++){
  1849. dom = rows[i].children[0].textContent;
  1850. if (dom.lastIndexOf(".") < dom.length-2 && dom.indexOf(".") > 1){
  1851. switch (typeRule){
  1852. case "asis":
  1853. if (rows[i].children[1].textContent == "Perma-ban") newDoms += dom + ":p|";
  1854. else newDoms += dom + ":t|";
  1855. break;
  1856. default:
  1857. newDoms += dom + ":" + typeRule + "|";
  1858. }
  1859. rows[i].style.backgroundColor = "#ff0";
  1860. } else {
  1861. rows[i].style.backgroundColor = "#f00";
  1862. }
  1863. }
  1864. if (newDoms != ""){
  1865. if (blist == "") blist = "|" + newDoms;
  1866. else blist += newDoms;
  1867. GM_setValue("hideyback",GM_getValue("hideyhosts"));
  1868. GM_setValue("hideyhosts",blist);
  1869. if(document.getElementById("ghhmngform").style.display=="block") refreshSiteList();
  1870. }
  1871. alert("Import of yellow-highlighted domains completed. Please check the Management Pane to " +
  1872. "view, sort, and/or de-duplicate your imported domains.");
  1873. }
  1874. function sortlist(e){ // Alpha-sort block list
  1875. if (listchgs > 0) {
  1876. if (confirm("You have unsaved changes to your lists. Save changes and sort, or cancel sorting?")){
  1877. saveedits(null);
  1878. } else {
  1879. return;
  1880. }
  1881. }
  1882. if (blist.substr(0,1) != "|") blist = "|" + blist;
  1883. var sarray = blist.substr(1,blist.length-2).split("|");
  1884. sarray.sort();
  1885. GM_setValue("hideyhosts", "|" + sarray.join("|") + "|");
  1886. blist = GM_getValue("hideyhosts");
  1887. refreshSiteList();
  1888. if (e) e.target.blur();
  1889. }
  1890. function dedup(e){ // De-duplicate block lists
  1891. 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;
  1892. var barray, i, j, iadd, smain, stest, sremd = "", sques = "";
  1893. if (blist.substr(0,1) != "|") blist = "|" + blist;
  1894. barray = blist.substr(1,blist.length-2).split("|");
  1895. for (i=0; i<barray.length; i++){
  1896. if (barray[i].indexOf(":t") > -1){
  1897. barray[i] = barray[i].substr(0,barray[i].indexOf(":")).split(".").reverse().join(".") + "!t";
  1898. } else {
  1899. if (barray[i].indexOf(":p") > -1){
  1900. barray[i] = barray[i].substr(0,barray[i].indexOf(":")).split(".").reverse().join(".") + "!p";
  1901. } else {
  1902. barray[i] = barray[i].split(".").reverse().join(".") + "!t";
  1903. }
  1904. }
  1905. }
  1906. barray.sort();
  1907. for (i=0; i<barray.length-1; i++){
  1908. iadd = 0;
  1909. for (j=1; j<barray.length-i; j++){
  1910. if (barray[i+j].indexOf(barray[i].substr(0,barray[i].length-2)) != 0) break;
  1911. smain = barray[i].substr(0,barray[i].length-2).split(".").reverse().join(".");
  1912. stest = barray[i+j].substr(0,barray[i+j].length-2).split(".").reverse().join(".");
  1913. if (stest.indexOf(smain) < 0) break;
  1914. if (barray[i].substr(barray[i].length-1) == barray[i+j].substr(barray[i+j].length-1)){
  1915. blist = blist.replace(stest + ":" + barray[i+j].substr(barray[i+j].length-1) + "|", "");
  1916. sremd += "|Removed: " + stest + "; Covered by: " + smain;
  1917. iadd += 1;
  1918. } else {
  1919. stest += (barray[i+j].substr(barray[i+j].length-1) == "t") ? " (regular)" : " (permaban)";
  1920. smain += (barray[i].substr(barray[i].length-1) == "t") ? " (regular)" : " (permaban)";
  1921. sques += "|Didn't remove " + stest + " due to block type difference from " + smain;
  1922. }
  1923. }
  1924. i += iadd;
  1925. }
  1926. GM_setValue("hideyhosts",blist);
  1927. refreshSiteList();
  1928. // ToDo: Alerts are temporary; nicer display "some day"
  1929. if (sremd != "") alert(sremd.substr(1).replace(/\|/g,"\n"));
  1930. if (sques != "") alert(sques.substr(1).replace(/\|/g,"\n"));
  1931. if (sremd == "" && sques == "") alert("No unnecessary domains found.");
  1932. if (e) e.target.blur();
  1933. }
  1934. function unwww(e){ // Remove www from beginnings of domains
  1935. if (!confirm("You can block other subdomains on example.com by removing www from the beginning (e.g., blog.example.com). Update the block list?")) return;
  1936. if (blist.substr(0,1) != "|") blist = "|" + blist;
  1937. blist = blist.replace(/\|www\./g, "\|");
  1938. GM_setValue("hideyhosts",blist);
  1939. refreshSiteList();
  1940. if (e) e.target.blur();
  1941. }
  1942. // Misc functions
  1943. function convertFormat(){
  1944. if (blist.substr(0,1) != "|") blist = "|" + blist;
  1945. blist = "|" + blist.slice(1).replace(/\|/g,":t|");
  1946. GM_setValue("hideyhosts", blist);
  1947. }
  1948. function convertTxts(strTxts){
  1949. var oldTxts;
  1950. oldTxts = JSON.parse(strTxts);
  1951. txts = defaultTxts;
  1952. if (txtsPref.indexOf(":[") == -1){ // 0.8x to 0.9x+
  1953. txts.block[0] = oldTxts.block;
  1954. txts.unblock[0] = oldTxts.unblock;
  1955. txts.pban[0] = oldTxts.pban;
  1956. txts.okbtn[0] = oldTxts.okbtn;
  1957. txts.cancelbtn[0] = oldTxts.cancelbtn;
  1958. txts.savebtn[0] = oldTxts.savebtn;
  1959. txts.closebtn[0] = oldTxts.closebtn;
  1960. } else { // 0.9x to 1.1x+
  1961. txts.block[0] = oldTxts.block[0];
  1962. txts.unblock[0] = oldTxts.unblock[0];
  1963. txts.pban[0] = oldTxts.pban[0];
  1964. txts.okbtn[0] = oldTxts.okbtn[0];
  1965. txts.cancelbtn[0] = oldTxts.cancelbtn[0];
  1966. txts.savebtn[0] = oldTxts.savebtn[0];
  1967. txts.closebtn[0] = oldTxts.closebtn[0];
  1968. if (oldTxts.okPbtn) txts.okPbtn[0] = oldTxts.okPbtn[0];
  1969. if (oldTxts.cancelMbtn) txts.cancelMbtn[0] = oldTxts.cancelMbtn[0];
  1970. if (oldTxts.mngbtn) txts.mngbtn[0] = oldTxts.mngbtn[0];
  1971. if (txts.savebtn[0]=="Save Changes") txts.savebtn[0]="Save Lists"; // v1.1
  1972. // 1.1 to 1.2+
  1973. if (oldTxts.eximbtn) txts.eximbtn[0] = oldTxts.eximbtn[0];
  1974. // 1.2 to 1.3+
  1975. if (oldTxts.utilbtn) txts.utilbtn[0] = oldTxts.utilbtn[0];
  1976. if (oldTxts.sortbtn) txts.sortbtn[0] = oldTxts.sortbtn[0];
  1977. if (oldTxts.unwwwbtn) txts.unwwwbtn[0] = oldTxts.unwwwbtn[0];
  1978. if (oldTxts.dedupbtn) txts.dedupbtn[0] = oldTxts.dedupbtn[0];
  1979. }
  1980. GM_setValue("textstrings",JSON.stringify(txts)); // requires Fx 3.5+
  1981. }
  1982. function ghhkillevent(e){
  1983. if (e.currentTarget.nodeName == "BUTTON" || e.currentTarget.nodeName == "INPUT") return;
  1984. e.stopPropagation();
  1985. }
  1986. function toggleBlockHiders(str){
  1987. var s = document.getElementById("ghhStyleNoBlock");
  1988. if (str == "S"){
  1989. if (s) s.parentNode.removeChild(s);
  1990. return;
  1991. }
  1992. if (str == "H"){
  1993. if (s) return;
  1994. s = document.createElement("style");
  1995. s.id = "ghhStyleNoBlock";
  1996. s.setAttribute("type", "text/css");
  1997. s.appendChild(document.createTextNode(".ghhb{display:none}"));
  1998. document.body.appendChild(s);
  1999. }
  2000. }
  2001. function refreshListeners(e){ // for AutoPager extension
  2002. var bbtns, bnotc, i, j;
  2003. bbtns = document.getElementById("navcnt").querySelectorAll(".ghhb");
  2004. for (i=0;i<bbtns.length;i++){
  2005. bbtns[i].removeEventListener("click",showbfd,true);
  2006. bbtns[i].addEventListener("click",showbfd,true);
  2007. }
  2008. bnotc = document.getElementById("navcnt").querySelectorAll(".ghhd");
  2009. for (i=0;i<bnotc.length;i++){
  2010. bnotc[i].removeEventListener("click",reshow,true);
  2011. bnotc[i].addEventListener("click",reshow,true);
  2012. bbtns = bnotc[i].querySelectorAll("button.ghhider");
  2013. for (j=0;j<bbtns.length;j++){
  2014. if (bbtns[j].getAttribute("title")=="Unblock this site"){
  2015. bbtns[j].removeEventListener("click",unblock,true);
  2016. bbtns[j].addEventListener("click",unblock,true);
  2017. }
  2018. if (bbtns[j].getAttribute("title")=="Permanently hide this site"){
  2019. bbtns[j].removeEventListener("click",permban,true);
  2020. bbtns[j].addEventListener("click",permban,true);
  2021. }
  2022. if (bbtns[j].getAttribute("title")=="Re-hide this hit"){
  2023. bbtns[j].removeEventListener("click",rehide,true);
  2024. bbtns[j].addEventListener("click",rehide,true);
  2025. }
  2026. }
  2027. }
  2028. }
  2029. function convertPrefs(arrPrefs, allnew){
  2030. ghhPrefO = arrPrefs;
  2031. if (allnew == "true"){ // 1.3.7 to 1.4.x
  2032. var tmp = GM_getValue("shownotc");
  2033. if (tmp){
  2034. if (tmp.length > 0) ghhPrefO.shownotc[0] = tmp;
  2035. GM_deleteValue("shownotc");
  2036. }
  2037. tmp = GM_getValue("mngpaneopen");
  2038. if (tmp){
  2039. if (tmp.length > 0) ghhPrefO.mngpaneopen[0] = tmp;
  2040. GM_deleteValue("mngpaneopen");
  2041. }
  2042. tmp = GM_getValue("mngbtnstyle");
  2043. if (tmp) if (tmp.length > 0){
  2044. if (tmp.indexOf("-")>-1) tmp = "both"; // default ancient pref
  2045. ghhPrefO.mngbtnstyle[0] = tmp;
  2046. GM_deleteValue("mngbtnstyle");
  2047. }
  2048. tmp = GM_getValue("addtolistpos");
  2049. if (tmp){
  2050. if (tmp.length > 0) ghhPrefO.addtolistpos[0] = tmp;
  2051. GM_deleteValue("addtolistpos");
  2052. }
  2053. tmp = GM_getValue("aggressiveblock");
  2054. if (tmp){
  2055. if (tmp.length > 0) ghhPrefO.aggressiveblock[0] = tmp;
  2056. GM_deleteValue("aggressiveblock");
  2057. }
  2058. tmp = GM_getValue("usemutation");
  2059. if (tmp){
  2060. if (tmp.length > 0) ghhPrefO.usemutation[0] = tmp;
  2061. GM_deleteValue("usemutation");
  2062. }
  2063. } else {
  2064. if (ghhPrefs.indexOf("reserved1")>-1){
  2065. var oldPrefs = JSON.parse(ghhPrefs);
  2066. ghhPrefO.shownotc[0] = oldPrefs.shownotc[0];
  2067. ghhPrefO.mngpaneopen[0] = oldPrefs.mngpaneopen[0];
  2068. ghhPrefO.mngbtnstyle[0] = oldPrefs.mngbtnstyle[0];
  2069. ghhPrefO.addtolistpos[0] = oldPrefs.addtolistpos[0];
  2070. ghhPrefO.aggressiveblock[0] = oldPrefs.aggressiveblock[0];
  2071. ghhPrefO.usemutation[0] = oldPrefs.usemutation[0];
  2072. ghhPrefO.oneclick[0] = oldPrefs.oneclick[0];
  2073. }
  2074. }
  2075. GM_setValue("ghhprefs",JSON.stringify(ghhPrefO)); // requires Fx 3.5+
  2076. }
  2077. function togglebbtn(e){
  2078. var bbtn = e.currentTarget.querySelector('.ghhb');
  2079. if (bbtn){
  2080. if (e.type == "mouseover") bbtn.style.visibility = "";
  2081. else bbtn.style.visibility = "hidden";
  2082. }
  2083. }
  2084. function reQuery(e){
  2085. var ss, rads, i;
  2086. if (e){
  2087. if (e.target.id == "ghhbf5") ss = "+site:";
  2088. else ss = "+-site:";
  2089. rads = e.target.form.querySelectorAll('input[type="radio"]');
  2090. } else {
  2091. ss = "+-site:"; // ALT omit
  2092. rads = document.querySelector('#ghhblockform form').querySelectorAll('input[type="radio"]');
  2093. }
  2094. if (rads.length > 0){
  2095. for (var i=0; i<rads.length; i++){
  2096. if(rads[i].checked){
  2097. ss += rads[i].nextElementSibling.textContent;
  2098. reQry(ss);
  2099. break;
  2100. }
  2101. }
  2102. } else GM_log("LOG:reQuery fail: no rads");
  2103. }
  2104. function reQry(d){
  2105. if (!d) return;
  2106. var qsp = window.location.href.indexOf("?");
  2107. if (qsp < 0) return;
  2108. var q = window.location.href.substr(qsp+1);
  2109. if (d.substr(0,2) == "+-" && (q.indexOf(d+"%20")>-1 || q.indexOf(d+"&")>-1)) return; // try to block dups, may be overinclusive
  2110. var qa = q.split("&");
  2111. var has_q = false
  2112. for (var j=qa.length-1; j>=0; j--){
  2113. if (qa[j].split("=")[0] == "q"){
  2114. qa[j] += d;
  2115. has_q = true;
  2116. break;
  2117. } else {
  2118. if (qa[j].indexOf("#q=") > -1){
  2119. qa[j] += d;
  2120. has_q = true;
  2121. break;
  2122. }
  2123. }
  2124. }
  2125. if (has_q) window.location.href = window.location.href.substr(0, window.location.href.indexOf("?")+1) + qa.join("&");
  2126. else GM_log("LOG:Unable to add new search term to URL");
  2127. }
  2128. function toggleciteline(posit) {
  2129. var ghhbd_sty = document.getElementById("bbposciteline");
  2130. if (posit == "C"){
  2131. if (!ghhbd_sty){
  2132. var ghhbd_sty = document.createElement("style");
  2133. ghhbd_sty.id = "bbposciteline";
  2134. ghhbd_sty.setAttribute("type", "text/css");
  2135. document.body.appendChild(ghhbd_sty);
  2136. }
  2137. // "inline" the action menu
  2138. ghhbd_sty.appendChild(document.createTextNode(".action-menu {vertical-align:baseline !important;} .action-menu .clickable-dropdown-arrow {display:none !important;} .action-menu-panel, .action-menu-panel ul, .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;}"));
  2139. // restyle the block button
  2140. 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:0!important;} .ghhb:hover {background:transparent!important; text-decoration:underline !important;}"));
  2141. } else { // remove citeline rules
  2142. if (ghhbd_sty){
  2143. while(ghhbd_sty.firstChild) ghhbd_sty.removeChild(ghhbd_sty.firstChild);
  2144. }
  2145. }
  2146. }
  2147. function openCustomStyleBar(e){
  2148. // Create fixed div with text input and buttons: Save, Test, Close
  2149. var csb = document.getElementById("ghhcsb");
  2150. if (csb){
  2151. csb.style.display = "block";
  2152. } else {
  2153. csb = document.createElement("div");
  2154. csb.id = "ghhcsb";
  2155. csb.setAttribute("style","position:fixed;bottom:0;left:0;z-index:750;width:100%;background-color:#afa;");
  2156. csb.innerHTML = "<form onsubmit=\"return false;\"><p style=\"margin:0.75em;\"><input id=\"ghhcsbrule\" type=\"text\" style=\"width:80%\"> " +
  2157. "<button id=\"ghhcsb1\" title=\"Save and Apply\">Save</button> " +
  2158. "<button id=\"ghhcsb2\" title=\"Test Current Rules\">Test</button> " +
  2159. "<button id=\"ghhcsb3\" title=\"Close\">Close</button></p></form>";
  2160. document.body.appendChild(csb);
  2161. document.getElementById("ghhcsb1").addEventListener("click",saveCustomStyle,true);
  2162. document.getElementById("ghhcsb2").addEventListener("click",testCustomStyle,true);
  2163. document.getElementById("ghhcsb3").addEventListener("click",closeCustomStyleBar,true);
  2164. }
  2165. document.getElementById("ghhcsbrule").value = custSty;
  2166. }
  2167. function saveCustomStyle(e){
  2168. // Update preferences and apply change to style#ghhbdcuststy
  2169. custSty = document.getElementById("ghhcsbrule").value;
  2170. GM_setValue("hiderStyles",custSty);
  2171. document.getElementById("ghhbdcuststy").innerHTML = "";
  2172. document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(custSty));
  2173. }
  2174. function testCustomStyle(e){
  2175. // Add/Edit style#ghhbdcuststy
  2176. document.getElementById("ghhbdcuststy").innerHTML = "";
  2177. document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(document.getElementById("ghhcsbrule").value));
  2178. }
  2179. function closeCustomStyleBar(e){
  2180. // Turn off display and reapply saved style to style#ghhbdcuststy
  2181. document.getElementById("ghhcsb").style.display = "none";
  2182. document.getElementById("ghhbdcuststy").innerHTML = "";
  2183. document.getElementById("ghhbdcuststy").appendChild(document.createTextNode(custSty));
  2184. }
  2185. function removePBs(e){
  2186. // Delete Perma-ban items fronm GoogleMonkeyR layout TODO
  2187. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址