-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列.js
3176 lines (3046 loc) · 175 KB
/
AC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列.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 AC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列
// @name:en AC-baidu-google_sogou_bing_RedirectRemove_favicon_adaway_TwoLine
// @name:zh AC-baidu-重定向优化百度搜狗谷歌必应搜索_favicon_双列
// @name:ja AC-baidu-重定向最適化Baiduの搜狗のGoogleのBing検索結果のリダイレクト除去+favicon
// @description 1.繞過百度、搜狗、谷歌、好搜搜索結果中的自己的跳轉鏈接,直接訪問原始網頁-反正都能看懂 2.新增自定义网站拦截功能 3添加Favicon显示 4.页面CSS 5.添加计数 6.开关选择以上功能 7.自动翻页功能
// @description:en 1.bypass the redirect link at baidu\sogou\google\haosou; 2.remove ads at baidu; 3.add Favicon for each website; 4.render your own style; 5.counter; 6.Switch to handle all 7.Auto Pager
// @description:ja 1.迂回Baidu、Sogou、Google、Haosou検索検索結果の中の自分の遷移リンク; 2.Baiduの余分な広告を取り除く; 3.コメントを追加; 4.ページのカスタムCSP; 5.カウントを追加; 6.スイッチは以上の機能を選択します; 7.自動ページめくり.
// @icon https://ae01.alicdn.com/kf/Hac1a58055c5047cdb91349e91aa208d5k.jpg
// @author AC
// @license GPL-3.0-only
// @create 2015-11-25
// @run-at document-body
// @version 25.04
// @connect baidu.com
// @connect google.com
// @connect google.com.hk
// @connect google.com.jp
// @connect bing.com
// @connect duckduckgo.com
// @connect dogedoge.com
// @connect so.com
// @include *://ipv6.baidu.com/*
// @include *://www.baidu.com/*
// @include *://www1.baidu.com/*
// @include *://m.baidu.com/*
// @include *://xueshu.baidu.com/s*
// @include *://www.so.com/s?*
// @include *://*.bing.com/*
// @include *://encrypted.google.*/search*
// @include *://*.google*/search*
// @include *://*.google*/webhp*
// @include *://*.zhihu.com/*
// @include *://*duckduckgo.com/*
// @include *://*.dogedoge.com/*
// @exclude *://*.google*/sorry*
// @exclude https://zhidao.baidu.com/*
// @exclude https://*.zhidao.baidu.com/*
// @exclude https://www.baidu.com/img/*
// @supportURL https://ac.tujidu.com/
// @home-url https://greasyfork.org/zh-TW/scripts/14178
// @home-url2 https://github.com/langren1353/GM_script
// @homepageURL https://greasyfork.org/zh-TW/scripts/14178
// @copyright 2015-2020, AC
// @lastmodified 2021-12-06
// @feedback-url https://github.com/langren1353/GM_script
// @note 2022.03-07-V25.04 修复谷歌、必应样式问题;修复并优化拦截功能
// @note 2022.01-29-V25.02 修复谷歌、百度、必应的部分样式错位的问题
// @note 2021.12-06-V25.01 修复百度样式偏左 & 修复谷歌样式显示
// @note 2021.10-31-V24.29 fixed Less requirement for faster Load
// @note 2021.10-29-V24.27 移除必应能选择的广告;增加自定义样式less的支持
// @note 2021.09-02-V24.26 修复必应多favicon,修复百度百科问题;修复谷歌一个小问题
// @note 2021.07-16-V24.25 修复一个bug;兼容百度下搜索股票tag;
// @note 2021.06-15-V24.24 更换cdn地址
// @note 2017.05.12 -> 2021.06-15 && V8.6 -> V24.24 各种各样的历史更新记录,从一个版本迭代到另一个版本
// @note 2017.05.12-V8.4 新增:默认屏蔽谷歌的安全搜索功能
// @note 2017.05.05-V8.3 修复include范围太小导致的百度知道的屏蔽问题
// @note 2017.05.04-V8.2 终于修复了百度知道图片替换了文字的这个大BUG; 顺便处理了superapi.zhidao.baidu.com; 新增谷歌搜索结果重定向去除
// @note 2017.05.04-V8.1 终于修复了百度知道图片替换了文字的这个大BUG,顺便处理了superapi.zhidao.baidu.com
// @note 2017.05.04-V8.0 终于修复了百度知道图片替换了文字的这个大BUG,待测试
// @note 2017.03.28-V7.6 修复在ViolentMonkey上的不支持的问题
// @note 2017.03.28-V7.5 尝试修复chrome上的问题
// @note 2017.03.21-V7.4 尝试处理Edge上不支持的问题,结果发现是Edge本身的TamperMonkey支持有问题
// @note 2017.03.19-V7.3 修复打开百度之后再次点击“百度一下”导致的无法更新重定向问题
// @note 2017.03.19-V7.2 未知原因chrome的MutationObserver无法使用了,继续回归以前的DOMNodeInserted
// @note 2017.02.17-V7.0 修复搜狗的搜索结果重定向问题+改个名字
// @note 2017.02.17-V6.9 修复搜狗的搜索结果重定向问题
// @note 2016.10.27-V6.7 修复了以前的重复请求,现在的请求数应该小了很多,网络也就不卡了,感觉萌萌哒
// @note 2016.04.24-V6.6 恢复以前的版本,因为兼容性问题
// @note 2015.12.01-V5.0 加入搜狗的支持,但是支持不是很好
// @note 2015.11.25-V2.0 优化,已经是真实地址的不再尝试获取
// @note 2015.11.25-V1.0 完成去掉百度重定向的功能
// @resource baiduCommonStyle http://ibaidu.tujidu.com/newcss/baiduCommonStyle.css?t=25.04
// @resource baiduOnePageStyle http://ibaidu.tujidu.com/newcss/baiduOnePageStyle.css?t=25.04
// @resource baiduTwoPageStyle http://ibaidu.tujidu.com/newcss/baiduTwoPageStyle.css?t=25.04
// @resource baiduLiteStyle http://ibaidu.tujidu.com/newcss/baiduLiteStyle.css?t=25.04
// @resource googleCommonStyle http://ibaidu.tujidu.com/newcss/googleCommonStyle.css?t=25.04
// @resource googleOnePageStyle http://ibaidu.tujidu.com/newcss/googleOnePageStyle.css?t=25.04
// @resource googleTwoPageStyle http://ibaidu.tujidu.com/newcss/googleTwoPageStyle.css?t=25.04
// @resource bingCommonStyle http://ibaidu.tujidu.com/newcss/bingCommonStyle.css?t=25.04
// @resource bingOnePageStyle http://ibaidu.tujidu.com/newcss/bingOnePageStyle.css?t=25.04
// @resource bingTwoPageStyle http://ibaidu.tujidu.com/newcss/bingTwoPageStyle.css?t=25.04
// @resource duckCommonStyle http://ibaidu.tujidu.com/newcss/duckCommonStyle.css?t=25.04
// @resource duckOnePageStyle http://ibaidu.tujidu.com/newcss/duckOnePageStyle.css?t=25.04
// @resource duckTwoPageStyle http://ibaidu.tujidu.com/newcss/duckTwoPageStyle.css?t=25.04
// @resource dogeCommonStyle http://ibaidu.tujidu.com/newcss/dogeCommonStyle.css?t=25.04
// @resource dogeOnePageStyle http://ibaidu.tujidu.com/newcss/dogeOnePageStyle.css?t=25.04
// @resource dogeTwoPageStyle http://ibaidu.tujidu.com/newcss/dogeTwoPageStyle.css?t=25.04
// @resource MainHuYanStyle http://ibaidu.tujidu.com/newcss/HuYanStyle.css?t=25.04
// @resource SiteConfigRules http://ibaidu.tujidu.com/newcss/SiteConfigRules.conf?t=25.04
// @require https://cdn.staticfile.org/vue/2.6.14/vue.min.js
// @require https://cdn.staticfile.org/less.js/4.1.2/less.min.js
// @require https://lib.baomitu.com/vue/2.6.14/vue.min.js
// @require https://lib.baomitu.com/less.js/4.1.2/less.min.js
// @require https://greasyfork.org/scripts/130-portable-md5-function/code/Portable%20MD5%20Function.js?version=10066
// @grant GM_getValue
// @grant GM.getValue
// @grant GM_setValue
// @grant GM.setValue
// @grant GM_addStyle
// @grant GM_getResourceURL
// @grant GM_listValues
// @grant GM_getResourceUrl
// @grant GM.getResourceUrl
// @grant GM_xmlhttpRequest
// @grant GM_getResourceText
// @grant GM_registerMenuCommand
// @grant unsafeWindow
// @namespace [email protected]
// ==/UserScript==
// calc(X1(vw) + X2(px)) -> B(px) 使用 http://www.yunsuan.info/matrixcomputations/solvelinearsystems.html 进行计算
!function () {
let isdebug = false;
let isLocalDebug = isdebug || false;
let debug = isdebug ? console.log.bind(console) : () => { }
let acCssLoadFlag = false;
let inExtMode = typeof (isExtension) !== "undefined";
let inGMMode = typeof (GM_info.scriptHandler) !== "undefined"; // = "Greasemonkey" || "Tampermonkey" || "ViolentMonkey"
// 新版本的GreaseMonkey是带有scriptHandler,但是没有GM_getResourceText;旧版本不带scriptHandler,但是有GM_getResourceText
// let isNewGM = typeof(GM_info.scriptHandler) !== "undefined" && GM_info.scriptHandler.toLowerCase() === "greasemonkey";
let isNewGM = false;
// inExtMode & inGMMode
// true true =扩展下的GM代码 不执行
// true false=扩展下代码 执行
// false true =仅GM代码 执行
// false false=异常 但是还是要执行代码
debug("程序开始");
if (inExtMode === true && inGMMode === true || typeof (window.AC666Init) !== 'undefined') {
console.log("扩展模式-脚本不启用");
return;
}
window.AC666Init = true
if (typeof (GM) === "undefined") {
// 这个是ViolentMonkey的支持选项
GM = {};
GM.setValue = GM_setValue;
GM.getValue = GM_getValue;
}
(function () {
debug("程序执行");
let needDisplayNewFun = true; // 本次更新是否有新功能需要展示
if (window.NodeList && !NodeList.prototype.forEach) {
NodeList.prototype.forEach = function (callback, thisArg) {
thisArg = thisArg || window;
for (var i = 0; i < this.length; i++) {
callback.call(thisArg, this[i], i, this);
}
};
}
// let RedirectMap = new Map();
let ACConfig = {};
let DBConfig = {}; // 仅作为普通ACConfig的原始备份,在其他非关键位置时进行保存使用
/*存在对未初始化变量的初始化赋值-无需担心迭代兼容问题*/
let DefaultConfig = {
isRedirectEnable: false, // 是否开启重定向功能
isAdsEnable: false, // 是否开启去广告模式
isAutopage: true, // 是否开启自动翻页功能
isBlockEnable: false, // 是否开启去拦截模式
isBlockDisplay: false, // 是否删除已拦截的条目
isBlockBtnNotDisplay: false, // 是否显示block按钮
AdsStyleEnable: true, // 是否开启自定义样式模式
baidu: {
name: 'baidu', // CSS load 的前缀标志
AdsStyleMode: '1', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-百度
},
google: {
name: 'google',
AdsStyleMode: '3', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-谷歌
},
bing: {
name: 'bing',
AdsStyleMode: '3', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-必应
},
duck: {
name: 'duck',
AdsStyleMode: '3', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-DuckGOGO
},
doge: {
name: 'doge',
AdsStyleMode: '3', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-DuckGOGO
},
sogou: {
name: 'sogou',
AdsStyleMode: '1', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-搜狗
},
zhihu: {
name: 'zhihu',
AdsStyleMode: '0', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-搜狗
},
other: {
name: 'other',
AdsStyleMode: '0', // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
HuYanMode: false, // 护眼模式-搜狗
},
Style_BaiduLite: false, // Baidu_Lite样式表
defaultHuYanColor: "#DEF1EF",
isUserColorEnable: true, // 是否开启favicon图标功能
isFaviconEnable: true, // 是否开启favicon图标功能
defaultFaviconUrl: "https://ae01.alicdn.com/kf/HTB1dRY0X8OD3KVjSZFFq6An9pXay.jpg", // 默认图标地址
doDisableSug: true, // 是否禁止百度搜索预测
isRightDisplayEnable: true, // 是否开启右侧边栏
isCounterEnable: false, // 是否显示计数器
isALineEnable: false, // 是否禁止下划线
isUserStyleEnable: false, // 是否开启自定义样式
normalizeDuck: true, // 是否按照常用习惯去配置DuckDuckGo
acceptLicense: false,
isEnLang: false,
isGooleInBaiduModeEnable: false, // 是否开启谷歌搜索结果页的百度图标显示
UserBlockList: [],
UserStyleText:
`/**计数器的颜色样式*/
div .AC-CounterT{
background: #FD9999;
}
/**百度样式区域**/
body[baidu] {
position: relative;
/**右侧栏的样式-其实不开启更好看一些*/
#content_right{
padding: 20px 15px 15px;
border-radius: 5px;
background-color: #fff;
box-sizing: border-box;
box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);
-webkit-box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);
-moz-box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);
}
&:before{
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
content: '';
background-image: url('https://img.tujidu.com/image/620210010b2cd.jpg');
background-size: 100% auto;
opacity: 0.6; /*背景图透明度=0.8,最大1*/
}
/**隐藏首页的大图标-修复可能导致外援样式异常**/
#s_lg_img_new{
display:none !important;
}
.c-container{
border-radius: 5px;
background-color: rgba(255,255,255, 0.6) !important; /*百度搜索块体的颜色;透明度=0.1,最大1*/
h3{
background-color: rgba(248,248,248, 0.6) !important; /*百度搜索块体 - 标题的颜色;透明度=0.1,最大1*/
}
}
}
body[google] {
&:before {
position: fixed;
width: 100%;
height: 100%;
top: 0;
left: 0;
content: '';
background-image: url('https://img.tujidu.com/image/620210010b2cd.jpg');
background-size: 100% auto;
opacity: 0.8; /*背景图透明度=0.8,最大1*/
}
#rso .g, .sfbg, .f6F9Be, .k8XOCe {
background-color: rgba(248,248,248, 0.6) !important;
}
.sfbg{
margin-top: -10px;
}
.yg51vc{
background-color: transparent !important;
}
}
`,
oldVersion: "",
lastSaveTime: new Date().getTime(),
};
let CONST = {
hasNewFuncNeedDisplay: true,
sortIndex: 1,
isGoogleImageUrl: false,
isGoogleSpecial: false, // 判断是否存在#rso>.g; true=存在
useItem: {},
StyleManger: function () {
},
};
var curSite = {
SiteTypeID: 1, // 当前站点的ID
MainType: "", // 主体节点,很多个的父节点
Stype_Normal: "", // 重定向选择器,只有百度-搜狗-好搜
FaviconType: "", // favicon的域名检查器cite,用于获取host用
FaviconAddTo: "", // favicon选择器,用于插入到title之前的
CounterType: "", // 计数器添加的位置,一般和favicon位置一致
BlockType: "", // 屏蔽按钮的位置,一般在title之后
};
let DBSite = {
baidu: {
SiteTypeID: 1,
MainType: "#content_left .c-container",
Stype_Normal: "h3.t>a, .c-container article a",
FaviconType: ".c-showurl",
FaviconAddTo: "h3",
CounterType: "#content_left>#double>div[srcid] *[class~=t],[class~=op_best_answer_question],#content_left>div[srcid] *[class~=t],[class~=op_best_answer_question]",
BlockType: "h3 a",
pager: {
nextLink: '//div[@id="page"]//a[contains(text(),"下一页")][@href]',
pageElement: "css;div#content_left > *",
HT_insert: ["css;div#content_left", 2],
replaceE: "css;#page",
stylish: ".autopagerize_page_info, div.sp-separator {margin-bottom: 10px !important;}",
}
},
sogou: {
SiteTypeID: 2,
MainType: "#main .results>div",
Stype_Normal: "h3.pt>a, h3.vrTitle>a",
FaviconType: "cite[id*='cacheresult_info_']",
FaviconAddTo: "h3",
CounterType: ".results>div",
BlockType: "h3 a",
pager: {
nextLink: "//div[@id=\"pagebar_container\"]//a[@id=\"sogou_next\"]",
pageElement: "//div[@class=\"results\"]/div",
HT_insert: ["//div[@class=\"results\"]", 2],
replaceE: "id(\"pagebar_container\")"
}
},
haosou: {
SiteTypeID: 3,
MainType: ".res-list",
Stype_Normal: ".res-list h3>a",
FaviconType: "cite",
FaviconAddTo: "h3",
CounterType: ".results>div",
BlockType: "h3 a",
pager: {
nextLink: "//div[@id='page']//a[text()='下一页>'] | id('snext')",
pageElement: "//div[@id='container']/div",
HT_insert: ["//div[@id='container']", 2],
replaceE: "id('page')"
}
},
google: {
SiteTypeID: 4,
MainType: "#rso .g",
FaviconType: ".iUh30",
FaviconAddTo: "h3",
CounterType: "#rso .g h3,._yE>div[class~=_kk] h3",
BlockType: ".rc>.r>a",
pager: {
nextLink: 'id("pnnext") | id("navbar navcnt nav")//td[span]/following-sibling::td[1]/a | id("nn")/parent::a',
pageElement: '//div[@id="res"]',
HT_insert: ["css;#res", 2],
replaceE: '//div[@id="navcnt"] | //div[@id="rcnt"]//div[@role="navigation"]'
}
},
bing: {
SiteTypeID: 5,
MainType: "#b_results>li",
FaviconType: ".b_attribution>cite",
FaviconAddTo: "h2",
CounterType: "#b_results>li[class~=b_ans] h2,#b_results>li[class~=b_algo] h2",
BlockType: "h2 a",
pager: {
nextLink: "//a[contains(@class,\"sb_pagN\")]",
pageElement: "id(\"b_results\")/li[not(contains(@class,\"b_pag\") or contains(@class,\"b_ans b_top\"))]",
HT_insert: ["id(\"b_results\")/li[@class=\"b_pag\"]", 1],
replaceE: "id(\"b_results\")//nav[@role=\"navigation\"]",
}
},
duck: {
SiteTypeID: 10,
MainType: "#links_wrapper #links .results_links_deep",
FaviconType: ".results_links_deep .result__url__domain",
FaviconAddTo: "h2",
CounterType: "#links_wrapper #links .results_links_deep h2",
BlockType: "h2 a",
pager: {
nextLink: "//a[contains(@class,\"sb_pagN\")]",
pageElement: "id(\"b_results\")/li[not(contains(@class,\"b_pag\") or contains(@class,\"b_ans b_top\"))]",
HT_insert: ["id(\"b_results\")/li[@class=\"b_pag\"]", 1],
replaceE: "id(\"b_results\")//nav[@role=\"navigation\"]",
}
},
doge: {
SiteTypeID: 11,
MainType: "#links_wrapper #links .results_links_deep",
FaviconType: ".results_links_deep .result__url__domain",
FaviconAddTo: "h2",
CounterType: "#links_wrapper #links .results_links_deep h2",
BlockType: "h2 a",
pager: {
nextLink: "//a[contains(@class,\"sb_pagN\")]",
pageElement: "id(\"b_results\")/li[not(contains(@class,\"b_pag\") or contains(@class,\"b_ans b_top\"))]",
HT_insert: ["id(\"b_results\")/li[@class=\"b_pag\"]", 1],
replaceE: "id(\"b_results\")//nav[@role=\"navigation\"]",
}
},
mBaidu: {
SiteTypeID: 6,
MainType: "#b_results>li",
FaviconType: ".b_attribution>cite",
FaviconAddTo: "h2",
CounterType: "#b_results>li[class~=b_ans]>h2,#b_results>li[class~=b_algo]>h2,#b_results>li[class~=b_algo]>h2",
BlockType: "h2 a",
},
zhihu: {
SiteTypeID: 7,
},
baidu_xueshu: {
SiteTypeID: 8,
MainType: "#content_left .result",
Stype_Normal: "h3.t>a, #results .c-container>.c-blocka",
FaviconType: ".result-op, .c-showurl", // baidu 似乎要改版了?
FaviconAddTo: "h3",
CounterType: "#content_left>#double>div[srcid] *[class~=t],[class~=op_best_answer_question],#content_left>div[srcid] *[class~=t],[class~=op_best_answer_question]",
BlockType: "h3 a",
},
other: {
SiteTypeID: 9,
}
};
let SiteType = {
BAIDU: DBSite.baidu.SiteTypeID,
MBAIDU: DBSite.mBaidu.SiteTypeID,
SOGOU: DBSite.sogou.SiteTypeID,
SO: DBSite.haosou.SiteTypeID,
GOOGLE: DBSite.google.SiteTypeID,
BING: DBSite.bing.SiteTypeID,
DUCK: DBSite.duck.SiteTypeID,
DOGE: DBSite.doge.SiteTypeID,
ZHIHU: DBSite.zhihu.SiteTypeID,
BAIDU_XUESHU: DBSite.baidu_xueshu.SiteTypeID,
OTHERS: 8
};
let otherData = {
other: {
curTab: 1, // 展示第二panel
showBlockListArea: false, // blockList展示位textarea
addBlockItem: "", // 用户手动输入的拦截规则
curHosts: [], // 存放已经访问的hosts数据内容
isBlockChecking: false, // 当前Block功能是否还在执行中,避免多次执行,导致页面卡顿
}
}; // 到时候挂载到other上
let AllData = {
ACConfig: {},
other: otherData.other,
CONST: CONST,
lan: {
use: {},
zh_cn: {
menu_text: "自定义",
curLang: "zh_cn",
fieldset_panel: {
panel_title: "AC-重定向设置 " + GM_info.script.version + (inExtMode ? 'Ext' : ''),
setting_panel: {
redirect_text: "主功能-重定向功能",
redirect_title: "重定向功能的开启与否",
useEn_text: "En-Language",
useEn_title: "Using English language to display",
ads_text: "附加1-去广告功能",
ads_title: "去除部分页面的广告信息,还你一个干净整洁的页面",
autopage_text: "自动翻页",
autopage_title: "自动翻页",
blockenable_text: "附加2-自主拦截域名",
blockenable_title: "点击页面block按钮添加你想要隐藏的地址,脚本将自动隐藏部分结果为小横幅,DIY按钮中点击表格内容可以取消隐藏",
blockDiyBtn_text: "DIY",
blockDiyBtn_title: "自定义BLOCK",
blockAutoRemove_text: "隐藏结果",
blockAutoRemove_title: "自动隐藏已经屏蔽的域名",
blockBtnShow_text: "隐藏'block'按钮",
blockBtnShow_title: "隐藏掉block按钮的显示",
userStyle_text: "附加3-自定义样式",
userStyle_baidu_lable: "展开百度设置>>",
userStyle_baidu_origin: "百度-原始模式",
userStyle_baidu_huyan: "百度-护眼模式",
userStyle_baidu_baiduLite: "百度Lite样式",
userStyle_baidu_1line: "单列",
userStyle_baidu_1line_enter: "单列居中",
userStyle_baidu_2line: "双列",
userStyle_baidu_3line: "三列",
userStyle_baidu_4line: "四列",
userStyle_google_lable: "展开谷歌设置>>",
userStyle_google_origin: "谷歌-原始模式",
userStyle_google_huyan: "谷歌-护眼模式",
userStyle_google_googleLite: "谷歌-伪装百度",
userStyle_google_1line: "单列",
userStyle_google_1line_enter: "单列居中",
userStyle_google_2line: "双列",
userStyle_google_3line: "三列",
userStyle_google_4line: "四列",
userStyle_bing_lable: "展开必应设置>>",
userStyle_bing_origin: "必应-原始模式",
userStyle_bing_huyan: "必应-护眼模式",
userStyle_bing_1line: "单列",
userStyle_bing_1line_enter: "单列居中",
userStyle_bing_2line: "双列",
userStyle_bing_3line: "三列",
userStyle_bing_4line: "四列",
userStyle_sogou_lable: "展开搜狗设置>>",
userStyle_sogou_origin: "搜狗-原始模式",
userStyle_sogou_huyan: "搜狗-护眼模式",
userStyle_sogou_1line: "单列",
userStyle_sogou_1line_enter: "单列居中",
userStyle_sogou_2line: "双列",
userStyle_sogou_3line: "三列",
userStyle_sogou_4line: "四列",
userStyle_duck_lable: "展开鸭鸭搜设置>>",
userStyle_duck_origin: "鸭鸭-原始模式",
userStyle_duck_huyan: "鸭鸭-护眼模式",
userStyle_duck_normal: "鸭鸭-常见配置",
userStyle_duck_1line: "单列",
userStyle_duck_1line_enter: "单列居中",
userStyle_duck_2line: "双列",
userStyle_duck_3line: "三列",
userStyle_duck_4line: "四列",
userStyle_doge_lable: "展开多吉设置>>",
userStyle_doge_origin: "多吉-原始模式",
userStyle_doge_huyan: "多吉-护眼模式",
userStyle_doge_normal: "多吉-常见配置",
userStyle_doge_1line: "单列",
userStyle_doge_1line_enter: "单列居中",
userStyle_doge_2line: "双列",
userStyle_doge_3line: "三列",
userStyle_doge_4line: "四列",
huyanMode_text: "附加4-护眼颜色配置-自定义3中需对应开启",
huyanMode_title: "!需要在自定义样式中启用护眼模式",
huyanColor_text: "默认护眼颜色:",
huyanColor_title: "自定义的护眼颜色:",
huyanColorMore_text: "更多颜色选择",
favicon_text: "附加5-Favicon功能",
favicon_title: "AC-添加Favicon",
favicon_defaultIcon_text: "Favicon默认图标:",
searchOrigin_text: "附加6-移除百度搜索预测(文字自动搜索)",
searchOrigin_title: "AC-移除搜索预测",
showRight_text: "附加7-显示右侧栏",
showCounter_text: "附加8-编号功能",
hintShowCounter_text: "可能会导致图片加载异常",
showALine_text: "附加9-文字下划线",
showUserStyle_text: "附加10-自定义样式 支持Less.js",
contactMe_text: "联系作者,提建议,寻求帮助,自定义样式,脚本定制点我",
contactMe_url: "https://github.com/langren1353/GM_script",
setting_panel_second: {
backBtn_text: "<-返回",
blockLabel_text: " 拦截列表 想要生效的话需要手动保存",
blockEditBtn_text: "编辑列表",
blockEditBtnEnd_text: "结束编辑",
addBlockLabel_text: "全匹配拦截:",
addBtnLabel_text: "添加",
},
cancelBtn_text: "取消",
okBtn_text: "保存",
resetBtn_text: "重置",
}
}
},
en: {
menu_text: "CUSTOM",
curLang: "en",
fieldset_panel: {
panel_title: "AC Redirect Settings " + GM_info.script.version + (inExtMode ? 'Ext' : ''),
setting_panel: {
redirect_text: "Main-RedirectFunc",
redirect_title: "Turn on or off redirect",
useEn_text: "En-Language",
useEn_title: "使用英文显示页面",
ads_text: "Add1-Remove Ads",
ads_title: "Remove the ads on the page, and return you a clean page",
autopage_text: "Auto Pager",
autopage_title: "Auto Pager",
blockenable_text: "Add2-Block host",
blockenable_title: "Click the Block button to add the address which you want to hide. The script will hide it with small banner automatically. DIY button for editting the hiding list",
blockDiyBtn_text: "DIY",
blockDiyBtn_title: "Edit BLOCK",
blockAutoRemove_text: "Auto remove",
blockAutoRemove_title: "remove the block results automatically",
blockBtnShow_text: "Hide 'Block' button",
blockBtnShow_title: "Hide 'Block' button",
userStyle_text: "Add3-CustomStyle",
userStyle_baidu_lable: "Expand Baidu Settings>>",
userStyle_baidu_origin: "Baidu-Origin",
userStyle_baidu_huyan: "Baidu-EyeSave",
userStyle_baidu_baiduLite: "BaiduLiteStyle",
userStyle_baidu_1line: "SingleRow",
userStyle_baidu_1line_enter: "SingleCenter",
userStyle_baidu_2line: "Two",
userStyle_baidu_3line: "Three",
userStyle_baidu_4line: "Four",
userStyle_google_lable: "Expand Google Settings>>",
userStyle_google_origin: "Google-Origin",
userStyle_google_huyan: "Google-EyeSave",
userStyle_google_googleLite: "Fake Baidu",
userStyle_google_1line: "SingleRow",
userStyle_google_1line_enter: "SingleCenter",
userStyle_google_2line: "Two",
userStyle_google_3line: "Three",
userStyle_google_4line: "Four",
userStyle_bing_lable: "Expand Bing Settings>>",
userStyle_bing_origin: "Bing-Origin",
userStyle_bing_huyan: "Bing-EyeSave",
userStyle_bing_1line: "SingleRow",
userStyle_bing_1line_enter: "SingleCenter",
userStyle_bing_2line: "Two",
userStyle_bing_3line: "Three",
userStyle_bing_4line: "Four",
userStyle_sogou_lable: "Expand SoGou Settings>>",
userStyle_sogou_origin: "SoGou-Origin",
userStyle_sogou_huyan: "SoGou-EyeSave",
userStyle_sogou_1line: "SingleRow",
userStyle_sogou_1line_enter: "SingleCenter",
userStyle_sogou_2line: "Two",
userStyle_sogou_3line: "Three",
userStyle_sogou_4line: "Four",
userStyle_duck_lable: "Expand DuckDuckGo Settings>>",
userStyle_duck_origin: "DuckDuck-Origin",
userStyle_duck_huyan: "DuckDuck-EyeSave",
userStyle_duck_normal: "DuckDuck-Normal",
userStyle_duck_1line: "SingleRow",
userStyle_duck_1line_enter: "SingleCenter",
userStyle_duck_2line: "Two",
userStyle_duck_3line: "Three",
userStyle_duck_4line: "Four",
userStyle_doge_lable: "Expand DogeDoge Settings>>",
userStyle_doge_origin: "DogeDoge-Origin",
userStyle_doge_huyan: "DogeDoge-EyeSave",
userStyle_doge_normal: "DogeDoge-Normal",
userStyle_doge_1line: "SingleRow",
userStyle_doge_1line_enter: "SingleCenter",
userStyle_doge_2line: "Two",
userStyle_doge_3line: "Three",
userStyle_doge_4line: "Four",
huyanMode_text: "Add4-EyeSave Color Setting-Need opened in Add3",
huyanMode_title: "!Open EyeSave Mode in CustomStyle is Must",
huyanColor_text: "Default EyeSave Color:",
huyanColor_title: "The color of EyeSave:",
huyanColorMore_text: "More Color",
favicon_text: "Add5-Favicon.Func",
favicon_title: "AC-AddFavicon",
favicon_defaultIcon_text: "FaviconFailedImg::",
searchOrigin_text: "AC-Remove Baidu AutoPredict in text search",
searchOrigin_title: "Add6-Remove Baidu AutoPredict in text search",
showRight_text: "Add7-Right Side Column",
showCounter_text: "Add8-NumFunc",
hintShowCounter_text: "May Cause image load problem",
showALine_text: "Add9-TextUnderLine",
showUserStyle_text: "Add10-Your own Style support Less.js",
contactMe_text: "For contact the writter, suggests, ask for help then click me",
contactMe_url: "https://github.com/langren1353/GM_script/",
setting_panel_second: {
backBtn_text: "<-Back",
blockLabel_text: " Block List Click Save Button if you want wo save the list",
blockEditBtn_text: "Edit List",
blockEditBtnEnd_text: "End Edit",
addBlockLabel_text: "Add Block item:",
addBtnLabel_text: "Add",
},
cancelBtn_text: "Cancel",
okBtn_text: "Save",
resetBtn_text: "Reset",
}
}
}
}
};
let vueVM = null;
/**初始化所有的设置**/
Promise.all([GM.getValue("Config")]).then(function (data) {
let res = data[0]
if (res != null) {
try {
ACConfig = JSON.parse(res);
} catch (e) {
ACConfig = res;
}
} else {
ACConfig = DefaultConfig;
}
const localData = localStorage.ACConfig; // 小心隐私模式
if (localData && localData.length > 0) {
ACConfig = JSON.parse(localData);
}
for (var key in DefaultConfig) {
if (typeof (ACConfig[key]) === "undefined") {
ACConfig[key] = DefaultConfig[key];
}
}
if (ACConfig.isUserStyleEnable === false && (new Date().getTime() - ACConfig.lastSaveTime > 2592000000)) { // 大约30天时间
// 如果用户取消了设置,并且长时间(30天)没有进行过处理,那么直接将数据置空 -> 用于刷新数据
console.log("ac-baidu css reset for time");
ACConfig.lastSaveTime = new Date().getTime();
ACConfig.UserStyleText = DefaultConfig.UserStyleText;
}
AllData.ACConfig = ACConfig;
DBConfig = JSON.parse(JSON.stringify(ACConfig)); // 暂时作为一个原始保存
AllData.lan.use = ACConfig.isEnLang ? AllData.lan.en : AllData.lan.zh_cn;
// 初始化完成之后才能调用正常函数
callback();
}).catch(function (except) {
console.log(except);
});
function Reg_Get(HTML, reg) {
let RegE = new RegExp(reg);
try {
return RegE.exec(HTML)[1];
} catch (e) {
return "";
}
}
function ACSetValue(key, value) {
GM_setValue(key, value);
if (key === 'Config') {
localStorage.ACConfig = value;
}
}
function getElementByXpath(e, t, r) {
r = r || document, t = t || r;
try {
return r.evaluate(e, t, null, XPathResult.FIRST_ORDERED_NODE_TYPE, null).singleNodeValue;
} catch (t) {
return void console.error("无效的xpath");
}
}
function getAllElements(e, t, r, n, o) {
let getAllElementsByXpath = function (e, t, r) {
return r = r || document, t = t || r, r.evaluate(e, t, null, XPathResult.ORDERED_NODE_SNAPSHOT_TYPE, null);
}
var i, s = [];
if (!e) return s;
if (r = r || document, n = n || window, o = o || void 0, t = t || r, "string" === typeof e) i = 0 === e.search(/^css;/i) ? function getAllElementsByCSS(e, t) {
return (t || document).querySelectorAll(e);
}(e.slice(4), t) : getAllElementsByXpath(e, t, r); else {
if (!(i = e(r, n, o))) return s;
if (i.nodeType) return s[0] = i, s;
}
return function makeArray(e) {
var t, r, n, o = [];
if (e.pop) {
for (t = 0, r = e.length; t < r; t++) (n = e[t]) && (n.nodeType ? o.push(n) : o = o.concat(makeArray(n)));
return a()(o);
}
if (e.item) {
for (t = e.length; t;) o[--t] = e[t];
return o;
}
if (e.iterateNext) {
for (t = e.snapshotLength; t;) o[--t] = e.snapshotItem(t);
return o;
}
}(i);
}
const throttle = (callback, wait = 100) => {
let it = 0
let preT = 0
return function (...args) {
const nowT = + new Date()
if (nowT - preT > wait) {
preT = nowT
clearTimeout(it)
it = setTimeout(() => {
callback.apply(this, args)
clearTimeout(it)
}, wait)
}
}
}
function callback() {
if (ACConfig.oldVersion === GM_info.script.version) {
CONST.hasNewFuncNeedDisplay = false;
} else {
CONST.hasNewFuncNeedDisplay = needDisplayNewFun;
}
!function () {
/**
* 进行不重复插入,插入后执行回调函数
* @param data 待插入数据
* @param callback 回调函数
*/
function acpush(data, callback) {
// 如果是垃圾数据,那么可以丢弃的
if (!data) return;
// 如果数据中有回车,那数据也是无效的正文而已
if (data.replace(/({|}|,|\+|:|。|\n)/) !== data) return;
if (this.findIndex(m => m === data) < 0) {
this.push(data);
callback && callback(this);
}
}
function acremove(data, callback) {
let delId = this.findIndex(m => m === data);
if (delId >= 0) {
this.splice(delId, 1);
callback && callback(this);
} // 删除delId的数据,删除一个
}
// 避免污染全局原型链
Object.defineProperty(ACConfig.UserBlockList, 'acpush', { value: acpush })
Object.defineProperty(ACConfig.UserBlockList, 'acremove', { value: acremove })
Object.defineProperty(otherData.other.curHosts, 'acpush', { value: acpush })
Object.defineProperty(otherData.other.curHosts, 'acremove', { value: acremove })
}();
!function () {
let insertLocked = false;
if (typeof GM_getResourceText === 'undefined') {
GM.getResourceText = GM_getResourceText = async function (aResourceName) {
let res = await (await fetch(await GM.getResourceUrl(aResourceName))).text();
let saveRes = await GM.getValue(aResourceName);
if (typeof (saveRes) === 'undefined') {
GM.setValue(aResourceName, res);
} else {
return saveRes;
}
return res;
}
}
if (GM_getResourceText) {
// 仅在支持GM_getResourceText的容器上进行动态数据更新
// 且能防止谷歌百度页面规则大变动又需要更新脚本 - 特别是涉及翻页参数
let config = GM_getResourceText("SiteConfigRules");
eval(config);
if (typeof (onlineDB) === "undefined") {
console.error("线上数据为空");
} else {
DBSite = onlineDB;
}
}
if (location.host.includes("xueshu.baidu.com")) {
curSite = DBSite.baidu_xueshu;
} else if (location.host.includes(".baidu.com")) {
if (navigator.userAgent.replace(/(android|mobile|iphone)/igm, "") !== navigator.userAgent) {
curSite = DBSite.mBaidu;
} else {
curSite = DBSite.baidu;
}
CONST.useItem = ACConfig.baidu;
} else if (location.host.includes("zhihu.com")) {
curSite = DBSite.zhihu;
CONST.useItem = ACConfig.zhihu;
} else if (location.host.includes("sogou")) {
curSite = DBSite.sogou;
CONST.useItem = ACConfig.sogou;
} else if (location.host.includes("so.com")) {
curSite = DBSite.haosou;
CONST.useItem = ACConfig.other;
} else if (location.host.includes("google")) {
curSite = DBSite.google;
CONST.useItem = ACConfig.google;
} else if (location.host.includes("bing")) {
curSite = DBSite.bing;
CONST.useItem = ACConfig.bing;
} else if (location.host.includes("duckduckgo")) {
curSite = DBSite.duck;
CONST.useItem = ACConfig.duck;
} else if (location.host.includes("dogedoge")) {
curSite = DBSite.doge;
CONST.useItem = ACConfig.doge;
} else {
curSite = DBSite.other;
CONST.useItem = ACConfig.other;
}
curSite.pageNum = 1; // 当前页数
curSite.pageLoading = false;
curSite.pageUrl = "";
if (
(curSite.SiteTypeID === SiteType.GOOGLE && location.href.replace(/tbm=(isch|lcl|shop|flm)/, "") !== location.href) ||
(curSite.SiteTypeID === SiteType.BING && location.href.replace(/images\/search/, "") !== location.href)
) {
// 图片站 、地图站、购物站
console.log("特殊站,不加载样式,不添加menu");
CONST.isGoogleImageUrl = true;
}
if (curSite.SiteTypeID === SiteType.BAIDU_XUESHU) {
CONST.useItem.AdsStyleMode = 2; // 单列居中即可
}
if (ACConfig.AdsStyleEnable) {
CONST.StyleManger = FSBaidu(); // 添加设置项-单双列显示
}
console.log("%c[AC-Redirect] %cLet Me Introduce you a Very Good Search Engine:%c %s %cSearch Engine.", "font-weight:bold;color:cornflowerblue", "color:0", "font-weight:bold;color:darkorange", CONST.useItem.name.replace(CONST.useItem.name[0], CONST.useItem.name[0].toUpperCase()), "font-weight:normal;color:0");
let SiteBlock = {
/**
* 初始化Block样式
*/
initStyle: function () {
AC_addStyle("button.ghhider.ghhb[ac-user-alter='1']::before{content:'取消 - ';}#sp-ac-container .ac-block-item{color:#AAA;margin-left:48px;}#sp-ac-container .ac-block-itemdel{float:right;margin-left:0;padding:0 20px;cursor:pointer;}#sp-ac-container .ac-block-itemdel:hover{color:red;}#sp-ac-container .ac-block-high{color:#000;}.ac-blockList li:hover{background-color:#a3caff;color:white !important;cursor:pointer;} *[ac-needhide] *{display:none} *[ac-needhide] .blockShow{display:unset;cursor:pointer;} *[ac-needhide] .blockShow:hover{border:1px solid #DDD}button.ghhider{color:#555;background-color:#fcfcfc;font-family:sans-serif;margin:auto 2px;border:1px solid #ccc;border-radius:4px;padding:2px 3px}button.ghhider{font-size:12px}button.ghhider:hover{color:#006aff;background:#fff}",
"AC-BlockStyle");
},
/**
* 初始化屏蔽按钮加载
*/
init: function () {
let checkNodes = document.querySelectorAll(curSite.MainType + ":not([acblock])");
for (let i = 0; i < checkNodes.length; i++) {
try {
let curNode = checkNodes[i];
let faviconNode = curNode.querySelector(curSite.FaviconType);
// if(curNode.hasAttribute("acblock")) continue;
let host = getNodeHost(faviconNode).curHost;
// if(host === null) continue;
let faNode = curNode.querySelector(curSite.BlockType);
let nodeStyle = "display:unset;";
if (ACConfig.isBlockBtnNotDisplay) {
nodeStyle = "display:none;";
}
faNode.insertAdjacentHTML("afterend", `<button style='${nodeStyle}' class='ghhider ghhb' href="${faviconNode.href || faviconNode.innerText}" meta="${host}" data-host="${host}" title='${this.getBlockBtnTitle(host)}'>block</button>`);
curNode.setAttribute("acblock", "0");
curNode.setAttribute("acblock", "0");
} catch (e) {
}
}
this.initListener();
this.renderDisplay();
},
getBlockBtnTitle(host) {
return `点击即可屏蔽 ${host} 放开,需要在自定义中手动配置放开`;
},
initListener: function () {
let checkNodes = document.querySelectorAll("button.ghhider:not([acEnv])");
for (let i = 0; i < checkNodes.length; i++) {
checkNodes[i].addEventListener("click", this.doHideEnv);
checkNodes[i].setAttribute("acEnv", "0");
}
},
doHideEnv: function (env) {
// 先插入数据---记得还要写入存储
let node = env.sourceTarget || env.target;
let host = node.dataset.host;
if (+node.getAttribute("ac-user-alter") === 1) {
// 已经屏蔽之后,再次点击block应该是取消状态
node.removeAttribute("ac-user-alter");
ACConfig.UserBlockList.acremove(host);
} else {
// 正常屏蔽操作
node.removeAttribute("ac-user-alter");
ACConfig.UserBlockList.acpush(host);
}
DBConfig.UserBlockList = ACConfig.UserBlockList;
ACSetValue("Config", JSON.stringify(DBConfig)); // 点击一次,保存一次
env.stopPropagation();
},