-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGoogle Hit Hider by Domain 汉化版.user.js
2947 lines (2926 loc) · 153 KB
/
Google Hit Hider by Domain 汉化版.user.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// ==UserScript==
// @name Google Hit Hider by Domain 汉化版
// @author Jefferson "jscher2000" Scher ,7980963
// @namespace JeffersonScher
// @version 2.3.1.3
// @copyright Copyright 2023 Jefferson Scher
// @license BSD-3-Clause
// @description 从Google、DuckDuckGo、Startpage.com、Bing和Yahoo搜索结果中屏蔽不需要的站点。 v2.3.1 2024-05-11
// @include http*://www.google.*/*
// @exclude http*://www.google.com/recaptcha/*
// @include http*://www.google.co*.*/*
// @include http*://news.google.*/*
// @include http*://encrypted.google.*/*
// @include http*://startpage.com/*
// @include http*://*.startpage.com/*
// @exclude https://www.startpage.com/*/ads?*
// @exclude https://www.startpage.com/*/*/ads*
// @exclude https://us-browse.startpage.com/av/proxy?*
// @include http*://duckduckgo.com/*
// @include http*://start.duckduckgo.com/*
// @include http*://safe.duckduckgo.com/*
// @include http*://3g2upl4pq6kufc4m.onion/*
// @include http*://www.bing.com/*
// @include http*://*search.yahoo.com/*
// @include http*://search.yahoo.co.jp/*
// @include http*://www.yandex.com/*
// @include http*://yandex.com/*
// @include http*://searx.*/*
// @include http*://www.qwant.com/*
// @include http*://www.qwantjunior.com/*
// @include http*://www.baidu.com/*
// @include https://www.ecosia.org/search*
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @grant GM_registerMenuCommand
// @grant GM_deleteValue
// @grant GM.deleteValue
// @grant GM_getResourceURL
// @grant GM.getResourceUrl
// @resource mycon https://www.jeffersonscher.com/gm/src/gfrk-GHHbD-ver231.png
// ==/UserScript==
var script_about = "https://greasyfork.org/zh-CN/scripts/457749-google-hit-hider-by-domain-%E6%B1%89%E5%8C%96%E7%89%88";
/*
Copyright (c) 2024 Jefferson Scher.
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met and subject to the following restriction:
1. Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holder nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
var GM4 = (typeof GM.getValue === "undefined") ? false : true;
function GHHbD_addStyle(txt){
var s=document.createElement('style');
s.className = 'GHHbDcss';
s.appendChild(document.createTextNode(txt));
document.body.appendChild(s);
}
var isch = false, nws = false;
function injectBaseCSS(){
// == == == To override the style of the script's buttons and panes, use the custom style feature == == ==
GHHbD_addStyle("div.ghhider{color:#888;} div.ghhider:hover{background-color:#eee;} " +
"button.ghhider{color:#555;background-color:#fcfcfc;font-family:sans-serif;font-size:0.85em;line-height:1.2em;margin:auto 2px;border:1px solid #ccc;border-radius:4px;padding:2px 3px;} h3>button.ghhider{font-size:0.75em;} " +
"button.ghhider:hover{color:#000;background:#ff8;} .ghh1time{background:#eee !important;} .ghhdnone{display:none !important;} " +
".ghhpane{position:absolute;color:#333;background-color:#fcfcfc;border:1px solid #ccc;border-radius:4px;padding:0.25em 1.5em;font-size:13px;display:none} " +
"#ghhsitelist, #ghhpbanlist{background:#fff;list-style-type:none;padding:0;margin:0;} " +
"#ghhsitelist li,#ghhpbanlist li{width:100%;line-height:1.5em;padding:0;position:relative} " +
"#ghhsitelist li:nth-of-type(odd),#ghhpbanlist li:nth-of-type(odd){background-color:#fcfcaa} " +
".ghhhost{display:block;padding:0 0.25em;cursor:pointer;} #ghhutil{text-align:center;margin:0.5em 0 1em 0;border:1px solid #ccc;border-radius:4px;padding:3px 0;} " +
".ghhinfo{font-size:12px;line-height:9px;position:absolute;top:0;right:0;z-index:1001;border:4px solid transparent;border-radius:4px;border-bottom-left-radius:8px;border-top-left-radius:8px;margin-top:1px;padding-left:1px} " +
".ghhdel{text-decoration:line-through;color:#333;} .ghhpb{text-decoration:none;color:#f00;} " +
".ghhblk{text-decoration:none;color:#333;} .ghhd{position:relative;line-height:1.2em;cursor:pointer;} " +
".ghhindent{position:absolute;left:350px;top:-3px;} #btnedit p{margin:2px 4px 4px 4px;} #ghhblockform input[type='radio'], #ghhmngform input[type='radio']{vertical-align:baseline !important;margin-top:5px;margin-bottom:1px} " +
"#ghhblockform label, #ghhmngform label{display:inline;font-weight:normal;font-size:unset;} .ghhtbl{border:1px solid black;border-collapse:collapse} .ghhtbl td, .ghhtbl th{border:1px solid black;padding:2px 4px;} " +
"#ghhtsdiv{margin:0 -1.5em;padding:0 3px 0 8px;border-bottom:1px solid #ccc;} #ghhtstrip{padding-bottom:0;} " +
"#ghhtstrip button{color:#555;background-color:#f5f5f5;margin:0 2px 0 0;border:1px solid #ccc;padding:1px 2px;height:22px;border-radius:2px;} " +
"#ghhtstrip .ghhCurTab{background-color:#fcfcfc;border-bottom-color:#fcfcfc;} .ghhtab {margin-top:1em;height:17em;overflow-y:scroll;border:1px solid #333;} " +
"#mflists>div>p{margin:1em 0;} #ghhmngform{position:fixed;top:65px;right:0;z-index:9001;text-align:left;line-height:1.2em} #ghhblockform{text-align:left;z-index:3005} " +
'h3[wotdonut="true"]{overflow:visible!important} div.divGHHbD{text-align:right;align-self:flex-end;padding:4px;} ' +
'button.imgGHHbD{position:relative;z-index:1000;color:#609beb;background-color:#333;border:1px solid #609beb;} button.imgGHHbD:hover{background-color:#000;color:#0ee;}');
GHHbD_addStyle("@media print {button.ghhider,button.imgGHHbD{display:none;}}");
// Standard image results style block
if (location.search.indexOf("tbm=isch") > -1){
var ghhbd_imgsty = document.createElement("style");
ghhbd_imgsty.id = "ghhStyleImgResults";
ghhbd_imgsty.setAttribute("type", "text/css");
ghhbd_imgsty.appendChild(document.createTextNode('div[imgblock="regular"] img{opacity:0.1 !important} div.isv-r[imgblock="regular"] a div:first-of-type{opacity:0.6 !important} div[imgblock="regular"]:not(.isv-r) a div{display:block !important;opacity:0.6 !important}div[imgblock="regular"] img:hover{opacity:0.5 !important} div[imgblock="pban"]{background-color:#aaa !important;border-radius:6px !important} div[imgblock="pban"] a{display:none !important}'));
document.body.appendChild(ghhbd_imgsty);
isch=true;
}
if (location.search.indexOf("tbm=nws") > -1){ //v2.2.6 for News results under www
var ghhbd_nwssty = document.createElement("style");
ghhbd_nwssty.id = "ghhStyleNwsResults";
ghhbd_nwssty.setAttribute("type", "text/css");
ghhbd_nwssty.appendChild(document.createTextNode('.ghhb{position:relative; top: -22px; float:right;} g-scrolling-carousel .ghhb{position:static !important; float:none;}'));
document.body.appendChild(ghhbd_nwssty);
nws=true;
}
}
injectBaseCSS();
var currentG = location.hostname; var engine = 'misc';
function doSiteSpecific(){
if (currentG.indexOf("google") > -1){
engine = 'Google';
// Google: div#res > div#search > div > div#ires > div.srg | ol#rso | div._NId | div.bkWMgd > div.g > div.rc > h3.r > a
// Google in-depth articles: div#res > div#search > div#ires > ol#rso > div > li.g.card-section or li.g.ct-cs > div.rc > div > h3.r > a
// Google Images (default): div#res > div#search > div > div#ires > div#rso > div#isr_mc > div > div#rg > div#rg_s > div.rg_di.rg_el.ivg-ig > a > img
}
if (currentG.indexOf("bing.com") > -1){
engine = 'Bing';
// Bing: div#b_content > main > ol#b-results > li.b_algo > h2 > a
// [as of v2.2.7 5/28/2023] true URL found in li.b_algo > div:not(.b_algo_group) cite
GHHbD_addStyle("li[ghhresult] h2 button.ghhider{font-size:0.7em !important;} li > h2 {white-space:nowrap !important;}");
}
if (currentG.indexOf("duckduckgo") > -1 || currentG.indexOf("3g2upl4pq6kufc4m") > -1){
engine = 'DDG';
// DuckDuckGo: div#links > div.results_links_deep > div.links_main > h2 > a
GHHbD_addStyle(".links_main, .result__title{overflow:visible !important;} .result__title{white-space:nowrap !important;} " +
".ghhb{font-size:12px!important;margin-left:4px!important;position:absolute;margin-top:4px!important} " +
".results_links_deep[blocknotice] + .results__sitelink--organics, .ghhdnone + .results__sitelink--organics, .results_links_deep[blocknotice] + .result__sitelinks--organics, .ghhdnone + .result__sitelinks--organics {display:none;}");
// v2.2.3 2022-05-02: div#links > div.nrn-react-div > article > div > h2 > a
// not sure what CSS changes might be needed yet
// v2.2.5 2023-05-13: ol.react-results--main > li[data-layout="organic"] > article[data-testid="result"][data-nrn="result"] > div > h2 > a
GHHbD_addStyle('li[blocknotice] .ghhider.ghhd{padding-left:10px !important;} li[ghhresult="unset"] h2 > a{display:inline-block !important;}');
}
if (currentG.indexOf("startpage") > -1){
engine = 'Startpage';
// Startpage: div#results > ol > li > div.result > h3 > a
// 11/21/2018: [data-view="results"] div.columns article.column.column--main > div.column.column--main__content > ol.list-flat > li.search-result.search-item > h3.search-item__title > a
// 7/03/2019: div.mainline-results__web section.w-gl > div.w-gl__result > a.w-gl__result-title
// 5/08/2024: div#main > div.w-gl > div.result > a.result-title.result-link, div#main > div.w-bg > div.result > div.result__main > a.result-title.result-link
GHHbD_addStyle('.w-gl__result{overflow:visible !important;} @media(min-width: 651px){div.w-gl .result, div.w-bg .result{position:relative!important;}' +
'.result button.ghhb{position:absolute;right:-30px;margin-top:-28px;} .result .result__main button.ghhb{margin-top:26px;}}' +
'div.w-gl__result .ghhd{padding:0 10px 8px 12px}button.ghhider{font-weight:normal;}' +
'#ghhblockform input[type="checkbox"], #ghhmngform input[type="checkbox"]{width:unset;height:unset;position:static;margin:unset;border:unset;padding:unset;clip:unset;}' +
'#ghhblockform button, #ghhmngform button{font-size:1em;font-weight:normal;border:1px solid #e3e3e3;border-radius:3px;padding:2px 8px;box-shadow:none} #ghhmngform{top:105px !important;}');
}
if (currentG.indexOf("yahoo.com") > -1){
engine = 'Yahoo';
// Yahoo (Firefox): div#results > div#cols > div#left > div > div#main > div > div#web > ol > li > div > div > h3 > a
// GHHbD_addStyle("div#web > ol.reg, li div.compTitle {overflow:visible !important;} .ghhd{margin: 1em 0px -1em 10px} #ghhmngform{top:80px} li div div h3{white-space:nowrap !important;}");
GHHbD_addStyle("div#web > ol.reg, li div.compTitle {overflow:visible !important; border-top:0.1px solid transparent;} .ghhd{margin: 1em 0px 0px 0px} #ghhmngform{top:80px} li div div h3{white-space:normal !important;}"); // v2.2.1
}
if (currentG.indexOf("yahoo.co.jp") > -1){
// Yahoo Japan (OLD): div#contents > div > div > div > div#WS2m > div.w > div.hd > h3 > a
// Yahoo Japan: div#contents > div#contents__wrap > div.Contents__inner Contents__inner--main > div.Contents__innerGroupBody > div.sw-CardBase div.sw-Card__title > a > h3 //v2.2.1
GHHbD_addStyle("#WS2m .w{overflow:visible !important;} #ghhmngform{z-index:3001}");
}
if (currentG.indexOf("baidu") > -1){
engine = 'Baidu';
// Baidu: (title) #content_left > div.result.c-container > h3 > a; (domain) #content_left > div.result.c-container > div > a.c-showurl
// Baidu rich result: (title) #content_left > div.result-op.c-container > h3 > a (or p.op_site_domain_title, div.op_generalqa_main.c-row); (domain) #content_left > div.result-op.c-container[mu]
}
if (currentG.indexOf("yandex.com") > -1){
// Yandex: div.serp-list | ul.serp-list > div.serp-item | li.serp-item > h2 > a
GHHbD_addStyle("h2.serp-item__title{white-space:nowrap;}.ghhb{font-size:0.75em!important;margin-left:4px!important;}");
}
if (currentG.indexOf("qwant") > -1){
// Qwant: div.results-column > div.result_fragment > div.result--web | div.result--news > h3 > a
GHHbD_addStyle("div[blocknotice]:not(.ghh1time){min-height:1em;padding-left:0;}");
}
if (currentG.indexOf("searx") > -1){
// Searx.me: div#main_results > div.result > h4.result_header > a
GHHbD_addStyle("h2.serp-item__title{white-space:nowrap;}.ghhb{font-size:0.75em!important;margin-left:4px!important;}");
}
if (currentG.indexOf("ecosia") > -1){
engine = 'Ecosia';
// Ecosia: div.results-wrapper > div.container.results ... div.card-web ... div.result-firstline-title > a.result-title
GHHbD_addStyle("[ghhresult] h2.result-firstline-title>a.result-title{display:inline;}.ghhider{font-size:0.6em!important;}");
}
}
doSiteSpecific();
function injectCustom(){
if (document.getElementById("ghhbdcuststy")) return;
var ghhbd_custsty = document.createElement("style");
ghhbd_custsty.setAttribute("type", "text/css");
ghhbd_custsty.id = "ghhbdcuststy";
ghhbd_custsty.appendChild(document.createTextNode(custSty));
document.body.appendChild(ghhbd_custsty);
}
var custSty;
if (!GM4){
custSty = GM_getValue("hiderStyles", "");
if (custSty.length > 0) injectCustom();
} else {
GM.getValue("hiderStyles", "").then(function(value){custSty = value; if (custSty.length > 0) injectCustom();});
}
// == == == Globals for preferences == == ==
var blist, defaultTxts, txtsPref, txts, defaultPrefs, ghhPrefs, ghhPrefO, showYN, mpopen, mbstyle, bbstyle, bbpos, addAt, listchgs, bLUopen, bAggress, bAJAX, bMutOb, pref1click, betatest, MutOb, chgMon, opts, kids, needupdate = true, doms = [], t_pb;
var patIPv4 = /\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b/;
function checkblist(){
if (blist.length === 0) blist = "|example.com:t|";
if (blist.substr(0,1) != "|") blist = "|" + blist;
if (blist.indexOf(":") < 0) convertFormat();
}
if (!GM4){
blist = GM_getValue("hideyhosts", "");
checkblist();
} else {
GM.getValue("hideyhosts", "").then(function(value){blist = value; checkblist();});
}
defaultTxts = {
"block": ["屏蔽", "在结果标题旁边的按钮,可呼出屏蔽对话框"],
"unblock": ["解除屏蔽", "在结果中的绿色按钮,可将网站从屏蔽列表中移除"],
"onetime": ["临时显示", "在结果中的黄色按钮,可暂时显示一个结果"],
"pban": ["永久屏蔽", "将网站移到永久屏蔽列表中的红色按钮"],
"shownotc": ["显示通知", "设置是否显示通知的按钮"],
"hidenotc": ["隐藏通知", "设置是否隐藏通知的按钮"],
"okbtn": ["常规屏蔽", "在屏蔽对话框中屏蔽所选域名的按钮"],
"cancelbtn": ["取消", "在屏蔽对话框中取消更改的按钮"],
"savebtn": ["保存列表", "在管理面板中更新屏蔽和永久屏蔽列表的按钮"],
"closebtn": ["关闭", "在管理面板中关闭面板的按钮"],
"okPbtn": ["永久屏蔽", "在屏蔽对话框中永久屏蔽所选域名的按钮"],
"cancelMbtn": ["管理隐藏", "在屏蔽对话框中打开管理面板的按钮"],
"mngbtn": ["Manage Hiding", "Button on the right side to open the management pane"],
"eximbtn": ["导出", "在管理面板中导出屏蔽列表的按钮"],
"utilbtn": ["列表工具", "在管理面板中打开实用程序面板的按钮"],
"sortbtn": ["排序", "在管理面板中对屏蔽列表进行排序的按钮"],
"unwwwbtn": ["去除www", "在管理面板中从被屏蔽的域名中去除www的按钮"],
"dedupbtn": ["去重", "在管理面板中对屏蔽列表进行去重的按钮"],
"impobtn": ["导入", "在管理面板中将域名导入屏蔽列表的按钮"],
"sharebtn": ["分享", "在管理面板中将屏蔽列表发布到网络的按钮"],
"addallbtn": ["全部添加", "在管理面板中批量添加所有未屏蔽的域名到当前列表的按钮"]
};
function checktxts(){
if (txtsPref.indexOf(":[") == -1 || txtsPref.indexOf("mngbtn") == -1 ||
txtsPref.indexOf("eximbtn") == -1 || txtsPref.indexOf("utilbtn") == -1 ||
txtsPref.indexOf("impobtn") == -1 || txtsPref.indexOf("addallbtn") == -1) {
convertTxts(txtsPref);
} else {
txts = JSON.parse(txtsPref);
}
}
if (!GM4){
txtsPref = GM_getValue("textstrings", JSON.stringify(defaultTxts));
checktxts();
} else {
GM.getValue("textstrings", JSON.stringify(defaultTxts)).then(function(value){txtsPref = value; checktxts();});
}
defaultPrefs = {
"shownotc":["Y","Show hit notices(Y|N)"],
"mngpaneopen":["Y-N","Persistence enabled(Y|N),Pane was open(Y|N),Last tab number(1-4)"],
"mngbtnstyle":["both-ifrN-R-P-Y-H","Display Manage Hiding button and Block buttons(mng|blk|both),In iframes(ifrN|ifrY),Position(R,T,B),Block button display(P,M),Block button tooltips(Y|N), Block button position(H|C)"],
"addtolistpos":["end","Where to add new hits to block lists(end|top|sort)"],
"aggressiveblock":["none","Which domains to default to shorter form(none|all|www)"],
"usemutation":["on-Y","Listen for mutation events(on|off),Use DOM4 Mutation Observer(Y|N)"],
"oneclick":["N-N","One-click blocking(Y|N),Goes to Perma-ban(Y|N)"],
"runbeta":["N","Enable incompletely tested features (Y|N)"],
"reserved2":["X","Y"]
};
function checkprefs(){
if (ghhPrefs.length == 0){
convertPrefs(defaultPrefs, "true");
} else {
if (ghhPrefs.indexOf("reserved1")>-1){
convertPrefs(defaultPrefs, "false");
} else {
ghhPrefO = JSON.parse(ghhPrefs);
}
}
}
if (!GM4){
ghhPrefs = GM_getValue("ghhprefs", "");
checkprefs();
if (engine == 'Startpage') window.setTimeout(GHHbDinit, 300);
else GHHbDinit();
} else {
GM.getValue("ghhprefs", "").then(function(value){
ghhPrefs = value;
checkprefs();
if (engine == 'Startpage') window.setTimeout(GHHbDinit, 300);
else GHHbDinit();
});
}
function GHHbDinit(){
showYN = ghhPrefO.shownotc[0];
mpopen = ghhPrefO.mngpaneopen[0];
mbstyle = ghhPrefO.mngbtnstyle[0];
if (mbstyle.split("-")[0] == "mng") toggleBlockHiders("H");
if (mbstyle.split("-").length < 3){
GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+
"border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}");
} else {
switch (mbstyle.split("-")[2]){
case "B":
GHHbD_addStyle("#ghhMngBtn {position:fixed;bottom:0;right:2px;"+
"border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}");
break;
case "T":
GHHbD_addStyle("#ghhMngBtn {margin:0;padding:4px 6px;z-index:3000;}");
if (document.querySelector("#appbar ol")){
window.setTimeout(function(){document.querySelector("#appbar ol#ab_ctls").appendChild(document.getElementById("ghhMngBtn"))}, 1000);
window.setTimeout(function(){var liNew = document.createElement("li");liNew.className="ab_ctl";liNew.appendChild(document.getElementById("ghhMngBtn"));document.querySelector("ol#ab_ctls").appendChild(liNew);}, 1500);
} else {
window.setTimeout(function(){if (document.querySelector("#appbar ol")){var liNew = document.createElement("li");liNew.className="ab_ctl";liNew.appendChild(document.getElementById("ghhMngBtn"));document.querySelector("ol#ab_ctls").appendChild(liNew);}else{document.getElementById("ghhMngBtn").setAttribute("style","position:absolute;top:8em;right:0")}}, 1500);
}
break;
default:
GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+
"border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}");
}
}
if (mbstyle.split("-").length > 3) bbstyle = mbstyle.split("-")[3];
else bbstyle = "P";
if (mbstyle.split("-").length > 5) bbpos = mbstyle.split("-")[5];
else bbpos = "H";
// toggleciteline(bbpos); called by fixuistyle()
addAt = ghhPrefO.addtolistpos[0];
listchgs = 0;
bLUopen = "N";
bAggress = ghhPrefO.aggressiveblock[0];
bAJAX = ghhPrefO.usemutation[0].split("-")[0];
if (ghhPrefO.usemutation[0].split("-").length > 1) bMutOb = ghhPrefO.usemutation[0].split("-")[1];
else bMutOb = "Y";
pref1click = ghhPrefO.oneclick[0];
betatest = ghhPrefO.runbeta[0];
if (document.body){
// Add buttons, hide unwanted domains
hidehits(null,false);
if (document.getElementById("GTR")) removePBs();
// Special results layout
if (betatest == "Y"){
var itbl = document.querySelector("#res .images_table");
if (itbl) hidebasic(itbl);
}
// Create skeleton of manage form
if (!document.getElementById("ghhmngform")) addManageForm();
// Add manage button
if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk"){
if (engine == 'Google'){if(document.getElementById("res") || isch) addMngBtn();}
else addMngBtn();
}
// Show pane if last open
if (mpopen.substr(0,3) == "Y-Y") showManageForm("mngform");
// Add menu item - Legacy Only
if (typeof GM_registerMenuCommand != "undefined") GM_registerMenuCommand("Manage Hiding", showManageForm);
// Create block form
if (!document.getElementById("ghhblockform")) addBlockForm();
// Watch for changes that could be new instant or AJAX search results
if (bAJAX == "on") setMutationWatch();
}
}
function setMutationWatch(){
// Prefer MutationObserver (Firefox 14+) over Mutation Events
MutOb = (window.MutationObserver) ? window.MutationObserver : window.WebKitMutationObserver;
if (MutOb && bMutOb == "Y"){
chgMon = new MutOb(function(mutationSet){
mutationSet.forEach(function(mutation){
if (mutation.type == "childList"){
for (var i=0; i<mutation.addedNodes.length; i++){
if (mutation.addedNodes[i].nodeType == 1){
checkNode(mutation.addedNodes[i]);
}
}
} else if (engine == 'DDG' && mutation.target.className == 'results js-results') { // v2.2.3
for (i=0; i<mutation.target.childNodes.length; i++){
if (mutation.target.childNodes[i].className == 'nrn-react-div'){
checkNode(mutation.target.childNodes[i]);
}
}
} else { // attribute mutation on Google Images
if(mutation.target.className == "rg_l") checkNode(mutation.target.parentNode);
}
});
});
// attach chgMon to document.body
if (isch == true) opts = {childList: true, subtree: true, attributes: true, attributeFilter: ["href"], characterData: false};
else if (engine == 'DDG') opts = {childList: true, subtree: true, attributes: true, characterData: false}; // v2.2.3
else opts = {childList: true, subtree: true, attributes: false, characterData: false};
chgMon.observe(document.body, opts);
} else if (bMutOb == "Y") { // Legacy browser support and Baidu
document.body.addEventListener("DOMSubtreeModified", checkOlist, false);
}
}
// == == == Main Event Loops == == ==
var ignoreNodeNames = "|BODY|#text|#comment|INPUT|BUTTON|SCRIPT|LI|A|FORM|";
var ignoreIds = "|leftnav|leftnavc|foot|ghhtemp|ghhblockform|ghhmanageform|ghhsitelist|ghhpbanlist|rhs|rhscol|";
var ignoreClass = "|ghhider|ghhdbuttons|ghh1time|";
var t_ap, t_gimg;
function checkOlist(e){ // Check for new results // Needed for Baidu
var el = e.target;
// Ignore events on some elements
if (ignoreNodeNames.indexOf("|"+el.nodeName+"|") > -1) return;
if (el.hasAttribute("id")){if (ignoreIds.indexOf("|"+el.id+"|") > -1) return;}
if (el.hasAttribute("class")){
if (ignoreClass.indexOf("|"+el.className+"|") > -1) return;
if (el.classList.contains("goog-date")) return;
}
if (!document.getElementById("ghhmngform")){
addManageForm();
injectBaseCSS();
injectCustom();
if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk"){
if (engine == 'Google'){if(document.getElementById("res")) addMngBtn();}
else addMngBtn();
}
// Use default button style for now (1.9.3)
GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+
"border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}");
}
checkNode(el);
}
function checkNode(el){
if (el.parentNode && (el.parentNode.id == 'ghhsitelist' || el.parentNode.id == 'ghhpbanlist')) return; // 2.0.6 duh!
// AutoPager extension
if (document.querySelector("#navcnt")){
if (t_ap) window.clearTimeout(t_ap);
t_ap = window.setTimeout(refreshListeners, 500);
}
if (el.nodeName == "LI" || (el.nodeName == "DIV" && (el.className == "g" || el.classList.contains("rg_di") || el.className == "rgsh")) ||
el.nodeName == 'G-INNER-CARD' || el.nodeName == 'G-CARD' || el.classList.contains("isv-r")) var nlist = [el];
else nlist = el.querySelectorAll('li.g, div.g, div.rg_di, div.isv-r');
if (engine != 'Google' && el.nodeName != "LI"){
if (el.nodeName == "DIV" && (el.classList.contains("result--web") || el.classList.contains("result--news") ||
el.className == "card-mobile" || el.classList.contains('nrn-react-div'))) nlist = [el]; // Qwant, Ecosia, DDG-react
else if (el.nodeName == "OL" && el.classList.contains('react-results--main')) nlist = el.querySelectorAll('li');
else nlist = el.querySelectorAll('div.result, div.result-op, div.links_main, div.serp-item, div.hd, li.b_algo, ol.list-flat > li, div.card-web div.card-mobile');
}
if (nlist.length > 0){
if (isch) hidehits(nlist,true);
else hidehits(nlist,false);
if (document.getElementById("GTR")) removePBs();
} else if (el.nodeName == "DIV" && ( (el.classList.contains("irc_c") || el.classList.contains("irc_bg")) || el.id == 'irc_bg') ) {
var buttondivs = el.querySelectorAll('.irc_butc:not([ghhresult]), .irc_but_r:not([ghhresult]), .irc_ab:not([ghhresult]), .irc_but_pdfr:not([ghhresult])');
for (var k=0; k<buttondivs.length; k++){
buttondivs[k].setAttribute("ghhresult", "image-unset");
buttondivs[k].style.position = "relative";
if (buttondivs[k].nodeName == 'TABLE'){
var tdnew = document.createElement("td");
tdnew.innerHTML = '<button type="button" title="Block/Unblock" class="irc_but"><span class="irc_but_t">GHHbD</span></button>';
buttondivs[k].querySelector('tr').appendChild(tdnew);
tdnew.firstChild.addEventListener("click", imgblockdialog, false);
} else {
var spannew = document.createElement("span");
spannew.style.marginLeft = '10px';
spannew.innerHTML = '<button type="button" title="Block/Unblock" class="irc_but"><span class="irc_but_t">GHHbD</span></button>';
buttondivs[k].appendChild(spannew);
spannew.firstChild.addEventListener("click", imgblockdialog, false);
}
}
} else {
var abtn = el.querySelectorAll('a[role="button"][href]'); // Google images sidebar 2020-06-20
if (abtn.length > 0 && abtn[0].closest('c-wiz') != null) var alnk = abtn[0].closest('c-wiz').querySelector('a[role="link"][href]');
if (alnk && !alnk.parentNode.hasAttribute('ghhresult')) {
alnk.parentNode.setAttribute('ghhresult', 'image-unset');
var dnew = document.createElement("div");
dnew.classList.add('divGHHbD'); // v2.2.8 update horizontal position for flex layout, move styling to classes
dnew.innerHTML = '<button type="button" title="Block/Unblock" url="' + alnk.href + '" class="imgGHHbD">GHHbD</button>';
alnk.parentNode.insertBefore(dnew, alnk);
dnew.firstChild.addEventListener("click", imgblockdialog, false);
}
}
if (document.querySelectorAll('style.GHHbDcss').length === 0){ // Bing losing styles... 2018-10-01
injectBaseCSS();
doSiteSpecific();
GHHbD_addStyle("#ghhMngBtn {position:fixed;top:150px;right:-2.8em;-moz-transform:rotate(-90deg);-webkit-transform:rotate(-90deg);"+
"border-bottom:0;border-bottom-left-radius:0;border-bottom-right-radius:0;padding:6px 1px;z-index:1000;}");
}
}
var parentcard;
function hidehits(liels,ovrd){
if (!liels){
if (engine == 'Google'){
liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res div._bkWMgd div.g, #res #rso div.g, #res #GTR div.g, #res #isr_mc, g-section-with-header g-scrolling-carousel g-inner-card, g-card div.dbsr, g-card, [data-async-context^=\"query:\"] div.g");
} else {
liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep > div.links_main, div#links > div.nrn-react-div, div#b_content ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.sw-CardBase, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news, #content_left > div.result.c-container, #content_left > div.result-op.c-container, ol.list-flat > li, div.w-gl__result, div.w-gl > div.result, div.w-bg > div.result, div.card-web div.card-mobile, ol.react-results--main > li');
}
if (nws == true) liels = document.querySelectorAll('#res #rso div[class][data-hveid]'); //v2.2.6 for News results under www
if (!liels) return;
}
if (isch && liels.length==0){
liels = document.querySelectorAll('div.rg_di, div.isv-r');
} else if (liels.length==0){
if (engine == 'Google'){
liels = document.querySelectorAll("#res li.g, #res div.srg div.g, #res div._NId div.g, #res div._bkWMgd div.g, #res #rso div.g, #res #GTR div.g, #res #isr_mc, g-section-with-header g-scrolling-carousel g-inner-card, g-card div.dbsr, g-card, [data-async-context^=\"query:\"] div.g");
} else {
liels = document.querySelectorAll('div#results li, div#results > div.result, div#links > div.results_links_deep > div.links_main, div#links > div.nrn-react-div, div#b_content ol > li.b_algo, div#results div#web > ol > li, div#WS2m > div.w, div.sw-CardBase, div.serp-list > div.serp-item, ul.serp-list > li.serp-item, div#main_results > div.result, div.results-column div.result--web, div.results-column div.result--news, #content_left > div.result.c-container, #content_left > div.result-op.c-container, ol.list-flat > li, div.w-gl__result, div.w-gl > div.result, div.w-bg > div.result, div.card-web div.card-mobile, ol.react-results--main > li');
}
}
if (liels.length == 0) return;
if (liels.length == 1){ // Google Standard Image Results
if(liels[0].id == "isr_mc") liels = liels[0].querySelectorAll(".rg_di");
}
var hosts, hiders, nhider, i, j, k, hid, ael, ahref, dom, dompart, btn, apar, dgone, pban, linkwidth;
hosts = blist;
for (i=0; i<liels.length; i++){
if ((liels[i].parentNode.nodeName == "OL" || liels[i].parentNode.nodeName == "TD" ||
liels[i].classList.contains("card-section") || liels[i].classList.contains("ct-cs") || liels[i].classList.contains("w-gl__result") ||
(liels[i].parentNode.nodeName == "DIV" && (liels[i].parentNode.classList.contains("srg") ||
liels[i].parentNode.classList.contains("_NId") || liels[i].parentNode.parentNode.classList.contains("_NId") ||
liels[i].parentNode.classList.contains("bkWMgd") || liels[i].parentNode.parentNode.classList.contains("bkWMgd") ||
liels[i].nodeName === 'G-INNER-CARD' || liels[i].nodeName === 'G-CARD')) ||
(liels[i].parentNode.nodeName == "DIV" && liels[i].closest('#rso, [data-async-context^="query:"]') !== null) ||
(engine != 'Google' && liels[i].parentNode.nodeName == "DIV") ||
(engine == 'Startpage' && liels[i].classList.contains("result")) ||
liels[i].classList.contains('serp-item')) &&
liels[i].className.indexOf("gbt")!=0 &&
liels[i].classList.contains("gplusgrid") === false &&
liels[i].classList.contains("mitem") === false &&
liels[i].classList.contains("kno-kp") === false) {
liels[i].setAttribute("ghhresult","unset");
hiders = liels[i].getElementsByClassName("ghhider");
nhider = hiders.length;
if (nhider == 0 || ovrd == true){ // skip if a button is there
hid = false;
ael = liels[i].querySelector("div.r > a, h3 a, div.rc a"); // first link (not useful for video or book blocks), <h3> preferred
if (!ael || ael.parentNode.className=='deeplink_title') ael = liels[i].querySelector("h2 a, h4 a");
if (!ael) ael = liels[i].querySelector("a");
if (liels[i].classList.contains("videobox")) ael = liels[i].querySelectorAll("td")[1].querySelector("a"); //video page
if (engine == 'Google' && location.search.indexOf('adtest=on') > -1){
ael = liels[i].querySelector('cite');
if(ael){if(!ael.hasAttribute('href')){
if (ael.textContent.indexOf('http://')===-1 && ael.textContent.indexOf('https://')===-1) ael.setAttribute('href', 'http://'+ael.textContent);
else ael.setAttribute('href', ael.textContent);
}}
}
if (engine == 'Baidu'){
if(liels[i].hasAttribute('mu')){
liels[i].insertAdjacentHTML('beforeend', '<span style="display:none"><a class="c-showurl" href="' + liels[i].getAttribute('mu') +'">' + liels[i].getAttribute('mu') + '</a></span>');
}
ael = liels[i].querySelector("a.c-showurl");
if(ael){if(!ael.hasAttribute('href')){
if (ael.textContent.indexOf('http://')===-1 && ael.textContent.indexOf('https://')===-1) ael.setAttribute('href', 'http://'+ael.textContent);
else ael.setAttribute('href', ael.textContent);
}}
}
if (engine == 'Startpage'){
ael = liels[i].querySelector('a.result-link');
}
if (ael){ahref=ael.getAttribute("href"); if(ahref){if (ahref.search(/http|ftp/i)==0 || ahref.indexOf("/interstitial")==0 ||
ahref.indexOf("/url?q=")==0 || ahref.indexOf(currentG+"/url?q=")>-1 || ahref.indexOf("/url?sa=")==0 ||
(ahref.indexOf("/aclk?")==0 && liels[i].classList.contains("psli")) ||
ahref.indexOf("//r.search.yahoo")==0 || ahref.indexOf(currentG+"/link?url=")>-1 ||
ahref.indexOf('/rebates/welcome') === 0){
if (engine == 'Bing'){ // v2.2.7
if (ahref.indexOf('https://www.bing.com/') === 0 || ahref.indexOf('/rebates/welcome') === 0){
var citeEl = liels[i].querySelector('div:not(.b_algo_group) cite');
if (citeEl) ahref = citeEl.textContent.trim();
}
}
dom = ahref.substr(ahref.search(/http|ftp/i));
if (ael.hasAttribute("data-href")) dom = ael.getAttribute("data-href").substr(ael.getAttribute("data-href").indexOf("http"));
if (dom.indexOf(currentG+"/aclk?")>-1) dom = ahref.substr(ahref.indexOf("http", 10));
if (ahref.indexOf("/url?sa=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("&url=")+5));
if (ahref.indexOf("r.search.yahoo.com/_ylt=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("RU=http")+3));
if (dom.indexOf("search.yahoo.co.jp/r/FOR=")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("/**http")+3));
if (dom.indexOf("https://ixquick-proxy.com/do/spg/highlight.pl")>-1) dom = decodeURIComponent(ahref.substr(ahref.indexOf("&u=http")+3));
if (currentG.indexOf("baidu") > -1) dom = '//' + ael.textContent.replace('https://', '').replace('http://', '').replace('....', '');
// if (dom.indexOf("imgrefurl")>-1) dom = dom.match(/imgrefurl=([^&]+)/)[1];
dom = dom.split("/")[2];
if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
dompart = dom;
liels[i].setAttribute("ghhhost",dompart);
while (dompart.indexOf(".")> -1) {
if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck
if (nhider > 0){ // Remove old buttons, notices, etc.
for (k=hiders.length-1; k>=0; k--){
hiders[k].remove();
nhider = liels[i].getElementsByClassName("ghhider").length;
}
}
if (liels[i].classList.contains("ghh1time") === false){
if (hosts.indexOf("|"+dompart+":p")<0) { // Regular block
if (showYN=="Y"){
if (liels[i].classList.contains("results_links_deep")){ // DDG
replaceHit(dompart,ael,liels[i].querySelector(".links_main"),"");
}
else replaceHit(dompart,ael,liels[i],"");
}
else replaceHit(dompart,ael,liels[i],"none");
} else { // Perma-ban
liels[i].setAttribute("blockhidden",dompart);
if (engine != 'Google' && liels[i].classList.contains("ghhdnone") === false){
liels[i].classList.add('ghhdnone');
if (liels[i].classList.contains("links_main")) liels[i].parentNode.classList.add('ghhdnone');
}
}
if (engine == 'DDG' && liels[i].classList.contains("results_links_deep")) kids = liels[i].lastElementChild.children; //DDG
else kids = liels[i].children;
for (j=0; j<kids.length; j++){ // Hide Google result
if (kids[j].classList.contains("ghhider") === false && kids[j].classList.contains("ghhdnone") === false){
kids[j].classList.add('ghhdnone');
}
}
}
if (liels[i].classList.contains("psli")) liels[i].style.padding = "0"; // Shopping results
hid = true;
break;
}
else {
dompart = dompart.slice(dompart.indexOf(".")+1);
if (dompart.indexOf(".") === -1 && dompart != "tld") dompart += '.tld';
}
}
if (hid == false && nhider > 1) { // Remove previous block & reset nhider
if (liels[i].children[0].classList.contains("ghhd")) liels[i].children[0].remove();
// Clean up unblocked one-times
if (liels[i].classList.contains("ghh1time")){
liels[i].classList.remove('ghh1time');
dgone = liels[i].getElementsByClassName("ghhd");
if (dgone.length > 0) dgone[0].remove();
dgone = liels[i].getElementsByClassName("ghhdbuttons");
if (dgone.length > 0) dgone[0].remove();
}
nhider = liels[i].getElementsByClassName("ghhider").length;
}
if (hid == false && (nhider == 0 || liels[i].children[0].nodeName.toLowerCase() == 'g-section-with-header')) { // Not blocked, insert block button
// First, remove hiding for unblocked domains
if (engine == 'DDG' && liels[i].classList.contains("results_links_deep")) kids = liels[i].lastElementChild.children; //DDG
else kids = liels[i].children;
for (j=0; j<kids.length; j++){
if (kids[j].classList.contains("ghhdnone")){
kids[j].classList.remove('ghhdnone');
}
}
if (liels[i].hasAttribute("blockhidden")){
liels[i].removeAttribute("blockhidden");
liels[i].classList.remove('ghhdnone');
if (engine == 'DDG' && liels[i].classList.contains("links_main")) liels[i].parentNode.classList.remove('ghhdnone');
}
if (liels[i].hasAttribute("blocknotice")) liels[i].removeAttribute("blocknotice");
if (liels[i].parentNode.hasAttribute("blocknotice")) liels[i].parentNode.removeAttribute("blocknotice"); //DDG
// Insert block button
apar = ael;
if (engine == 'Google'){
if (location.search.indexOf('adtest=on') > -1){
apar = liels[i].querySelector("h3 a, a");
if (!apar.hasAttribute('hreforiginal')) apar.setAttribute('hreforiginal', ael.getAttribute('href'));
} else {
if (!apar.hasAttribute('hreforiginal')) apar.setAttribute('hreforiginal', apar.href);
}
}
if (engine == 'Baidu'){
apar = liels[i].querySelector("h3 a, .c-result-content a");
if (!apar && liels[i].querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row") != null) apar = liels[i].querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row").firstChild;
}
if (apar != null && !apar.nextElementSibling){
if (apar.parentNode.nodeName != "LI" &&
apar.parentNode.nodeName != "TD" &&
apar.parentNode.nodeName != "H2") apar = apar.parentNode;
}
if (apar != null && apar != undefined) { if (dom.indexOf(currentG)<0 &&
(liels[i].parentNode != document.querySelector("#tads ol")) &&
(liels[i].parentNode != document.querySelector("#bottomads ol")) &&
(liels[i].parentNode != document.querySelector("#ads div")) &&
(liels[i].parentNode != document.querySelector("#rhs ol"))){
btn = document.createElement("button");
btn.appendChild(document.createTextNode(txts.block[0]));
btn.className="ghhider ghhb";
btn.setAttribute("meta",dom);
if (pref1click.substr(0,1) == "Y" && mbstyle.split("-")[4] == "Y"){ //BUG: for 1-click with aggressive (subdomain) settings, dom will be incorrect
if (engine == 'Google') btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form / ALT+click to omit");
else btn.setAttribute("title","Block "+dom+" / SHIFT+click to display block form");
} else if (mbstyle.split("-")[4] == "Y"){
if (engine == 'Google') btn.setAttribute("title","Block "+dom+" / Show block form / ALT+click to omit");
else btn.setAttribute("title","Block "+dom+" / Show block form");
}
btn.addEventListener("click",showbfd,true);
// Position button inside the H2 or H3 or H4
if (apar.nodeName == "H3" || apar.nodeName == "H2" || apar.nodeName == "H4" || engine == 'Startpage'){
apar.style.overflow = "visible";
apar.appendChild(btn);
// full link text tooltip
if (engine == 'Yahoo' && apar.querySelector('a').childNodes[0].nodeName == 'SPAN') apar.querySelector('a').setAttribute("title",apar.querySelector('a').childNodes[1].textContent);
else if (engine == 'Startpage' && apar.nodeName == 'A') {
apar.parentNode.insertBefore(btn, apar.nextSibling);
apar.setAttribute("title",apar.firstElementChild.textContent);
}
else apar.querySelector('a').setAttribute("title",apar.querySelector('a').textContent);
} else if (apar.parentNode.parentNode.nodeName == 'G-CARD'){
apar.parentNode.appendChild(btn);
apar.parentNode.parentNode.style.overflowY = 'visible';
apar.parentNode.parentNode.style.height = 'unset';
apar.parentNode.parentNode.style.position = 'relative';
} else if (apar.parentNode.className == 'dbsr') {
apar.parentNode.appendChild(btn);
parentcard = apar.closest('g-card');
if (parentcard){
parentcard.style.overflowY = 'visible';
parentcard.style.position = 'relative';
}
} else {
if (apar.nextSibling) apar.parentNode.insertBefore(btn,apar.nextSibling);
else apar.parentNode.appendChild(btn);
}
// Move button to citeline 6/10/2013; updated 8/16/2020 to look for action-menu first
if (bbpos == "C") {
var axnmenu = liels[i].querySelector(".action-menu");
var citelines = liels[i].querySelectorAll("cite");
if (axnmenu){ // parentNode is a span
axnmenu.parentNode.insertBefore(btn, axnmenu);
if (citelines.length > 0) axnmenu.parentNode.className = citelines[0].className;
} else {
for (var citenum=0; citenum<citelines.length; citenum++){
if (window.getComputedStyle(citelines[citenum]).visibility != "hidden"){
citelines[citenum].parentNode.appendChild(btn);
btn.removeAttribute("style");
if (engine == 'Google') btn.style.visibility = 'visible';
} else { // add to visibility:hidden element for spacing
citelines[citenum].parentNode.appendChild(btn.cloneNode(true));
if (engine == 'Google') btn.style.visibility = 'hidden';
}
}
// Startpage.com
citelines = liels[i].querySelectorAll('.w-gl__result-url-container');
if (citelines.length > 0){
citelines[0].appendChild(btn);
btn.removeAttribute("style");
}
}
}
// Implement Mouseover Option 6/22/2012
if (bbstyle == "M") {
btn.style.visibility = "hidden";
liels[i].addEventListener("mouseover",togglebbtn,false);
liels[i].addEventListener("mouseout",togglebbtn,false);
}
// Avoid unhiding garbage span 5/25/2012
for (j=0; j<liels[i].children.length; j++){
if (liels[i].children[j].classList.contains("ghhider") === false){
if (liels[i].children[j].style.display=="none") liels[i].children[j].setAttribute("wasdisplaynone","wasdisplaynone");
}
}
}}
}
}}}
}
} else { // Check for and handle Google standard image results - doesn't yet support BASIC image results
if (liels[i].classList.contains("rg_di") || liels[i].classList.contains("isv-r")){
if (!liels[i].hasAttribute("imgblock") || ovrd == true){ // skip if previously processed
liels[i].setAttribute("imgblock", "normal");
ael = liels[i].querySelector('a[href*="."]');
if (ael && ael.href.indexOf('/search?') == -1){
if (ael.getAttribute("href").indexOf("imgrefurl")>-1){ // Site showing the image ("visit page")
dom = decodeURIComponent(ael.href).match(/imgrefurl=([^&]+)/)[1].split("/")[2];
} else if (ael.getAttribute("href").indexOf("imgurl")>-1){ // Site hosting the image ("view image")
dom = decodeURIComponent(ael.href).match(/imgurl=([^&]+)/)[1].split("/")[2];
} else { //sometimes you get a clean URL
dom = ael.getAttribute("href").split("/")[2];
}
if (dom.length > 0){
if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
dompart = dom;
while (dompart.indexOf(".")> -1) {
if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck
if (hosts.indexOf("|"+dompart+":p")<0) { // Regular block
liels[i].setAttribute("imgblock", "regular");
} else { // Perma-ban
liels[i].setAttribute("imgblock", "pban");
}
break;
} else {
dompart = dompart.slice(dompart.indexOf(".")+1);
if (dompart.indexOf(".") === -1 && dompart != "tld") dompart += '.tld';
}
}
}
}
}
var imgshuffle = false; // CHANGE TO TRUE TO TURN ON SHUFFLING (CURRENTLY BROKEN)
if (imgshuffle){
// Standard image results: move p-banned nodes to the end to maintain overall page length (otherwise, autoloading stops)
if (t_gimg) window.clearTimeout(t_gimg);
t_gimg = window.setTimeout(fixImagesLayout, 500);
}
}
}
}
if (!document.getElementById("ghhMngBtn") && mbstyle.split("-")[0] != "blk" && document.getElementById("res")) addMngBtn();
if (document.getElementsByClassName("unbtn").length > 1) undupMngBtn();
if (betatest == "Y" && engine == 'Google'){ // BETA - NEW - v1.5.2
// If there are more than two completely invisible results, modify the query to exclude the first hidden site
var invis = document.querySelectorAll("li[blockhidden]");
if (invis.length >= 3) reQry("+-site:"+invis[0].getAttribute("blockhidden"));
}
}
function fixImagesLayout(){
// BUGGY: REPLACEMENT IMAGES DO NOT LOAD UNTIL YOU TRIGGER A REPAINT (e.g., open/close Find bar, resize window, zoom in then zoom out)
var madeamove = false;
var rgshes = document.querySelectorAll(".rgsh");
var lastdatapg = rgshes[rgshes.length-1].getAttribute("data-pg");
var badimg = document.querySelectorAll('div[imgblock="pban"]');
// TODO: Create setting to let user choose to remove regular blocks, too; temporary workaround: uncomment the following line:
// var badimg = document.querySelectorAll('div[imgblock="pban"],div[imgblock="regular"]');
if (badimg.length > 0){
for (var bi=0; bi<badimg.length; bi++){
if (badimg[bi].hasAttribute("newdatapg")){ // already moved
if (badimg[bi].getAttribute("newdatapg") != lastdatapg){
document.getElementById("rg_s").appendChild(badimg[bi]);
badimg[bi].setAttribute("newdatapg", lastdatapg);
madeamove = true;
}
} else { // first move
document.getElementById("rg_s").appendChild(badimg[bi]);
badimg[bi].setAttribute("newdatapg", lastdatapg);
madeamove = true;
}
}
// Trigger Google's function to re-layout the results neatly
if (madeamove){
var sctag = document.createElement("script");
sctag.setAttribute("type", "text/javascript");
sctag.appendChild(document.createTextNode("google.isr.layoutInit();"));
document.body.appendChild(sctag);
}
}
}
function replaceHit(sdomain,oa,oli,ddis){
var fc, dnew, dset, btn;
fc = oli.querySelector('h3, h2');
if (!fc) fc = oli.firstChild;
if (fc.nodeName=="DIV" && fc.classList.contains("ghhider")) return;
dnew = document.createElement("div");
if (oa.querySelector('h3')){
dnew.appendChild(document.createTextNode(oa.querySelector('h3').textContent+" on "+sdomain));
} else if (nws == true && oa.querySelector('div[role="heading"]')) { //v2.2.6 for News results under www
dnew.appendChild(document.createTextNode(oa.querySelector('div[role="heading"]').textContent+" on "+sdomain));
} else if (oli.nodeName === 'G-INNER-CARD' || oli.nodeName === 'G-CARD' || oli.className === 'dbsr'){
if (oa.children[1]) dnew.appendChild(document.createTextNode(oa.children[1].textContent+" on "+sdomain));
else if (oa.children[0] && oa.children[0].children[1] && oa.children[0].children[1].children[1]) dnew.appendChild(document.createTextNode(oa.children[0].children[1].children[1].textContent+" on "+sdomain));
dnew.style.whiteSpace = 'normal';
} else {
if (engine == 'Yahoo' && oa.childNodes[0].nodeName == 'SPAN') dnew.appendChild(document.createTextNode(oa.childNodes[1].textContent+" on "+sdomain)); //v2.2.1
else dnew.appendChild(document.createTextNode(oa.textContent+" on "+sdomain));
}
dnew.className="ghhider ghhd";
dnew.setAttribute("title","Click to view, unblock or Perma-ban");
dnew.style.display = ddis;
if (ddis == "none"){
oli.setAttribute("blockhidden",sdomain);
if (oli.hasAttribute("blocknotice")) oli.removeAttribute("blocknotice");
} else {
oli.setAttribute("blocknotice",sdomain);
if (oli.hasAttribute("blockhidden")) oli.removeAttribute("blockhidden");
oli.classList.remove('ghhdnone');
if (oli.parentNode.classList.contains("results_links_deep")){
oli.parentNode.setAttribute("blocknotice",sdomain);
if (oli.parentNode.hasAttribute("blockhidden")) oli.parentNode.removeAttribute("blockhidden");
oli.parentNode.classList.remove('ghhdnone');
}
}
dnew.addEventListener("click",reshow,false);
// dnew is disappearing on Bing in Chrome TODO: FIXIT
if (oli.className === 'dbsr'){
parentcard = oa.closest('g-card');
if (parentcard){
parentcard.insertBefore(dnew, parentcard.firstChild);
}
} else {
oli.insertBefore(dnew,oli.firstChild);
}
dset = document.createElement("div");
dset.className = "ghhider ghhindent";
dset.setAttribute("dom",sdomain);
dset.style.display = "none";
btn = document.createElement("button");
btn.appendChild(document.createTextNode(txts.unblock[0]));
btn.className="ghhider";
btn.setAttribute("title","Unblock this site");
btn.style.backgroundColor="#9f6";
btn.addEventListener("click",unblock,false);
dset.appendChild(btn);
btn = document.createElement("button");
btn.appendChild(document.createTextNode(txts.pban[0]));
btn.className="ghhider";
btn.setAttribute("title","Permanently hide this site");
btn.style.backgroundColor="#f66";
btn.addEventListener("click",permban,false);
dset.appendChild(btn);
btn = document.createElement("button");
btn.appendChild(document.createTextNode("close"));
btn.className="ghhider";
btn.setAttribute("title","Re-hide this hit");
btn.style.backgroundColor="#eee";
btn.addEventListener("click",rehide,false);
dset.appendChild(btn);
dnew.appendChild(dset);
if (dnew.parentNode.style.overflow == "hidden" || dnew.parentNode.style.overflowX == "hidden"){
dnew.insertBefore(document.createElement("br"), dnew.firstChild);
}
dset.addEventListener("click",ghhkillevent,false);
if (oli.classList.contains("psli")) dnew.style.margin = "1em 0"; // Shopping results
}
function hidebasic(tbl){ // BASIC IMAGE RESULTS, BETA ONLY, NON-AJAX
var hosts, tds, i, j, k, hid, ael, dom, dompart, btn, apar, dgone;
hosts = blist;
tds = tbl.querySelectorAll("td");
for (i=0; i<tds.length; i++){
ael = tds[i].querySelector("a");
if (ael){if(ael.hasAttribute("href")){if (ael.getAttribute("href").indexOf("imgrefurl=")>-1){
dom = ael.getAttribute("href").substr(ael.getAttribute("href").indexOf("imgrefurl=")+7).split("/")[2];
if (dom.indexOf(":")> -1) dom = dom.substr(0,dom.indexOf(":")); // Strip port number
dompart = dom;
while (dompart.indexOf(".")> -1) {
if (hosts.indexOf("|"+dompart+":")>-1) { // These domains suck; mark the cell for now
if (hosts.indexOf("|"+dompart+":p")>-1 || showYN=="N") tds[i].setAttribute("ghhaction","delete");
else tds[i].setAttribute("ghhaction","notice");
break;
} else {
dompart = dompart.slice(dompart.indexOf(".")+1);
if (dompart.indexOf(".") === -1 && dompart != "tld") dompart += '.tld';
}
}
}}}
}
for (i=0; i<tds.length; i++){
switch (tds[i].getAttribute("ghhaction")){
case "delete":
// TODO implement deletion
tds[i].innerHTML = "delete cell";
break;
case "notice":
// TODO implement clickable notices
tds[i].style.textDecoration = "line-through";
tds[i].style.opacity = "0.3";
break;
default:
// TODO add block button
}
}
}
// == == == Other Functions == == ==
function reshow(e){ // Show hit without unblocking
var liel, ael, dabs, k;
liel = e.target.closest('[ghhresult]');
if (!liel) return;
liel.classList.add('ghh1time');
// Hide notice, move action buttons, then show hit
e.target.style.display="none";
ael = liel.querySelector("div.r > a, h3 a, .c-result-content a");
if (!ael && engine == 'DDG') ael = liel.querySelector('article h2 > a');
if (!ael && engine == 'Baidu' && liel.hasAttribute('mu')) ael = liel.querySelector("p.op_site_domain_title, div.op_generalqa_main.c-row").firstChild;
if (!ael) ael = liel.querySelector("span.tl a"); // summarized news result
if (!ael) ael = liel.querySelector("a"); // other
if (liel.classList.contains("videobox")) ael = liel.querySelectorAll("td")[1].querySelector("a"); //video page
dabs = e.target.firstElementChild;
if (engine != 'Bing'){
if (ael.parentNode.classList.contains('ghh1time')){
ael.parentNode.insertBefore(dabs,ael.nextSibling);
} else {
if (ael.parentNode.parentNode.nodeName === 'G-INNER-CARD' || ael.parentNode.parentNode.nodeName === 'G-CARD') ael.parentNode.parentNode.insertBefore(dabs,ael.parentNode);
else {
if (ael.parentNode.nextSibling) ael.parentNode.parentNode.insertBefore(dabs,ael.parentNode.nextSibling);
else ael.parentNode.parentNode.appendChild(dabs);
}
}
dabs.className = "ghhdbuttons";
dabs.removeAttribute("style");
if (dabs.nextElementSibling) if (dabs.nextElementSibling.className.indexOf("ghhider") == 0 || dabs.nextElementSibling.innerHTML == "block") dabs.parentNode.removeChild(dabs.nextElementSibling);
} else {
// TODO dabs is disappearing on Bing when moved -- temporarily, don't move it
e.target.style.display='';
dabs.className = "ghhdbuttons";
dabs.removeAttribute("style");
}
for (k=1; k<liel.children.length; k++){
liel.children[k].classList.remove('ghhdnone');
}
e.stopPropagation();
}
// Hide or Show hit notices
async function updtpref(e){
var btns, j, hds, s;
if (showYN == "Y"){
if (confirm("No longer show titles or buttons for suppressed results?")){
ghhPrefO.shownotc[0] = "N";
if (!GM4){
GM_setValue("ghhprefs", JSON.stringify(ghhPrefO));
} else {
await GM.setValue("ghhprefs", JSON.stringify(ghhPrefO));
}
showYN = ghhPrefO.shownotc[0];
togHiderDivs("no");
}
} else {
hds = document.getElementsByClassName("ghhd");
if (hds.length > 0) s = (hds.length == 1) ? "is 1 blocked hit" : "are "+hds.length+" blocked hits";
else s = "are no blocked hits";