AC-baidu:重定向优化百度搜狗谷歌搜索_去广告_favicon_双列

1.繞過百度、搜狗、谷歌、好搜搜索結果中的自己的跳轉鏈接,直接訪問原始網頁-反正都能看懂 2.去除百度的多余广告 3.添加Favicon显示 4.页面CSS 5.添加计数 6.开关选择以上功能

目前為 2018-12-22 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name AC-baidu:重定向优化百度搜狗谷歌搜索_去广告_favicon_双列
  3. // @name:en AC-baidu:google_sogou_RedirectRemove_favicon_adaway_TwoLine
  4. // @name:zh AC-baidu:重定向优化百度搜狗谷歌搜索_去广告_favicon_双列
  5. // @name:zh-CN AC-baidu:重定向优化百度搜狗谷歌搜索_去广告_favicon_双列
  6. // @name:ja AC-baidu:重定向最適化Baiduの搜狗Google検索結果のリダイレクト除去+に広告_favicon
  7. // @description 1.繞過百度、搜狗、谷歌、好搜搜索結果中的自己的跳轉鏈接,直接訪問原始網頁-反正都能看懂 2.去除百度的多余广告 3.添加Favicon显示 4.页面CSS 5.添加计数 6.开关选择以上功能
  8. // @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; Switch to handle all
  9. // @description:ja 1.迂回Baidu、Sogou、Google、Haosou検索検索結果の中の自分の遷移リンク; 2.Baiduの余分な広告を取り除く; 3.コメントを追加; 4.ページのカスタムCSP; 5.カウントを追加; 6.スイッチは以上の機能を選択します。
  10. // @icon https://coding.net/u/zb227/p/zbImg/git/raw/master/img0/icon.jpg
  11. // @author AC
  12. // @license GNU GPL v3
  13. // @create 2015-11-25
  14. // @run-at document-start
  15. // @version 22.03
  16. // @connect www.baidu.com
  17. // @include *://www.baidu.com/*
  18. // @include *://xueshu.baidu.com/*
  19. // @include *://www.sogou.com/web*
  20. // @include *://www.sogou.com/sie*
  21. // @include *://www.so.com/s?*
  22. // @include *://*.bing.com/*
  23. // @include *://encrypted.google.*/search*
  24. // @include *://*.google*/search*
  25. // @include *://*.zhihu.com/*
  26. // @namespace 1353464539@qq.com
  27. // @supportURL https://qm.qq.com/cgi-bin/qm/qr?k=fOg8ij6TuwOAfS8g16GRYNf5YYFu5Crw&jump_from=&auth=-l05paasrPe5zigt5ahdzn_dzXiB1jJ_
  28. // @home-url https://gf.qytechs.cn/zh-TW/scripts/14178
  29. // @home-url2 https://github.com/langren1353/GM_script
  30. // @copyright 2017, AC
  31. // @lastmodified 2018-12-20
  32. // @feedback-url https://qm.qq.com/cgi-bin/qm/qr?k=fOg8ij6TuwOAfS8g16GRYNf5YYFu5Crw&jump_from=&auth=-l05paasrPe5zigt5ahdzn_dzXiB1jJ_
  33. // @note 2018.12.22-V22.03 修复edge的样式错乱问题 && 修复谷歌双列样式问题 && 修复百度顶部大空白的问题 && 修复支持DarkReader
  34. // @note 2018.12.20-V22.02 修复样式加载 && 修复护眼模式效果
  35. // @note 2018.12.20-V22.01 更换样式表插入模式,尽量避免闪烁问题; 修复edge上该模式的兼容问题
  36. // @note 2018.12.19-V21.15 修复上次更新导致的护眼模式失效的问题
  37. // @note 2018.12.19-V21.14 修复在edge上样式没有生效的问题
  38. // @note 2018.12.19-V21.13 修复上次更新代码忘记修改导致的bug,修复百度移动预测的遗留bug
  39. // @note 2018.12.18-V21.12 继续加快移除广告的内容,尽量减少闪烁的情况;吐槽一下,百度的广告是越来越烦了
  40. // @note 2018.12.18-V21.11 修复在特殊情况下的样式表没有生效的问题,同时能够更快速的移除广告内容
  41. // @note 2018.12.18-V21.10 修复特殊关键内容搜索下,由于移除广告导致的页面顶部特殊标记显示不正确的问题。
  42. // @note 2018.12.18-V21.9 再次优化样式表加载速度,能更好的更快速的加载样式而不影响代码运行
  43. // @note 2018.12.08-V21.8 修复srcElement在firefox旧版本上不支持的问题
  44. // @note 2018.12.07-V21.7 修复护眼色的引入;修复GM小于4.0版本的兼容问题;优化选项的位置,避免过长
  45. // @note 2018.12.06-V21.6 感谢Mooncan对谷歌样式调整的建议,已经采用了该样式,效果特别好; 同时修复了谷歌右侧栏的位置问题
  46. // @note 2018.12.06-V21.5 P_P修复上一版没有测试导致的支持ViolentMonkey但是有不支持GreaseMonkey的问题;更换css地址;修复护眼色在百度上的部分样式问题
  47. // @note 2018.12.06-V21.4 修复ViolentMonkey的支持;至此已经完全支持三只猴子(TamperMonkey、ViolentMonkey、GreaseMonkey)了;如果还有BUG-直接加群反馈
  48. // @note 2018.12.06-V21.3 修复在edge上样式错乱的问题 && 修复宽度过宽的问题
  49. // @note 2018.12.05-V21.2 移除默认的护眼模式。。。
  50. // @note 2018.12.05-V21.1 修复GreaseMonkey不支持GM_getResourceText导致的样式无法引入的问题,使用自己的服务器中转
  51. // @note 2018.12.05-V21.0 新增必应单列、双列、多列展示;新增护眼模式,各种颜色自定义设置;修复谷歌已浏览的网址未变色问题;优化一定的资源占用
  52. // @note 2018.10.18-V20.5 修复由于谷歌更新导致的样式问题
  53. // @note 2018.10.08-V20.4 修复由于去广告导致的卡顿问题 & 重写favicon添加的位置元素-减少错位产生
  54. // @note 2018.10.03-V20.3 国庆无事,刷版本; 修复在侧边栏开启需要在1920的分辨率下的问题,默认关闭侧边栏的样式操作,如果需要开启的话,在自定义样式中设置开启即可,增加三列|四列模式
  55. // @note 2018.10.01-V20.2 修复拦截广告过多导致的页面显示问题-有些正常地址也被拦截了->似乎发现不是这个脚本的bug;那就刷个版本吧,正好处理下样式缓存问题 & 大家国庆节快乐
  56. // @note 2018.09.21-V20.1 修复在ViolentMonkey的兼容问题 && 样式加载缓慢的问题
  57. // @note 2018.09.21-V20.0 修复闪烁频繁的问题;修复由于扩展和脚本模式两个CSS同时加载导致的问题;新增点击任意位置关闭设置按钮;修复在bing上的计数器位置错误;调整页面单页的样式,这次是真的居中了
  58. // @note 2018.09.19-V19.8 修复TamperMonkey和扩展模式下的兼容问题
  59. // @note 2018.09.19-V19.7 分离去广告功能和自定义样式功能
  60. // @note 2018.09.18-V19.6 修复由于infinity扩展的地址导致的百度样式没有载入的问题;修复万年bug之搜索预测无效的问题
  61. // @note 2018.09.18-V19.5 新增支持扩展模式-推荐使用扩展;修复谷歌地图页面的载入问题;配置脚本GPL协议;支持旧版本的chrome上的自定义显示结果却在最底部的问题-无法解决旧版本chrome上双列的问题
  62. // @note 2018.08.31-V19.4 修复1.google页面中计数器Counter在账号登录(不可用)后的显示错位问题; 2.排除掉百度可能存在的error情况的地址; 3.更换css样式地址,我的CDN流量撑不住了
  63. // @note 2018.08.24-V19.3 修复谷歌图片在单列模式下的错位问题
  64. // @note 2018.08.17-V19.2 修复谷歌和百度的部分样式问题
  65. // @note 2018.08.16-V19.1 继续修复谷歌和百度双列的问题,这次尽量采用css样式表来调整,感觉效果还可以
  66. // @note 2018.08.14-V18.9 修复谷歌双列的翻页错位的问题; 百度搜索结果的阴影模式; 高分屏等我找到一台高分的显示器再说吧
  67. // @note 2018.08.11-V18.8 紧急-修复更新规则导致的谷歌失效的问题
  68. // @note 2018.08.10-V18.7 推荐升级:修改生效规则,尽量避免弹出提示更新窗口;修复-chrome4x版本的bug;预计下次更新处理高分屏显示界面问题
  69. // @note 2018.08.08-V18.6 更新脚本命名; 尝试解决http没有自动https的问题--------刷版本号
  70. // @note 2018.08.04-V18.5 修复在chrome上脚本偶尔没有生效的问题;修复百度搜索顶部侧移的情况;一定情况下修复双页的分列
  71. // @note 2018.07.25-V18.4 仅做文本说明修改-en-jp; 下次预计修改百度首页的广告问题
  72. // @note 2018.07.25-V18.3 减少了偶尔从首页加载进来的时候样式表没有载入的问题~能遇到部分样式表加载失效的情况很少;优化广告移除
  73. // @note 2018.07.24-V18.2 修复从百度首页加载进入页面时样式表没有载入的问题
  74. // @note 2018.07.24-V18.1 整体优化样式表加载速度-百度和谷歌的界面美化一下就载入了特别快;修复百度搜索的小链接的重定向没有改;修复下划线移除选项的下划线移除模式
  75. // @note 2018.07.21-V18.0 修复搜狗搜索没有获取到真实链接的问题;处理百度重定向速度又快又好;这次更新就支持edge了,同时理论上支持safari,希望测试;其次优化谷歌的界面样式
  76. // @note 2018.07.12-V17.9 修改检测参数,兼容支持Opera浏览器;暂时还是不支持EDGE的链接重定向功能
  77. // @note 2018.07.07-V17.8 修复由于上次更新世界杯界面时导致的shadowDOM关闭,然后广告出现的问题;优化整体去广告规则---有工具何必自己造轮子-本次用了百度自带jquery的查询函数has()
  78. // @note 2018.06.29-V17.7 修复右边栏导致的右侧过高,左侧看不见,以及自定义页面样式丢失的问题
  79. // @note 2018.06.27-V17.6 暂时关闭ShadowDOM的移除功能-尽量保留搜索世界杯功能完善。修复在某些页面上脚本无法运行的情况。新增自定义样式的输入框
  80. // @note 2018.06.26-V17.5 默认关闭右边栏-昨天忘了关闭了
  81. // @note 2018.06.25-V17.4 1.修复谷歌双列问题;2.修复右边栏展示-好些人说去掉之后不好看;3.似乎上个版本又有多次插入导致的页面卡顿情况-再次修复。。。其他的似乎没有了,想起再说
  82. // @note 2018.06.14-V17.3 由于edge中还是不支持返回真实链接,于是暂时屏蔽掉edge浏览器总的请求,等猴子更新了再开启这个功能;connect元素中添加baidu.com避免抽风
  83. // @note 2018.06.13-V17.2 加快查询速度-同时不再弹窗说新连接,无需设置特殊参数;缺点:LOG中会有许多Refused to connect to "xxx": Request was redirected to a not whitelisted URL
  84. // @note 2018.05.25-V17.1 新增支持百度学术的重定向功能
  85. // @note 2018.05.25-V17.0 拆分关键词高亮这个功能,保证功能尽量不交叉,如果需要这个功能的,请安装搜索关键词自动高亮脚本
  86. // @note 2018.05.22-V16.5 尝试缓解内存的问题,避免对其他的进行干扰,同时减少了head标签触发
  87. // @note 2018.05.22-V16.4 彻底拆分双击高亮和自动高亮功能,同时保持两个功能都是关闭状态
  88. // @note 2018.05.22-V16.3 设置添加双击高亮按钮
  89. // @note 2018.05.22-V16.2 不再使用MO方式,百度的原因导致MO彻底无法使用,于是全都用DOM操作来判断吧
  90. // @note 2018.05.21-V16.1 优化ac_redirectstatus高亮的问题; 同时修复了一个高亮关键词的bug;在一个老司机的指点下,添加了referer参数
  91. // @note 2018.05.21-V16.0 谢谢朋友们关心5.20我还是一个人过的很好;大版本:修正计数器的计数问题,修正MO失效之后脚本的触发问题;新增搜索关键词高亮选项,默认关闭
  92. // @note 2018.05.06-V15.3 简单移除好搜的广告
  93. // @note 2018.04.20-V15.2 修复bing的Favicon效果,避免显示在不同行上
  94. // @note 2018.04.04-V15.1 继续尝试修复bug,优化整体页面效果以及谷歌其余页面的效果展示;同时将百度样式写入到#wrapper>#head中去,刷新或者更换页面时就不会异常闪烁并且很平滑了
  95. // @note 2018.04.02-V14.9 更新谷歌整体效果,并尝试修复图片新闻等显示问题的bug
  96. // @note 2018.04.01-V14.8 --日狗问题,忘了改代码,只是更新了说明。。
  97. // @note 2018.04.01-V14.7 经过老司机(没ID)提供的反馈,发现上一版更新的依旧有bug,修复调小触发参数导致的触发没有生效的问题--偶尔双列失效的问题
  98. // @note 2018.04.01-V14.6 经过老司机(没ID)提供的反馈,排查发现chrome上脚本首次载入失效的问题,已经修复
  99. // @note 2018.04.01-V14.5 更新并添加谷歌双列、待测试,如果有问题,可以直接反馈
  100. // @note 2018.03.28-V14.4 移除jquery的require,疑似jquery引起冲突问题,于是彻底弃用jquery来处理页面数据,改用原声JS处理页面
  101. // @note 2018.03.27-V14.3 刷一个版本号,同时优化CSS载入过多的问题,但是载入过慢的问题又出现了,下次处理
  102. // @note 2018.03.26-V14.2 修复由于上次更新过于流畅的bug,同时修正首页的样式显示
  103. // @note 2018.03.25-V14.1 再次抄点代码,借鉴老司机:浮生@未歇的部分优化代码完善已有的(@resource、GM_getResourceText、GM_addStyle),避免页面闪烁一下,同时解决部分css载入重复的问题
  104. // @note 2018.03.23-V14.0 1.尝试修复在百度贴吧和百度知道的文字显示异常的问题; 2.修复编号奇怪的异常问题
  105. // @note 2018.03.18-V13.9 更新谷歌的favicon丢失的问题
  106. // @note 2018.03.04-V13.8 更新图库为https模式,避免那啥显示不安全
  107. // @note 2018.02.16-V13.7 1.新增关闭百度搜索预测;2.新增未知图标时切换; 3.移除百度搜索建议的顶部一条
  108. // @note 2018.01.12-V13.6 1.新增移除右边栏的按钮;2.新增版本显示文字;3.修正favicon位置;4.修复favicon的图片错误时候的值,万年BUG
  109. // @note 2017.12.27-V13.5 修复由于上个版本更新处理白屏,导致的默认标准模式的右侧栏不见了
  110. // @note 2017.12.20-V13.4 感谢ID:磁悬浮青蛙的反馈,已经修复小概率搜索之后点击结果白屏的问题-貌似之前处理过,但是没有彻底处理掉,这次彻底了,改用CSS隐藏
  111. // @note 2017.12.04-V13.3 新增设置,针对百度系列的重定向问题,不常用百度系列的朋友可以开启这个功能
  112. // @note 2017.11.23-V13.2 感谢卡饭坛友@Apollo8511提供反馈,已经修复部分知乎的重定向问题,更多问题可以直接反馈我
  113. // @note 2017.11.22-V13.1 移除百度系的重定向,虽然处理了,但是百度系直连会导致文字无法直接显示,其他直连不影响
  114. // @note 2017.11.17-V12.13 进一步移除百度的广告,右边部分广告的处理和移除
  115. // @note 2017.11.15-V12.12 搜狗的搜索地址又变了,加一个
  116. // @note 2017.11.02-V12.11 新增在手机mobile模式下百度的重定向处理,其余网站以后再说吧,估计没有需求
  117. // @note 2017.10.27-V12.10 1.修复逼死强迫症的问题;2.移除完整模式-避免出现各种拦截;3.修复www.so.com的重定向问题
  118. // @note 2017.09.18-V12.9 更新原因:1.勿忘国耻918;2.更新百度偶尔重定向没成功的问题;3.修复页面的小问题;4.新增文字下划线开关
  119. // @note 2017.09.15-V12.8 紧急修复谷歌上页面卡顿的问题,排查得知为百度规则的扩展出了问题,非常感谢众多朋友的支持,没有你们的反馈就没有这个脚本。修复并移除了百度官方采用的新方式广告模式,貌似只在chrome上出现
  120. // @note 2017.09.13-V12.7 1.修复N年前更新导致的部分网址重定向无效,继续使用GET方法,因为好些网站不支持HEAD方法,获取成功之后就断开,尽量减少了网络开支; 2.修复搜狗的部分搜索异常; 3.修复百度在chrome61上的链接异常问题
  121. // @note 2017.09.13-V12.6 开学之后的第二个版本,修复上次更新导致的百度首页错乱,修复firefox上的触发,修复SuperPreloader的翻页展示
  122. // @note 2017.09.12-V12.5 开学之后的第一个版本,修复在百度上偶尔不触发的问题【从首页搜索的时候触发】,其次在兄弟XXX(我也忘了哪个P_P)的帮助下,修复了偶尔会全屏特殊推广模式的问题
  123. // @note 2017.09.06-V12.4 修复上个版本更新导致的百度知道再次异常问题;更新知乎上的重定向问题-自己的脚本
  124. // @note 2017.09.06-V12.3 修复双列的模式的显示问题,如果有问题希望反馈一下,顺便切换css来源
  125. // @note 2017.09.04-V12.2 特意修复在ViolentMonkey上的设置无效的问题以及在360浏览器上的设置不显示问题
  126. // @note 2017.09.04-V12.1 百度页面直接添加设置入口;360浏览器设置可能在底部页面;支持单列和双列模式,界面更美观from浮生@未歇;可能是最近一段时间的最后版本了,要开学了~~
  127. // @note 2017.09.02-V11.10 添加两个选项,可以选择性移除部分设置
  128. // @note 2017.09.01-V11.9 修复上次更新导致的百度去广告不灵的问题
  129. // @note 2017.08.30-V11.8 新增:1.GM设置栏目中加入设置 2.baidu-使用HEAD方式获取,减少数据传输,搜狗特殊,继续GET方式
  130. // @note 2017.08.29-V11.7 方便朋友们-移除知乎重定向
  131. // @note 2017.08.07-V11.6 调整:移除小绿点,换为点击Favicon或者是计数器弹出窗口,更换为加群链接
  132. // @note 2017.08.06-V11.5 修复,保存异常;预期之后会添加百度搜索页面的大调整
  133. // @note 2017.08.05-V11.4 新增:反馈和建议地址增加
  134. // @note 2017.08.04-V11.3 修复:由于英语不好导致的拼写错误,感谢shj兄弟指出
  135. // @note 2017.08.03-V11.2 新增:谷歌链接新标签打开; 移除搜索结果链接的下划线
  136. // @note 2017.07.22-V11.1 新增了开关模式,可以开启或者关闭某些自己不喜欢的功能,开关在右上角,和SuperPreload共用
  137. // @note 2017.06.25-V10.1 修复上次更新导致的百度去广告的问题
  138. // @note 2017.06.25-V10.0 修复上次更新导致的百度知道再次出现老问题
  139. // @note 2017.06.24-V9.9 更新了翻页的问题,经过多次的尝试应该没有太大问题了
  140. // @note 2017.06.24-V9.8 更新了bing上的图片favicon地址;并且尽量减少了MO触发次数,避免页面卡顿;修复搜狗的重定向问题
  141. // @note 2017.06.23-V9.7 上传错了~重新来,顺带处理了谷歌favicon问题
  142. // @note 2017.06.23-V9.6 修复了谷歌重定向的问题~~我的锅
  143. // @note 2017.06.11-V9.5 不再使用DOM方式来监听页面了,使用timer+MO来处理,极大减少了cpu占用时间和瞬时网速占用
  144. // @note 2017.05.26-V9.4 恢复favicon模式,现在这个脚本基本上全了,有需要以后再说
  145. // @note 2017.05.15-V9.3 暂时移除百度右边侧栏的广告移除模式,准备下次优化好了再继续
  146. // @note 2017.05.12-V9.2 暂时移除谷歌的安全搜索模式,因为很复杂的原因
  147. // @note 2017.05.12-V9.1 暂时移除Favicon的显示,因为这样就杂了,有需要的人自己去装这个脚本吧,保留百度去广告
  148. // @note 2017.05.12-V9.0 集合了去重定向+去广告+Favicon显示
  149. // @note 2017.05.12-V8.7 集合了去广告的脚本,以前的那个去广告的脚本就不用了
  150. // @note 2017.05.12-V8.6 修复谷歌安全搜索的BUG V2
  151. // @note 2017.05.12-V8.4 新增:默认屏蔽谷歌的安全搜索功能
  152. // @note 2017.05.05-V8.3 修复include范围太小导致的百度知道的屏蔽问题
  153. // @note 2017.05.04-V8.2 终于修复了百度知道图片替换了文字的这个大BUG; 顺便处理了superapi.zhidao.baidu.com; 新增谷歌搜索结果重定向去除
  154. // @note 2017.05.04-V8.1 终于修复了百度知道图片替换了文字的这个大BUG,顺便处理了superapi.zhidao.baidu.com
  155. // @note 2017.05.04-V8.0 终于修复了百度知道图片替换了文字的这个大BUG,待测试
  156. // @note 2017.03.28-V7.6 修复在ViolentMonkey上的不支持的问题
  157. // @note 2017.03.28-V7.5 尝试修复chrome上的问题
  158. // @note 2017.03.21-V7.4 尝试处理Edge上不支持的问题,结果发现是Edge本身的TamperMonkey支持有问题
  159. // @note 2017.03.19-V7.3 修复打开百度之后再次点击“百度一下”导致的无法更新重定向问题
  160. // @note 2017.03.19-V7.2 未知原因chrome的MutationObserver无法使用了,继续回归以前的DOMNodeInserted
  161. // @note 2017.02.17-V7.0 修复搜狗的搜索结果重定向问题+改个名字
  162. // @note 2017.02.17-V6.9 修复搜狗的搜索结果重定向问题
  163. // @note 2016.12.10-V6.8 ***
  164. // @note 2016.10.27-V6.7 修复了以前的重复请求,现在的请求数应该小了很多,网络也就不卡了,感觉萌萌哒
  165. // @note 2016.04.24-V6.6 恢复以前的版本,因为兼容性问题
  166. // @note 2015.12.01-V5.0 加入搜狗的支持,但是支持不是很好
  167. // @note 2015.11.25-V2.0 优化,已经是真实地址的不再尝试获取
  168. // @note 2015.11.25-V1.0 完成去掉百度重定向的功能
  169. // @resource baiduCommonStyle https://baidu.ntaow.com/newcss/baiduCommonStyle.css?t=22.03
  170. // @resource baiduOnePageStyle https://baidu.ntaow.com/newcss/baiduOnePageStyle.css?t=22.03
  171. // @resource baiduTwoPageStyle https://baidu.ntaow.com/newcss/baiduTwoPageStyle.css?t=22.03
  172. // @resource googleCommonStyle https://baidu.ntaow.com/newcss/googleCommonStyle.css?t=22.03
  173. // @resource googleOnePageStyle https://baidu.ntaow.com/newcss/googleOnePageStyle.css?t=22.03
  174. // @resource googleTwoPageStyle https://baidu.ntaow.com/newcss/googleTwoPageStyle.css?t=22.03
  175. // @resource bingCommonStyle https://baidu.ntaow.com/newcss/bingCommonStyle.css?t=22.03
  176. // @resource bingOnePageStyle https://baidu.ntaow.com/newcss/bingOnePageStyle.css?t=22.03
  177. // @resource bingTwoPageStyle https://baidu.ntaow.com/newcss/bingTwoPageStyle.css?t=22.03
  178. // @resource MainHuYanStyle https://baidu.ntaow.com/newcss/HuYanStyle.css?t=22.03
  179. // @grant GM_getValue
  180. // @grant GM.getValue
  181. // @grant GM_setValue
  182. // @grant GM.setValue
  183. // @grant GM_addStyle
  184. // @grant GM_xmlhttpRequest
  185. // @grant GM_getResourceText
  186. // @grant GM_registerMenuCommand
  187. // ==/UserScript==
  188. !function () {
  189. var isdebug = false;
  190. var debug = isdebug ? console.log.bind(console) : function () {};
  191. var inExtMode = typeof(isExtension)!="undefined";
  192. var inGMMode = typeof(GM_info.scriptHandler)!="undefined"; // = "Greasemonkey" || "Tampermonkey" || "ViolentMonkey"
  193. // 新版本的GreaseMonkey是带有scriptHandler,但是没有GM_getResourceText;旧版本不带scriptHandler,但是有GM_getResourceText
  194. var isNewGM = typeof(GM_info.scriptHandler) != "undefined" && GM_info.scriptHandler.toLowerCase() == "greasemonkey";
  195. // inExtMode & inGMMode
  196. // true true =扩展下的GM代码 不执行
  197. // true false=扩展下代码 执行
  198. // false true =仅GM代码 执行
  199. // false false=异常 但是还是要执行代码
  200. debug("程序开始");
  201. if(inExtMode == true && inGMMode == true){
  202. console.log("扩展模式-脚本不启用");
  203. return;
  204. }
  205. if(typeof(GM) == "undefined"){
  206. // 这个是ViolentMonkey的支持选项
  207. GM = {};
  208. GM.setValue = GM_setValue;
  209. GM.getValue = GM_getValue;
  210. }
  211. (function () {
  212. debug("程序执行");
  213. var needDisplayNewFun = true; // 本次更新是否有新功能需要展示
  214.  
  215. var ACConfig = {};
  216. var DefaultConfig = {
  217. isRedirectEnable : true, // 是否开启重定向功能
  218. isAdsEnable : true, // 是否开启去广告模式
  219. AdsStyleEnable : true, // 是否开启自定义样式模式
  220. AdsStyleMode_Baidu : 2, // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
  221. AdsStyleMode_Google : 2, // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
  222. AdsStyleMode_Bing : 3, // 0-不带css;1-单列靠左;2-单列居中;3-双列居中
  223. HuYan_Baidu: false, // 护眼模式-百度
  224. HuYan_Google: false, // 护眼模式-谷歌
  225. HuYan_Bing: false, // 护眼模式-必应
  226. defaultHuYanColor: "#DEF1EF",
  227. isUserColorEnable : true, // 是否开启favicon图标功能
  228. isFaviconEnable : true, // 是否开启favicon图标功能
  229. defaultFaviconUrl : "https://ws1.sinaimg.cn/large/6a155794ly1foijtdzhxhj200w00wjr5.jpg", // 默认图标地址
  230. doDisableSug : true, // 是否禁止百度搜索预测
  231. isRightDisplayEnable : false, // 是否开启右侧边栏
  232. isCounterEnable : false, // 是否显示计数器
  233. isALineEnable : false, // 是否禁止下划线
  234. isUserStyleEnable : false, // 是否开启自定义样式
  235. UserStyleText : "/**计数器的颜色样式*/\n" + // 自定义样式数据
  236. ".CounterT{\n" +
  237. " background: #FD9999;\n" +
  238. "}\n" +
  239. "/**右侧栏的样式-其实不开启更好看一些*/\n" +
  240. "#content_right{\n" +
  241. " padding: 20px 15px 15px;\n" +
  242. " border-radius: 5px;\n" +
  243. " background-color: #fff;\n" +
  244. " box-sizing: border-box;\n" +
  245. " box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);\n" +
  246. " -webkit-box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);\n" +
  247. " -moz-box-shadow: 0 0 20px 2px rgba(0, 0, 0, .1);\n" +
  248. "}",
  249. oldVersion : "",
  250. };
  251. var hasNewFuncNeedDisplay = true; // 设置器
  252. var sortIndex = 1; // 设置编号值
  253. var isGoogleImageUrl = false;
  254. var AdsStyleMode = ACConfig.AdsStyleMode_Baidu;// 值 = baidu or = google
  255. var HuYanMode = ACConfig.HuYan_Baidu;// 值 = baidu or = google
  256. var keySite = "baidu";
  257. var StyleManger = function(){};
  258.  
  259. /**初始化所有的设置**/
  260. Promise.all([GM.getValue("Config")]).then(function(data){
  261. if(data[0] != null){
  262. ACConfig = data[0];
  263. } else{
  264. ACConfig = DefaultConfig;
  265. }
  266. // 初始化完成之后才能调用正常函数
  267. callback();
  268. }).catch(function(except){
  269. console.log(except);
  270. });
  271. function callback() {
  272. if (ACConfig.oldVersion == GM_info.script.version) {
  273. hasNewFuncNeedDisplay = false;
  274. } else {
  275. hasNewFuncNeedDisplay = needDisplayNewFun;
  276. }
  277. !function(){
  278. var Stype_Normal; // 去重定向的选择
  279. var FaviconType; // favicon的选择-取得实际地址-得到host
  280. var FaviconAddTo; // favicon的选择-取得实际地址-得到host
  281. var CounterType; // Counter的选择
  282. var SiteTypeID; // 标记当前是哪个站点[百度=1;搜狗=2;3=好搜;谷歌=4;必应=5;知乎=6;百度学术=7;其他=8]
  283. var SiteType = {
  284. BAIDU: 1,
  285. SOGOU: 2,
  286. SO: 3,
  287. GOOGLE: 4,
  288. BING: 5,
  289. ZHIHU: 6,
  290. BAIDU_XUESHU: 7,
  291. OTHERS: 8
  292. };
  293. var BaiduVersion = " V" + GM_info.script.version;
  294. var insertLocked = false;
  295. var oldCenter_colWidth = 0;
  296. if (location.host.indexOf("www.baidu.com") > -1) {
  297. SiteTypeID = SiteType.BAIDU;
  298. Stype_Normal = "h3.t>a, #results .c-container>.c-blocka"; //PC,mobile
  299. FaviconType = ".result-op, .c-showurl";
  300. FaviconAddTo = ".c-container h3";
  301. CounterType = "#content_left>#double>div[srcid] *[class~=t],[class~=op_best_answer_question],#content_left>div[srcid] *[class~=t],[class~=op_best_answer_question]";
  302. } else if (location.host.indexOf("sogou") > -1) {
  303. SiteTypeID = SiteType.SOGOU;
  304. Stype_Normal = "h3.pt>a, h3.vrTitle>a";
  305. FaviconType = "cite[id*='cacheresult_info_']";
  306. FaviconAddTo = ".vrwrap h3, .rb h3";
  307. CounterType = ".results>div";
  308. } else if (location.host.indexOf("so.com") > -1) {
  309. SiteTypeID = SiteType.SO;
  310. Stype_Normal = ".res-list h3>a";
  311. FaviconType = ".res-linkinfo cite";
  312. FaviconAddTo = ".res-list h3";
  313. CounterType = ".results>div";
  314. } else if (location.host.indexOf("google") > -1) {
  315. SiteTypeID = SiteType.GOOGLE;
  316. FaviconType = ".iUh30";
  317. FaviconAddTo = ".rc h3";
  318. CounterType = ".srg>div[class~=g] *[class~=r] h3,._yE>div[class~=_kk] h3";
  319. } else if (location.host.indexOf("bing") > -1) {
  320. SiteTypeID = SiteType.BING;
  321. FaviconType = ".b_attribution>cite";
  322. FaviconAddTo = ".b_algo h2, .b_ans h2";
  323. CounterType = "#b_results>li[class~=b_ans]>h2,#b_results>li[class~=b_algo]>h2,#b_results>li[class~=b_algo]>h2";
  324. } else if (location.host.indexOf("zhihu.com") > -1) {
  325. SiteTypeID = SiteType.ZHIHU;
  326. } else if (location.host.indexOf("xueshu.baidu.com") > -1) {
  327. SiteTypeID = SiteType.BAIDU_XUESHU;
  328. } else {
  329. SiteTypeID = SiteType.OTHERS;
  330. }
  331. if (SiteTypeID == SiteType.GOOGLE && location.href.replace(/tbm=(isch|lcl|shop|flm)/, "") != location.href) {
  332. // 图片站 、地图站、购物站
  333. console.log("特殊站,不加载样式");
  334. isGoogleImageUrl = true;
  335. }
  336. if (ACConfig.AdsStyleEnable) {
  337. if (SiteTypeID == SiteType.BAIDU){
  338. AdsStyleMode = ACConfig.AdsStyleMode_Baidu;
  339. HuYanMode = ACConfig.HuYan_Baidu;
  340. keySite = "baidu";
  341. }else if (SiteTypeID == SiteType.GOOGLE){
  342. AdsStyleMode = ACConfig.AdsStyleMode_Google;
  343. HuYanMode = ACConfig.HuYan_Google;
  344. keySite = "google";
  345. } else if (SiteTypeID == SiteType.BING){
  346. AdsStyleMode = ACConfig.AdsStyleMode_Bing;
  347. HuYanMode = ACConfig.HuYan_Bing;
  348. keySite = "bing";
  349. }
  350. StyleManger = FSBaidu(); // 添加设置项-单双列显示
  351. }
  352. setInterval(function(){
  353. if(document.body != null){
  354. document.body.setAttribute(keySite, "1");
  355. }
  356. }, 300);
  357. function addStyle(css) { //添加CSS的代码--copy的
  358. var pi = document.createProcessingInstruction(
  359. 'xml-stylesheet',
  360. 'type="text/css" href="data:text/css;utf-8,' + encodeURIComponent(css) + '"'
  361. );
  362. return document.insertBefore(pi, document.documentElement);
  363. }
  364. if (ACConfig.isAdsEnable) {
  365. // display已经无法隐藏他们了,需要用绝对的隐藏
  366. addStyle("#content_left>div:not([id])>div[cmatchid], #content_left>div[id*='300']:not([class*='result']),#content_right td>div:not([id]),#content_right>br{position:absolute;top:-6666px;}");
  367. }
  368. try {
  369. if (SiteTypeID != SiteType.OTHERS) {
  370. document.addEventListener('DOMNodeInserted', MainCallback, false);
  371. document.addEventListener('keyup', MainCallback, false);
  372. }
  373. } catch (e) {
  374. console.log(e);
  375. }
  376. function MainCallback(e){
  377. if (e.target != null && e.target.className != null && e.target.className.toUpperCase().indexOf("AC-") == 0) {
  378. return;
  379. } //屏蔽掉因为增加css导致的触发insert动作
  380. rapidDeal();
  381. }
  382. function AutoRefresh() {
  383. if (!ACConfig.isRightDisplayEnable) {
  384. // 移除右边栏 -注意在#wrapper>#con-at>#result-op xpath-log有时候很重要,不能隐藏
  385. AC_addStyle("#content_right{display:none !important;}#content_right td>div:not([id]){display:none;}#content_right .result-op:not([id]){display:none!important;}#rhs{display:none;}", "AC-RightRemove");
  386. } else {
  387. if(AdsStyleMode == 2){
  388. // 非双列模式下尽可能的显示右侧栏
  389. AC_addStyle("@media screen and (min-width: 1250px) {#container{width: 80% !important;}.container_l #content_right{margin-right: calc(18% - 210px);position: absolute;right: -200px;display:block !important;overflow:hidden;width: 22vw !important;}", "AC-RightRemove");
  390. }
  391. }
  392. if (!ACConfig.isALineEnable) {
  393. AC_addStyle("a,a em{text-decoration:none}", "AC-NoLine");// 移除这些个下划线
  394. }
  395. if (ACConfig.isUserStyleEnable) {
  396. AC_addStyle(ACConfig.UserStyleText, "AC-userStyle");// 用户自定义的样式表
  397. }
  398. AC_addStyle(
  399. ".opr-recommends-merge-imgtext{display:none!important;}" + // 移除百度浏览器推广
  400. ".res_top_banner{display:none!important;}" + // 移除可能的百度HTTPS劫持显示问题
  401. ".headBlock{display:none;}" // 移除百度的搜索结果顶部一条的建议文字
  402. , "AC-special-BAIDU"
  403. );
  404. /*"自定义"按钮效果*/
  405. AC_addStyle("#sp-ac-container label{display:inline;}#u{width:319px}#u #myuser{display:inline}#myuser,#myuser .myuserconfig{padding:0;margin:0}#myuser{display:inline-block;}#myuser .myuserconfig{display:inline-block;line-height:1.5;background:#2866bd;color:#fff;font-weight:700;text-align:center;padding:6px;border:2px solid #E5E5E5;}#myuser .myuserconfig{box-shadow:0 0 10px 3px rgba(0,0,0,.1)}#myuser .myuserconfig:hover{background:#2970d4 !important;color:#fff;cursor:pointer;border:2px solid #73A6F8;}", "AC-MENU_Btn");
  406. /*自定义页面内容效果*/
  407. AC_addStyle('body[baidu] #sp-ac-container .container-label:not([class*="baidu"])>label,\n' +
  408. ' body[google] #sp-ac-container .container-label:not([class*="google"])>label,\n' +
  409. ' body[bing] #sp-ac-container .container-label:not([class*="bing"])>label,\n' +
  410. ' body[baidu] #sp-ac-container .container-label:not([class*="baidu"])>br,\n' +
  411. ' body[google] #sp-ac-container .container-label:not([class*="google"])>br,\n' +
  412. ' body[bing] #sp-ac-container .container-label:not([class*="bing"])>br,\n' +
  413. ' body[baidu] #sp-ac-container .container-label[class*="baidu"]>labelhide,\n' +
  414. ' body[google] #sp-ac-container .container-label[class*="google"]>labelhide,\n' +
  415. ' body[bing] #sp-ac-container .container-label[class*="bing"]>labelhide{\n' +
  416. ' display:none;\n' +
  417. '}#sp-ac-container labelHide{cursor:pointer;margin-left: 8%;color:blue;}#sp-ac-container .linkhref,#sp-ac-container labelHide:hover{color:red;} #sp-ac-container .linkhref:hover{font-weight: bold;}#sp-ac-container label.menu-box-small{max-width:16px;max-height:16px;cursor:pointer;display: inline-block;}.CounterT{background: #FD9999;}body>#sp-ac-container{position: fixed !important; top: 3.9vw;right: 8.8vw;} #sp-ac-container{z-index:999999!important;text-align:left!important;background-color:white;}#sp-ac-container *{font-size:13px!important;color:black;float:none!important;}#sp-ac-main-head{position:relative!important;top:0!important;left:0!important;}#sp-ac-span-info{position:absolute!important;right:1px!important;top:0!important;font-size:10px!important;line-height:10px!important;background:none!important;font-style:italic!important;color:#5a5a5a!important;text-shadow:white 0px 1px 1px!important;}#sp-ac-container input{vertical-align:middle!important;display:inline-block!important;outline:none!important;height:auto !important;padding:0px !important;margin-bottom:0px !important;margin-top: 0px !important;}#sp-ac-container input[type="number"]{width:50px!important;text-align:left!important;}#sp-ac-container input[type="checkbox"]{border:1px solid #B4B4B4!important;padding:1px!important;margin:3px!important;width:13px!important;height:13px!important;background:none!important;cursor:pointer!important;visibility:visible !important;position:static !important;}#sp-ac-container input[type="button"]{border:1px solid #ccc!important;cursor:pointer!important;background:none!important;width:auto!important;height:auto!important;}#sp-ac-container li{list-style:none!important;margin:3px 0!important;border:none!important;float:none!important;}#sp-ac-container fieldset{border:2px groove #ccc!important;-moz-border-radius:3px!important;border-radius:3px!important;padding:4px 9px 6px 9px!important;margin:2px!important;display:block!important;width:auto!important;height:auto!important;}#sp-ac-container legend{line-height:20px !important;margin-bottom:0px !important;}#sp-ac-container fieldset>ul{padding:0!important;margin:0!important;}#sp-ac-container ul#sp-ac-a_useiframe-extend{padding-left:40px!important;}#sp-ac-rect{position:relative!important;top:0!important;left:0!important;float:right!important;height:10px!important;width:10px!important;padding:0!important;margin:0!important;-moz-border-radius:3px!important;border-radius:3px!important;border:1px solid white!important;-webkit-box-shadow:inset 0 5px 0 rgba(255,255,255,0.3),0 0 3px rgba(0,0,0,0.8)!important;-moz-box-shadow:inset 0 5px 0 rgba(255,255,255,0.3),0 0 3px rgba(0,0,0,0.8)!important;box-shadow:inset 0 5px 0 rgba(255,255,255,0.3),0 0 3px rgba(0,0,0,0.8)!important;opacity:0.8!important;}#sp-ac-dot,#sp-ac-cur-mode{position:absolute!important;z-index:9999!important;width:5px!important;height:5px!important;padding:0!important;-moz-border-radius:3px!important;border-radius:3px!important;border:1px solid white!important;opacity:1!important;-webkit-box-shadow:inset 0 -2px 1px rgba(0,0,0,0.3),inset 0 2px 1px rgba(255,255,255,0.3),0px 1px 2px rgba(0,0,0,0.9)!important;-moz-box-shadow:inset 0 -2px 1px rgba(0,0,0,0.3),inset 0 2px 1px rgba(255,255,255,0.3),0px 1px 2px rgba(0,0,0,0.9)!important;box-shadow:inset 0 -2px 1px rgba(0,0,0,0.3),inset 0 2px 1px rgba(255,255,255,0.3),0px 1px 2px rgba(0,0,0,0.9)!important;}#sp-ac-dot{right:-3px!important;top:-3px!important;}#sp-ac-cur-mode{left:-3px!important;top:-3px!important;width:6px!important;height:6px!important;}#sp-ac-content{padding:0!important;margin:0px !important;-moz-border-radius:3px!important;border-radius:3px!important;border:1px solid #A0A0A0!important;-webkit-box-shadow:-2px 2px 5px rgba(0,0,0,0.3)!important;-moz-box-shadow:-2px 2px 5px rgba(0,0,0,0.3)!important;box-shadow:-2px 2px 5px rgba(0,0,0,0.3)!important;}#sp-ac-main{padding:5px!important;border:1px solid white!important;-moz-border-radius:3px!important;border-radius:3px!important;background-color:#F2F2F7!important;background:-moz-linear-gradient(top,#FCFCFC,#F2F2F7 100%)!important;background:-webkit-gradient(linear,0 0,0 100%,from(#FCFCFC),to(#F2F2F7))!important;}#sp-ac-foot{position:relative!important;left:0!important;right:0!important;min-height:20px!important;}#sp-ac-savebutton{position:absolute!important;top:0!important;right:2px!important;}#sp-ac-container .sp-ac-spanbutton{border:1px solid #ccc!important;-moz-border-radius:3px!important;border-radius:3px!important;padding:2px 3px!important;cursor:pointer!important;background-color:#F9F9F9!important;-webkit-box-shadow:inset 0 10px 5px white!important;-moz-box-shadow:inset 0 10px 5px white!important;box-shadow:inset 0 10px 5px white!important;}label[class="newFunc"]{color:blue !important;}', "AC-MENU_Page");
  418. }
  419. AutoRefresh();
  420. try{
  421. GM_registerMenuCommand('AC-重定向脚本设置', function () {
  422. document.querySelector("#sp-ac-content").style.display = 'block';
  423. });
  424. }catch (e) {
  425. }
  426. function rapidDeal() {
  427. try {
  428. if (insertLocked == false && SiteTypeID != SiteType.OTHERS) {
  429. insertLocked = true;
  430. ShowSetting();
  431. ACHandle();
  432. AutoRefresh();
  433. if (ACConfig.isAdsEnable) { // 放进来,减少卡顿
  434. removeAD_baidu_sogou();
  435. }
  436. if (ACConfig.AdsStyleEnable) {
  437. FSBaidu(); // 单独不需要定时器-頻繁触发-载入css
  438. }
  439. setTimeout(function () {
  440. insertLocked = false;
  441. }, 200);
  442. }
  443. } catch (e) {
  444. console.log(e);
  445. }
  446. }
  447. function acSetCookie(cname, cvalue, domain, exdays) {
  448. exdays = exdays || 30;
  449. var d = new Date();
  450. domain = (domain ? "domain="+domain:"") + ";";
  451. d.setTime(d.getTime() + (exdays * 24 * 60 * 60 * 1000));
  452. var expires = "expires=" + d.toUTCString();
  453. document.cookie = cname + "=" + cvalue + "; " + domain + expires + ";path=/";
  454. }
  455. function ACHandle() {
  456. if (SiteTypeID == SiteType.OTHERS) return;
  457. InsertSettingMenu();
  458. if (ACConfig.isRedirectEnable) {
  459. if (Stype_Normal != null && Stype_Normal != "") resetURLNormal(document.querySelectorAll(Stype_Normal)); // 百度搜狗去重定向-普通模式【注意不能为document.query..】
  460. if (SiteTypeID == SiteType.GOOGLE) removeOnMouseDownFunc(); // 移除onMouseDown事件,谷歌去重定向
  461. removeRedirectLinkTarget(); // 只移除知乎的重定向问题 & 百度学术重定向问题
  462. safeRemove(".res_top_banner"); // 移除百度可能显示的劫持
  463. }
  464. if (ACConfig.isFaviconEnable) {
  465. addFavicon(document.querySelectorAll(FaviconType)); // 添加Favicon显示
  466. }
  467. if (ACConfig.doDisableSug) {
  468. // 不启用移动预测[默认]
  469. acSetCookie("ORIGIN", 2, "www.baidu.com");
  470. acSetCookie("ISSW", 1);
  471. acSetCookie("ISSW", 1, "www.baidu.com");
  472. }else{
  473. // 启用移动预测-不知道为什么要设置两个-百度自己会变?,反正有效果
  474. acSetCookie("ORIGIN", 1, "www.baidu.com");
  475. acSetCookie("ISSW", 2);
  476. acSetCookie("ISSW", 2, "www.baidu.com");
  477. }
  478. // if (ACConfig.AdsStyleEnable) {
  479. // FSBaidu();
  480. // }
  481. if (ACConfig.isAdsEnable) {
  482. removeAD_baidu_sogou(); // 移除百度广告
  483. } else {
  484. document.querySelector("input[name='sp-ac-a_force_style_baidu']").setAttribute("disabled", "disabled");
  485. document.querySelector("input[name='sp-ac-a_force_style_google']").setAttribute("disabled", "disabled");
  486. }
  487. if (ACConfig.isCounterEnable) {
  488. addCounter(document.querySelectorAll(CounterType));
  489. }
  490. }
  491.  
  492. function ACtoggleSettingDisplay(e) {
  493. e.stopPropagation();
  494. // 显示?隐藏设置界面
  495. setTimeout(function () {
  496. if (document.querySelector("#sp-ac-content").style.display == 'block') {
  497. document.querySelector("#sp-ac-content").style.display = 'none';
  498. } else {
  499. ACConfig.oldVersion = GM_info.script.version;
  500. GM.setValue("Config", ACConfig);
  501. document.querySelector(".ac-newversionDisplay").style.display = 'none';
  502. document.querySelector("#sp-ac-content").style.display = 'block';
  503. }
  504. }, 100);
  505. return false;
  506. }
  507.  
  508. function ShowSetting() {
  509. if (SiteTypeID == SiteType.OTHERS) return;
  510. // 如果不存在的话,那么自己创建一个-copy from superPreload
  511. if (document.body != null && document.querySelector("#sp-ac-container") == null) {
  512. var Container = document.createElement('div');
  513. Container.id = "sp-ac-container";
  514. Container.innerHTML =
  515. " <div id='sp-ac-content' style='display: none;'>\n" +
  516. " <div id='sp-ac-main'>\n" +
  517. " <fieldset id='sp-ac-autopager-field' style='display:block;'>\n" +
  518. " <legend title='AC重定向功能相关设置'><a class='linkhref' href='https://www.ntaow.com/aboutscript.html' target='_blank'>AC-重定向设置" + BaiduVersion + "</a></legend>\n" +
  519. " <ul>\n" +
  520. " <li><label title='重定向功能的开启与否'><input id='sp-ac-redirect' name='sp-ac-a_separator' type='checkbox' " + (ACConfig.isRedirectEnable ? 'checked' : '') + ">主功能-重定向功能</label>\n" +
  521. " </li>\n" +
  522. " <li><label title='AC-去广告' ><input id='sp-ac-ads' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isAdsEnable ? 'checked' : '') + ">附加1-去广告功能</label></li>\n" +
  523. " <li><label title='AC-自定义样式' style='"+(hasNewFuncNeedDisplay ? "color:red !important;font-weight: 100;background-color: yellow;font-weight: 600 !important;" : "")+"'><input id='sp-ac-style' name='sp-ac-a_force' type='checkbox' " + (ACConfig.AdsStyleEnable ? 'checked' : '') + ">附加2-自定义样式</label>\n" +
  524. " <label></label></li>\n" +
  525. " <li>" +
  526. /****-百度样式-*****/
  527. " <labelMain class='container-label baidu'>" +
  528. " <labelHide>展开百度设置&gt;&gt;</labelHide>" +
  529. " <label title='百度-原始模式' style='margin-left:20px'><input name='sp-ac-a_force_style_baidu' value='0' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 0 ? 'checked' : '') + ">百度-原始模式</label>" +
  530. " <label title='百度-护眼模式'><input name='sp-ac-huyan_style_baidu' type='checkbox' " + (ACConfig.HuYan_Baidu == true ? 'checked' : '') + ">百度-护眼模式</label>" +
  531. " <BR/><label title='百度-单列普通模式' style='margin-left:20px'><input title='百度-单列普通模式' name='sp-ac-a_force_style_baidu' value='1' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 1 ? 'checked' : '') + ">单列</label>" +
  532. " <label title='百度-单列居中'><input name='sp-ac-a_force_style_baidu' value='2' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 2 ? 'checked' : '') + ">单列居中</label>" +
  533. " <label title='双列'><input name='sp-ac-a_force_style_baidu' value='3' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 3 ? 'checked' : '') + ">双列</label>" +
  534. " <label title='三列'><input name='sp-ac-a_force_style_baidu' value='4' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 4 ? 'checked' : '') + ">三列</label>" +
  535. " <label title='四列'><input name='sp-ac-a_force_style_baidu' value='5' type='radio' " + (ACConfig.AdsStyleMode_Baidu == 5 ? 'checked' : '') + ">四列</label>" +
  536. " <BR/></labelMain>" +
  537. /****-百度样式-*****/
  538. " <div style='height: 1px;width:267px;margin-left:25px;background-color:#d8d8d8;margin-top:1px;'></div>" +
  539. /****-谷歌样式-*****/
  540. " <labelMain class='container-label google'>" +
  541. " <labelHide>展开谷歌设置&gt;&gt;</labelHide>" +
  542. " <label title='谷歌-原始模式' style='margin-left:20px'><input name='sp-ac-a_force_style_google' value='0' type='radio' " + (ACConfig.AdsStyleMode_Google == 0 ? 'checked' : '') + ">谷歌-原始模式</label>" +
  543. " <label title='谷歌-护眼模式'><input name='sp-ac-huyan_style_google' type='checkbox' " + (ACConfig.HuYan_Google == true ? 'checked' : '') + ">谷歌-护眼模式</label>" +
  544. " <BR/><label title='单列普通模式' style='margin-left:20px'><input title='谷歌-单列普通模式' name='sp-ac-a_force_style_google' value='1' type='radio' " + (ACConfig.AdsStyleMode_Google == 1 ? 'checked' : '') + ">单列</label>" +
  545. " <label title='谷歌-单列居中'><input name='sp-ac-a_force_style_google' value='2' type='radio' " + (ACConfig.AdsStyleMode_Google == 2 ? 'checked' : '') + ">单列居中</label>" +
  546. " <label title='双列'><input name='sp-ac-a_force_style_google' value='3' type='radio' " + (ACConfig.AdsStyleMode_Google == 3 ? 'checked' : '') + ">双列</label>" +
  547. " <label title='三列'><input name='sp-ac-a_force_style_google' value='4' type='radio' " + (ACConfig.AdsStyleMode_Google == 4 ? 'checked' : '') + ">三列</label>" +
  548. " <label title='四列'><input name='sp-ac-a_force_style_google' value='5' type='radio' " + (ACConfig.AdsStyleMode_Google == 5 ? 'checked' : '') + ">四列</label>" +
  549. " <BR/></labelMain>" +
  550. /****-谷歌样式-*****/
  551. " <div style='height: 1px;width:267px;margin-left:25px;background-color:#d8d8d8;margin-top:1px;'></div>" +
  552. /****-必应样式-*****/
  553. " <labelMain class='container-label bing'>" +
  554. " <labelHide>展开必应设置&gt;&gt;</labelHide>" +
  555. " <label title='必应-原始模式' style='margin-left:20px'><input name='sp-ac-a_force_style_bing' value='0' type='radio' " + (ACConfig.AdsStyleMode_Bing == 0 ? 'checked' : '') + ">必应-原始模式</label>" +
  556. " <label title='必应-护眼模式'><input name='sp-ac-huyan_style_bing' type='checkbox' " + (ACConfig.HuYan_Bing == true ? 'checked' : '') + ">必应-护眼模式</label>" +
  557. " <BR/><label title='单列普通模式' style='margin-left:20px'><input title='必应-单列普通模式' name='sp-ac-a_force_style_bing' value='1' type='radio' " + (ACConfig.AdsStyleMode_Bing == 1 ? 'checked' : '') + ">单列</label>" +
  558. " <label title='必应-单列居中'><input name='sp-ac-a_force_style_bing' value='2' type='radio' " + (ACConfig.AdsStyleMode_Bing == 2 ? 'checked' : '') + ">单列居中</label>" +
  559. " <label title='双列'><input name='sp-ac-a_force_style_bing' value='3' type='radio' " + (ACConfig.AdsStyleMode_Bing == 3 ? 'checked' : '') + ">双列</label>" +
  560. " <label title='三列'><input name='sp-ac-a_force_style_bing' value='4' type='radio' " + (ACConfig.AdsStyleMode_Bing == 4 ? 'checked' : '') + ">三列</label>" +
  561. " <label title='四列'><input name='sp-ac-a_force_style_bing' value='5' type='radio' " + (ACConfig.AdsStyleMode_Bing == 5 ? 'checked' : '') + ">四列</label>" +
  562. " </labelMain>" +
  563. /****-必应样式-*****/
  564. " </li>\n" +
  565. " <li><label><input title='AC-自定义护眼' id='sp-ac-usercolor' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isUserColorEnable ? 'checked' : '') + ">附加3-护眼颜色配置</label></li>\n" +
  566. " <li><label class='menu-box-container'><label style='margin-left:20px;'>默认护眼颜色:</label>" +
  567. " <input class='sp-ac-menuhuyanColor' title='自定义的护眼颜色' style='width:70px;margin-top:-0.05rem !important;' value='"+ACConfig.defaultHuYanColor+"'>" +
  568. " <label class='menu-box-small' data-color='#DEF1EF' style='background-color:#DEF1EF;'>&nbsp;&nbsp;&nbsp;&nbsp;</label>" +
  569. " <label class='menu-box-small' data-color='#f3f2ee' style='background-color:#f3f2ee;'>&nbsp;&nbsp;&nbsp;&nbsp;</label>" +
  570. " <label class='menu-box-small' data-color='#e5e5e5' style='background-color:#e5e5e5;'>&nbsp;&nbsp;&nbsp;&nbsp;</label>" +
  571. " <label class='linkhref' data-href='https://html-color-codes.info/' style='cursor:pointer;margin-right: 10px;' onclick='window.open(this.dataset.href)'>更多颜色选择</label>" +
  572. " </label></li>\n" +
  573. " <li><label><input title='AC-添加Favicon' id='sp-ac-favicon' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isFaviconEnable ? 'checked' : '') + ">附加4-Favicon功能</label></li>\n" +
  574. " <li><label><label style='margin-left:20px;'>Favicon默认图标:</label><input id='sp-ac-faviconUrl' name='sp-ac-a_force' value='" + ACConfig.defaultFaviconUrl + "' style='width:55%;margin-top:-0.3rem !important;' type='input' " + (ACConfig.isFaviconEnable ? '' : 'disabled=true') + "></label></li>\n" +
  575. " <li><label><input title='AC-移除搜索预测' id='sp-ac-sug_origin' name='sp-ac-a_force' type='checkbox' " + (ACConfig.doDisableSug ? 'checked' : '') + ">附加5-移除百度搜索预测(文字自动搜索)</label></li>\n" +
  576. // 有更新-高亮 <label style=''> || style='"+(hasNewFuncNeedDisplay?"color:red !important;font-weight: 100;background-color: yellow;font-weight: 600 !important;":"")+"'
  577. " <li><label><input title='AC-显示右侧栏' id='sp-ac-right' type='checkbox' " + (ACConfig.isRightDisplayEnable ? 'checked' : '') + ">附加6-显示右侧栏</label></li>\n" +
  578. " <li><label><input title='AC-添加编号' id='sp-ac-counter' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isCounterEnable ? 'checked' : '') + ">附加7-编号功能</label></li>\n" +
  579. " <li><label><input title='AC-文字下划线' id='sp-ac-aline' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isALineEnable ? 'checked' : '') + ">附加8-文字下划线</label></li>\n" +
  580. " <li><label><input title='AC-自定义样式' id='sp-ac-userstyle' name='sp-ac-a_force' type='checkbox' " + (ACConfig.isUserStyleEnable ? 'checked' : '') + ">附加9-自定义样式</label></li>\n" +
  581. " <li><textarea id='sp-ac-userstyleTEXT' name='sp-ac-a_force' value='这个是用户自定义样式' style='width:85%;height: 66px;margin-left:30px!important;' type='input'>" + ACConfig.UserStyleText + "</textarea></label></li>\n" +
  582. " <li><a class='linkhref' target='_blank' href='https://qm.qq.com/cgi-bin/qm/qr?k=fOg8ij6TuwOAfS8g16GRYNf5YYFu5Crw&jump_from=&auth=-l05paasrPe5zigt5ahdzn_dzXiB1jJ_' >联系作者,提建议,寻求帮助,自定义样式,脚本定制点我</a></li>" +
  583. " </ul>\n" +
  584. " <span id='sp-ac-cancelbutton' class='sp-ac-spanbutton' title='取消' style='position: relative !important;float: left !important;'>取消</span>\n" +
  585. " <span id='sp-ac-savebutton' class='sp-ac-spanbutton' title='保存设置' style='position: relative !important;float: right !important;'>保存</span>\n" +
  586. " </fieldset>\n" +
  587. " </div>\n" +
  588. " </div>";
  589. try {
  590. document.body.appendChild(Container);
  591. } catch (e) {
  592. console.log(e);
  593. }
  594. try {
  595. document.querySelector("#sp-ac-savebutton").addEventListener("click", function(){
  596. // 点击之后的保存功能
  597. ACConfig.isRedirectEnable = document.querySelector("#sp-ac-redirect").checked;
  598. ACConfig.isAdsEnable = document.querySelector("#sp-ac-ads").checked;
  599. ACConfig.AdsStyleEnable = document.querySelector("#sp-ac-style").checked;
  600. ACConfig.AdsStyleMode_Baidu = document.querySelector('input[name="sp-ac-a_force_style_baidu"]:checked').value;
  601. ACConfig.AdsStyleMode_Google = document.querySelector('input[name="sp-ac-a_force_style_google"]:checked').value;
  602. ACConfig.AdsStyleMode_Bing = document.querySelector('input[name="sp-ac-a_force_style_bing"]:checked').value;
  603. ACConfig.HuYan_Baidu = document.querySelector('input[name="sp-ac-huyan_style_baidu"]').checked;
  604. ACConfig.HuYan_Google = document.querySelector('input[name="sp-ac-huyan_style_google"]').checked;
  605. ACConfig.HuYan_Bing = document.querySelector('input[name="sp-ac-huyan_style_bing"]').checked;
  606. var imgurl = document.querySelector("#sp-ac-faviconUrl").value.trim();
  607. imgurl = (imgurl == "" || imgurl == null) ? "https://ws1.sinaimg.cn/large/6a155794ly1foijtdzhxhj200w00wjr5.jpg" : imgurl;
  608. ACConfig.isUserColorEnable = document.querySelector("#sp-ac-usercolor").checked;
  609. ACConfig.defaultHuYanColor = document.querySelector(".sp-ac-menuhuyanColor").value;
  610. ACConfig.isFaviconEnable = document.querySelector("#sp-ac-favicon").checked;
  611. ACConfig.defaultFaviconUrl = imgurl;
  612. ACConfig.doDisableSug = document.querySelector("#sp-ac-sug_origin").checked;
  613. ACConfig.isRightDisplayEnable = document.querySelector("#sp-ac-right").checked;
  614. ACConfig.isCounterEnable = document.querySelector("#sp-ac-counter").checked;
  615. ACConfig.isALineEnable = document.querySelector("#sp-ac-aline").checked;
  616. ACConfig.isUserStyleEnable = document.querySelector("#sp-ac-userstyle").checked;
  617. ACConfig.UserStyleText = document.querySelector("#sp-ac-userstyleTEXT").value.trim();
  618. GM.setValue("Config", ACConfig);
  619. setTimeout(function () {
  620. window.location.reload();
  621. }, 400);
  622. }, false);
  623. document.querySelector(".menu-box-container").addEventListener("click", function(e){
  624. var cur = e.srcElement || e.target;
  625. if(typeof(cur.dataset.color) != "undefined"){
  626. document.querySelector(".sp-ac-menuhuyanColor").value = cur.dataset.color;
  627. StyleManger.loadHuYanStyle(cur.dataset.color);
  628. }
  629. e.stopPropagation();
  630. });
  631. document.querySelector(".sp-ac-menuhuyanColor").addEventListener("keyup", function(e){
  632. StyleManger.loadHuYanStyle(document.querySelector(".sp-ac-menuhuyanColor").value);
  633. e.stopPropagation();
  634. });
  635. document.querySelectorAll("labelHide").forEach(function(per){
  636. per.addEventListener("click", function(e){
  637. var cur = e.srcElement || e.target;
  638. var className = cur.parentNode.className.replace("container-label ", "");
  639. AC_addStyle(".XX>label,.XX>br{display:unset !important;}.XX>labelhide{display:none !important;}".replace(/XX/gm, className), "AC-ShowHideItem-"+className, "body");
  640. e.stopPropagation();
  641. });
  642. });
  643. } catch (e) {
  644. }
  645. }
  646. var allNodes = document.querySelectorAll(".faviconT, .CounterT");
  647. for (var i = 0; i < allNodes.length; i++) {
  648. if (allNodes[i].getAttribute('acClick') == null) {
  649. allNodes[i].setAttribute('acClick', '1');
  650. try {
  651. allNodes[i].addEventListener('click', function (e) {
  652. return ACtoggleSettingDisplay(e);
  653. }, true);
  654. } catch (e) {
  655. console.log(e);
  656. }
  657. }
  658. }
  659. try {
  660. document.querySelector("body>#sp-ac-container").addEventListener('click', function (e) {
  661. e.stopPropagation(); // 阻止点击自身的时候关闭
  662. }, false);
  663. document.querySelector("body").addEventListener('click', function (e) {
  664. document.querySelector("#sp-ac-content").style.display = 'none';
  665. }, false);
  666. document.querySelector("#sp-ac-cancelbutton").addEventListener('click', function (e) {
  667. document.querySelector("#sp-ac-content").style.display = 'none';
  668. e.stopPropagation();
  669. }, false);
  670. } catch (e) {
  671. }
  672. }
  673.  
  674. function removeOnMouseDownFunc() {
  675. try {
  676. var resultNodes = document.querySelectorAll(".g .rc .r a");
  677. for (var i = 0; i < resultNodes.length; i++) {
  678. var one = resultNodes[i];
  679. one.setAttribute("onmousedown", ""); // 谷歌去重定向干扰
  680. one.setAttribute("target", "_blank"); // 谷歌链接新标签打开
  681. }
  682. } catch (e) {
  683. console.log(e);
  684. }
  685. }
  686.  
  687. function removeRedirectLinkTarget() {
  688. if (SiteTypeID == SiteType.ZHIHU) {
  689. var nodes = document.querySelectorAll(".RichText a[href*='//link.zhihu.com/?target']");
  690. for (var i = 0; i < nodes.length; i++) {
  691. var url = decodeURIComponent(nodes[i].href.replace(/https?:\/\/link\.zhihu\.com\/\?target=/, ""));
  692. nodes[i].href = url;
  693. }
  694. } else if (SiteTypeID == SiteType.BAIDU_XUESHU) {
  695. var xnodes = document.querySelectorAll("a[href*='sc_vurl=http']");
  696. for (var j = 0; i < xnodes.length; j++) {
  697. var xurl = getUrlAttribute(xnodes[j].href, "sc_vurl", true);
  698. xnodes[j].href = xurl;
  699. }
  700. }
  701. }
  702.  
  703. function AC_addStyle(css, className, addToTarget, isReload, initType) { // 添加CSS代码,不考虑文本载入时间,带有className
  704. debug("样式IN-"+className);
  705. var tout = setInterval(function () {
  706. /**
  707. * addToTarget这里不要使用head标签,head标签的css会在html载入时加载,
  708. * html加载后似乎不会再次加载,body会自动加载
  709. * **/
  710. debug("样式preload-"+className);
  711. var addTo = document.querySelector(addToTarget);
  712. if(typeof(addToTarget) == "undefined")
  713. addTo = (document.head || document.body || document.documentElement || document);
  714. isReload = isReload || false; // 默认是非加载型
  715. initType = initType || "text/css";
  716. // 如果没有目标节点(则直接加) || 有目标节点且找到了节点(进行新增)
  717. if (typeof(addToTarget) == "undefined" || (typeof(addToTarget)!="undefined" && document.querySelector(addToTarget) != null)) {
  718. clearInterval(tout);
  719. // 如果true 强行覆盖,不管有没有--先删除
  720. // 如果false,不覆盖,但是如果有的话,要退出,不存在则新增--无需删除
  721. if (isReload == true) {
  722. safeRemove("." + className);
  723. } else if (isReload == false && document.querySelector("." + className) != null) {
  724. // 节点存在 && 不准备覆盖
  725. return;
  726. }
  727. var cssNode = document.createElement("style");
  728. if (className != null) cssNode.className = className;
  729. cssNode.setAttribute("type", initType);
  730. cssNode.innerHTML = css;
  731. try {
  732. addTo.appendChild(cssNode);
  733. debug("样式load-"+className);
  734. } catch (e) {
  735. console.log(e.message);
  736. }
  737. }
  738. }, 20);
  739. }
  740.  
  741. function getUrlAttribute(url, attribute, needDecode) {
  742. var searchValueS = (url.substr(1) + "").split("&");
  743. for (var i = 0; i < searchValueS.length; i++) {
  744. var key_value = searchValueS[i].split("=");
  745. var reg = new RegExp("^" + attribute + "$");
  746. if (reg.test(key_value[0])) {
  747. var searchWords = key_value[1];
  748. return needDecode ? decodeURIComponent(searchWords) : searchWords;
  749. }
  750. }
  751. }
  752.  
  753. function resetURLNormal(list) {
  754. for (var i = 0; i < list.length; i++) {
  755. // 此方法是异步,故在结束的时候使用i会出问题-严重!
  756. // 采用闭包的方法来进行数据的传递
  757. var curNode = list[i];
  758. var curhref = curNode.href;
  759. var trueUrlNoBaidu = "";
  760. try {
  761. var node = curNode.parentNode.parentNode;
  762. if (node.className.indexOf("result") >= 0) {
  763. trueUrlNoBaidu = node.querySelector(FaviconType).innerHTML;
  764. trueUrlNoBaidu = replaceAll(trueUrlNoBaidu);
  765. }
  766. } catch (e) {
  767. }
  768. if (IsinBaiduBlockLists(trueUrlNoBaidu)) {
  769. document.querySelector("a[href*='" + curhref + "']").setAttribute("ac_redirectStatus", "-2"); // 丢弃特殊的百度自身的地址【百度知道、百度贴吧】
  770. continue;
  771. }
  772. if (list[i] != null && list[i].getAttribute("ac_redirectStatus") == null) {
  773. list[i].setAttribute("ac_redirectStatus", "0");
  774. if (curhref.indexOf("www.baidu.com/link") > -1 ||
  775. curhref.indexOf("m.baidu.com/from") > -1 ||
  776. curhref.indexOf("www.sogou.com/link") > -1 ||
  777. curhref.indexOf("so.com/link") > -1) {
  778. (function (c_curnode, c_curhref) {
  779. var url = c_curhref.replace(/^http:/, "https:");
  780. if (SiteTypeID == SiteType.BAIDU && url.indexOf("eqid") < 0) {
  781. // 如果是百度,并且没有带有解析参数,那么手动带上
  782. url = url + "&wd=&eqid=";
  783. }
  784. var gmRequestNode = GM_xmlhttpRequest({
  785. // from: "acxhr",
  786. extData: c_curhref, // 用于扩展
  787. url: url,
  788. headers: {"Accept": "*/*", "Referer": c_curhref.replace(/^http:/, "https:")},
  789. method: "GET",
  790. timeout: 5000,
  791. onreadystatechange: function (response) {
  792. // 由于是特殊返回-并且好搜-搜狗-百度都是这个格式,故提出
  793. DealRedirect(gmRequestNode, c_curhref, response.responseText, "URL='([^']+)'")
  794. // 这个是在上面无法处理的情况下,备用的 tm-finalurldhdg tm-finalurlmfdh
  795. if (response.responseHeaders.indexOf("tm-finalurl") >= 0) {
  796. var relURL = Reg_Get(response.responseHeaders, "tm-finalurl\\w+: ([^\\s]+)");
  797. if (relURL == null || relURL == "" || relURL.indexOf("www.baidu.com/search/error") > 0) return;
  798. DealRedirect(gmRequestNode, c_curhref, relURL);
  799. }
  800. }
  801. });
  802. })(curNode, curhref); //传递旧的网址过去,读作c_curhref
  803. }
  804. }
  805. }
  806. }
  807.  
  808. var DealRedirect = function (request, curNodeHref, respText, RegText) {
  809. if (respText == null || typeof(respText) == "undefined") return;
  810. var resultResponseUrl = "";
  811. if (RegText != null) {
  812. resultResponseUrl = Reg_Get(respText, RegText);
  813. } else {
  814. resultResponseUrl = respText;
  815. }
  816. if (resultResponseUrl != null && resultResponseUrl != "" && resultResponseUrl.indexOf("www.baidu.com/link") < 0) {
  817. try {
  818. if (SiteTypeID == SiteType.SOGOU) curNodeHref = curNodeHref.replace(/^https:\/\/www.sogou.com/, "");
  819. var changeNodeList = document.querySelectorAll("a[href*='" + curNodeHref + "']");
  820. for (var i = 0; i < changeNodeList.length; i++) {
  821. changeNodeList[i].setAttribute("ac_redirectStatus", "2");
  822. changeNodeList[i].setAttribute("href", resultResponseUrl);
  823. }
  824. request.abort();
  825. } catch (e) {
  826. }
  827. }
  828. };
  829.  
  830. function Reg_Get(HTML, reg) {
  831. var RegE = new RegExp(reg);
  832. try {
  833. return RegE.exec(HTML)[1];
  834. } catch (e) {
  835. return "";
  836. }
  837. }
  838.  
  839. function removeAD_baidu_sogou() { // 移除百度自有广告
  840. if (SiteTypeID == SiteType.BAIDU) {
  841. // safeRemove(".c-container /deep/ .c-container");
  842. // 移除shadowDOM广告;搜索关键字:淘宝;然后点击搜索框,广告会多次重现shadowdom
  843. safeRemove(function(){
  844. $('.c-container /deep/ .c-container').has('.f13>span:contains("广告")').remove();
  845. });
  846. safeRemove(function(){
  847. $('#content_right>div').has('a:contains("广告")').remove();
  848. });
  849. // 移除标准广告
  850. safeRemove(function(){
  851. $('#content_left>div').has('span:contains("广告")').remove();
  852. });
  853. // 移除右侧栏顶部-底部无用广告
  854. safeRemove(function(){
  855. $("#content_right td>div:not([id]),#content_right>br").remove();
  856. });
  857. } else if (SiteTypeID == SiteType.SOGOU) {
  858. safeRemove("#promotion_adv_container");
  859. safeRemove("#kmap_business_title");
  860. safeRemove("#kmap_business_ul");
  861. safeRemove(".sponsored");
  862. try {
  863. document.querySelector(".rvr-model[style='width:250px;']").style = "display:none";
  864. } catch (e) {
  865. }
  866. } else if (SiteTypeID == SiteType.SO) {
  867. safeRemove("#so_kw-ad");
  868. safeRemove("#m-spread-left");
  869. safeRemove("#m-spread-bottom");
  870. } else if(SiteTypeID == SiteType.BING){
  871. safeRemove(".b_ad");
  872. }
  873. }
  874.  
  875. function IsNumber(val) {
  876. if (val === "" || val == null) {
  877. return false;
  878. }
  879. if (!isNaN(val)) {
  880. return true;
  881. } else {
  882. return false;
  883. }
  884. }
  885.  
  886. function addCounter(citeList) {
  887. var cssText = "position:relative;z-index:1;margin-right:4px;display:inline-block;color:white;font-family:'微软雅黑';font-size:16px;text-align:center;width:22px;line-height:22px;border-radius:50%;";
  888. var div = document.createElement('div');
  889. for (var i = 0; i < citeList.length; i++) {
  890. if (citeList[i].getAttribute('sortIndex')) {
  891. continue;
  892. } else {
  893. citeList[i].setAttribute('sortIndex', sortIndex);
  894. citeList[i].inner = citeList[i].innerHTML;
  895. if (IsNumber(citeList[i].parentNode.id)) {
  896. // 如果是百度的数据
  897. div.innerHTML = "<div class='CounterT' style=" + cssText + ">" + (citeList[i].parentNode.id % 100) + "</div>";
  898. citeList[i].innerHTML = div.innerHTML + citeList[i].inner;
  899. } else {
  900. div.innerHTML = "<div class='CounterT' style=" + cssText + ">" + sortIndex + "</div>";
  901. citeList[i].innerHTML = div.innerHTML + citeList[i].inner;
  902. }
  903. sortIndex++;
  904. }
  905. }
  906. }
  907.  
  908. function safeRemove(cssSelector) {
  909. if(typeof(cssSelector) == "string"){
  910. try {
  911. var removeNodes = document.querySelectorAll(cssSelector);
  912. for (var i = 0; i < removeNodes.length; i++)
  913. removeNodes[i].remove();
  914. } catch (e) {
  915. }
  916. }else if(typeof(cssSelector) == "function"){
  917. try{
  918. cssSelector();
  919. }catch (e) {}
  920. }else{
  921. console.log("未知命令:"+cssSelector);
  922. }
  923. }
  924.  
  925. function replaceAll(sbefore) {
  926. var send;
  927. var result = sbefore.split('-');
  928. if (SiteTypeID == SiteType.SOGOU && location.href.indexOf("sogou") < 20) {
  929. // --搜狗专用;如果第一个是中文的话,地址就是第二个
  930. sbefore = result[1];
  931. }
  932. send = sbefore.replace(/(\/[^/]*|\s*)/, "").replace(/<[^>]*>/g, "").replace(/https?:\/\//g, "").replace(/<\/?strong>/g, "").replace(/<\/?b>/g, "").replace(/<?>?/g, "").replace(/( |\/).*/g, "");
  933. return send;
  934. }
  935.  
  936. function IsinBaiduBlockLists(url) {
  937. // if(url == null) return true;
  938. // if(url.indexOf("zhidao.baidu.com") >= 0) return true;
  939. // if(url.indexOf("teiba.baidu.com") >= 0) return true;
  940. return false;
  941. }
  942.  
  943. function addFavicon(citeList) {
  944. for (var index = 0; index < citeList.length; index++) {
  945. var url = replaceAll(citeList[index].innerHTML);
  946. //console.log(index+"."+url);
  947. if (null == citeList[index].getAttribute("ac_faviconStatus")) {
  948. if (url == "") {
  949. console.log("无效地址:" + citeList[index].innerHTML);
  950. citeList[index].setAttribute("ac_faviconStatus", "-1");
  951. continue;
  952. }
  953. var curNode = citeList[index];
  954. var faviconUrl = url;
  955. var II = 0;
  956. for (; II <= 5; II++) {
  957. curNode = curNode.parentNode;
  958. if (curNode != null && curNode.querySelector(FaviconAddTo) != null) {
  959. break;
  960. }
  961. }
  962. //console.log(index+"."+faviconUrl+"--"+II);
  963. if (II <= 5) {
  964. // 先用父节点判断一下是否存在img
  965. var tmpHTML = curNode.innerHTML;
  966. var pos = tmpHTML.indexOf("fav-url")
  967. & tmpHTML.indexOf("favurl")
  968. & tmpHTML.indexOf("tit-ico")
  969. & tmpHTML.indexOf("img_fav rms_img")
  970. & tmpHTML.indexOf("c-tool-")
  971. & tmpHTML.indexOf("span class=\"c-icon c-icon-");
  972. //他自己已经做了favicon了
  973. if (pos > -1) {
  974. console.log("已有图片:");
  975. citeList[index].setAttribute("ac_faviconStatus", "-2");
  976. continue;
  977. }
  978. curNode = curNode.querySelector(FaviconAddTo);
  979. // 特殊处理BING
  980. // if (SiteTypeID == SiteType.BING) curNode = curNode.querySelector("h2");
  981. //https://api.byi.pw/favicon/?url=???? 不稳定
  982. //http://"+faviconUrl+"/cdn.ico?defaulticon=http://soz.im/favicon.ico 不稳定
  983. //https://www.xtwind.com/api/index.php?url=???? 挂了。。。
  984. //https://statics.dnspod.cn/proxy_favicon/_/favicon?domain=sina.cn
  985. //www.google.com/s2/favicons?domain=764350177.lofter.com
  986. //如果地址不正确,那么丢弃
  987. var host = faviconUrl.replace(/[^.]+\.([^.]+)\.([^.]+)/, "$1.$2");
  988. if (curNode.querySelector(".faviconT") == null && host.length > 3) {
  989. var insNode = document.createElement("img");
  990. // curNode = curNode.children[0] || curNode.firstChild ; // firstChild容易遇到text对象
  991. citeList[index].setAttribute("ac_faviconStatus", "1");
  992. // curNode.insertBefore(insNode, curNode.firstChild);
  993. insNode.className = "faviconT";
  994. insNode.style = "position:relative;z-index:1;vertical-align:sub;height:16px;width:16px;margin-right:5px;margin-bottom: 2px;";
  995. insNode.src = "https://favicon.yandex.net/favicon/" + host;
  996. insNode.setAttribute("faviconID", "0");
  997. insNode.onload = function (eveNode) {
  998. if (eveNode.target.naturalWidth < 16) {
  999. eveNode.target.src = ACConfig.defaultFaviconUrl;
  1000. eveNode.target.onload = null;
  1001. }
  1002. };
  1003. curNode.innerHTML = insNode.outerHTML + curNode.innerHTML;
  1004. }
  1005. }
  1006. }
  1007. }
  1008. }
  1009.  
  1010. function InsertSettingMenu() {
  1011. if (document.querySelector("#myuser") == null) {
  1012. try {
  1013. var parent = document.querySelector("#u, #gbw>div>div, #b_header>#id_h"); //baidu; google; bing
  1014. parent.style = "width: auto;";
  1015. var userAdiv = document.createElement("div");
  1016. userAdiv.id = "myuser";
  1017. userAdiv.innerHTML = "<input type='submit' class='myuserconfig' value='自定义'/><span class='ac-newversionDisplay' style='background-color: red;left: 0px;top: 0px;float: right;height: 8px;width: 8px;border-radius: 4px;display:" + (hasNewFuncNeedDisplay ? "unset" : "none") + "'>&nbsp;</span>";
  1018. parent.insertBefore(userAdiv, parent.childNodes[0]);
  1019. document.querySelector("#myuser .myuserconfig").addEventListener("click", function(e){
  1020. return ACtoggleSettingDisplay(e);
  1021. }, true);
  1022.  
  1023. } catch (e) {
  1024. }
  1025. }
  1026. }
  1027. function clip255(value){
  1028. if(value > 255) return 255;
  1029. if(value < 0) return 0;
  1030. return value;
  1031. }
  1032. function Lighter(oriRGB, deltaY){
  1033. // 按比例缩放 + 1/deltaY
  1034. // HEX 2 RGB
  1035. var rgb = oriRGB.replace("#", "");
  1036. var R = parseInt("0x"+rgb.substr(0, 2));
  1037. var G = parseInt("0x"+rgb.substr(2, 2));
  1038. var B = parseInt("0x"+rgb.substr(4, 2));
  1039. // RGB 2 YUV
  1040. var Y = ( ( 66 * R + 129 * G + 25 * B + 128) >> 8) + 16;
  1041. var U = ( ( -38 * R - 74 * G + 112 * B + 128) >> 8) + 128;
  1042. var V = ( ( 112 * R - 94 * G - 18 * B + 128) >> 8) + 128;
  1043. Y = Y * (1+1.0/deltaY);// 提高亮度
  1044. // YUV 2 RGB
  1045. R = clip255(( 298 * (Y - 16) + 409 * (V - 128) + 128) >> 8);
  1046. G = clip255(( 298 * (Y - 16) - 100 * (U - 128) - 208 * (V - 128) + 128) >> 8);
  1047. B = clip255(( 298 * (Y - 16) + 516 * (U - 128) + 128) >> 8);
  1048. return "#"+((R<<16) + (G<<8) + B).toString(16);
  1049. }
  1050. function checkDocmentHasNode(nodeClass){
  1051. for(var i = 0; i < document.childNodes.length; i++){
  1052. if(document.childNodes[i].data && document.childNodes[i].data.indexOf(nodeClass) > 0)
  1053. return true;
  1054. }
  1055. return false;
  1056. }
  1057. function FSBaidu() { // thanks for code from 浮生@未歇 @page https://gf.qytechs.cn/zh-TW/scripts/31642
  1058. debug("初始化FSBAIDU");
  1059. var StyleManger = {
  1060. importStyle: function (data, toClassName) {
  1061.  
  1062. if(navigator.userAgent.toLowerCase().indexOf("edge") < 0){
  1063. if(data.indexOf("http") != 0) data = "data:text/css;utf-8," + encodeURIComponent(data);
  1064. if(!checkDocmentHasNode(toClassName)){
  1065. var pi = document.createProcessingInstruction(
  1066. "xml-stylesheet",
  1067. `type="text/plain" class="${toClassName}" href="${data}"`
  1068. ); // 注意必须要双引号
  1069. document.insertBefore(pi, document.documentElement);
  1070. }
  1071. }else{
  1072. /* **********多重样式-兼容edge && 黑夜脚本************ */
  1073. AC_addStyle(data, toClassName, "head", false, "text/plain");
  1074. /* **********多重样式-兼容edge && 黑夜脚本************ */
  1075. }
  1076. },
  1077. isLocalDebug : isdebug || false, // 如果是debug状态那么是载入本地样式调试
  1078. //加载普通样式
  1079. loadCommonStyle: function () {
  1080. this.loadStyle(keySite + "CommonStyle", keySite + "CommonStyle");
  1081. try {
  1082. $("#result_logo img, .index-logo-src, .index-logo-src").setAttribute("src", "https://ws1.sinaimg.cn/large/6a155794ly1fkx1uhxfz6j2039012wen.jpg");
  1083. } catch (e) {
  1084. }
  1085. },
  1086. // isLocalDebug : false, // 如果是debug状态那么是载入本地样式调试
  1087. loadStyle : function(styleName, insClassName){
  1088. // 全部采用text/plain的内容来载入
  1089. // 如果是debug模式。或者是gm模式
  1090. if(this.isLocalDebug){
  1091. debug("本地-加载样式:"+insClassName);
  1092. this.importStyle("http://127.0.0.1/" + styleName+".css", "AC-"+insClassName);
  1093. }else if(isNewGM == true){
  1094. // 仅用于GreaseMonkey4.0+
  1095. debug("特殊模式-加载样式:"+insClassName);
  1096. this.importStyle("https://baidu.ntaow.com/baiducss/" + styleName+".css", "AC-"+insClassName);
  1097. }else{
  1098. debug("加载样式:"+insClassName);
  1099. // TamperMonkey + GreaseMonkey < 4.0 + ViolentMonkey (4.0GreaseMonkey不支持GetResource方法)
  1100. this.importStyle(GM_getResourceText(styleName), "AC-"+insClassName);
  1101. }
  1102. },
  1103. //加载护眼模式样式
  1104. loadHuYanStyle: function (color) {
  1105. var style = "body,#head,#s_tab{background-color:#fff}#content_left .result-op,#content_left .result,#container #rs,#container #content_right{background-color:#aaa;border:1px double #a2d7d4;border-radius:0}#content_left .result-op:hover,#content_left .result:hover{background-color:#ccc!important}#content_left .result-op h3,#content_left .c-container h3,#rs .tt{background-color:#bbb}.na_cnt .nws_itm,.nws_itmb,#b_results li{background-color:#aaa;border:1px double #a2d7d4;border-radius:0}#b_results li:hover{background-color:#ccc!important}#b_content>#b_results li h2{background-color:#bbb}.srg .g,.bkWMgd>.g,.bkWMgd g-inner-card,#rhscol #rhs,#rhscol #rhs .g>div, .c2xzTb .g, .ruTcId .g, .fm06If .g, .cUnQKe .g, .HanQmf .g{background-color:#aaa;border:1px double #a2d7d4;border-radius:0}.srg .g:hover,.bkWMgd>.g:hover{background-color:#ccc!important}.bkWMgd .g div.r,.srg .g h3{background-color:#bbb}";
  1106. if(ACConfig.isUserColorEnable){
  1107. color = color || ACConfig.defaultHuYanColor || "#FFFFFF";
  1108. }else{
  1109. color = color || "#FFFFFF";
  1110. }
  1111. if(color.indexOf("#") != 0 || color.length < 7) return;
  1112. if(isNewGM == false){
  1113. style = GM_getResourceText("MainHuYanStyle");
  1114. }
  1115. style = style
  1116. .replace(/#aaa(a*)/igm, color)
  1117. .replace(/#bbb(b*)/igm, Lighter(color, -40))
  1118. .replace(/#ccc(c*)/igm, Lighter(color, 45));
  1119. AC_addStyle(style, "AC-" + keySite + "HuYanStyle" + (isNewGM?"":"-File"), "head", true, "text/css");
  1120. },
  1121. //加载单页样式
  1122. loadOnePageStyle: function () {
  1123. this.loadStyle(keySite + "OnePageStyle", keySite + "OnePageStyle");
  1124. },
  1125. //加载双页样式
  1126. loadTwoPageStyle: function () {
  1127. this.loadStyle(keySite + "TwoPageStyle", keySite + "TwoPageStyle");
  1128. },
  1129. // 加载三列样式
  1130. loadThreePageStyle:function(){
  1131. var cssHead = "";
  1132. if(SiteTypeID == SiteType.BAIDU) cssHead = "#container #content_left";
  1133. if(SiteTypeID == SiteType.GOOGLE) cssHead = ".srg,#acid_src";
  1134. if(SiteTypeID == SiteType.BING) cssHead = "#b_content #b_results";
  1135. AC_addStyle(cssHead+"{grid-template-columns: repeat(auto-fit,minmax(33%,1fr));}#container #content_left>*:not([class*='result']){grid-column-end: 4;}", "AC-ThreePageStyle", "head");
  1136. },
  1137. // 加载四列样式
  1138. loadFourPageStyle:function(){
  1139. var cssHead = "";
  1140. if(SiteTypeID == SiteType.BAIDU) cssHead = "#container #content_left";
  1141. if(SiteTypeID == SiteType.GOOGLE) cssHead = ".srg,#acid_src";
  1142. if(SiteTypeID == SiteType.BING) cssHead = "b_content #b_results";
  1143. AC_addStyle(cssHead+"{grid-template-columns: repeat(auto-fit,minmax(25%,1fr));}#container #content_left>*:not([class*='result']){grid-column-end: 5;}", "AC-FourPageStyle", "head");
  1144. },
  1145. loadExpandOneStyle: function () {
  1146. AC_addStyle(
  1147. "#content_left .result-op:hover,#content_left .result:hover{box-shadow:0 0 2px gray;background:rgba(230,230,230,0.1)!important;}" +
  1148. "#content_left .result,#content_left .result-op{width:100%; min-width:670px;margin-bottom:14px!important;}" +
  1149. ".c-span18{width:78%!important;min-width:550px;}" +
  1150. ".c-span24{width: auto!important;}", "AC-Style-expand", "head");
  1151. },
  1152. loadPlainToCSS: function(){
  1153. for(var i = 0 ; i < document.childNodes.length; i++){
  1154. var curNode = document.childNodes[i];
  1155. if(curNode.target == "xml-stylesheet" && curNode.data.indexOf("text/plain") > 0){
  1156. curNode.data = curNode.data.replace("type=\"text/plain\"", "type=\"text/css\"");
  1157. }
  1158. }
  1159. if(navigator.userAgent.toLowerCase().indexOf("edge") > 0){
  1160. document.querySelectorAll("style[class*='AC'][type='text/plain']").forEach(function (per) {
  1161. per.setAttribute("type", "text/css");
  1162. var insCSS = document.createElement("style");
  1163. insCSS.innerHTML = per.innerHTML;
  1164. insCSS.className = per.className + "-new";
  1165. per.setAttribute("used", "不生效,无用");
  1166. document.head.appendChild(insCSS)
  1167. });
  1168. }
  1169. },
  1170. loadCSSToPlain: function(){
  1171. for(var i = 0 ; i < document.childNodes.length; i++){
  1172. var curNode = document.childNodes[i];
  1173. if(curNode.target == "xml-stylesheet" && curNode.data.indexOf("text/css") > 0){
  1174. curNode.data = curNode.data.replace("type=\"text/css\"", "type=\"text/plain\"");
  1175. }
  1176. }
  1177. }
  1178. };
  1179. var ControlManager = {
  1180. twoPageDisplay: function () {
  1181. // 定时查询
  1182. try {
  1183. var tI = setInterval(function () {
  1184. if (SiteTypeID == SiteType.GOOGLE) {
  1185. if (document.querySelector("#ires>#rso>.bkWMgd") != null) {
  1186. clearInterval(tI);
  1187. var insSrc = document.createElement("div");
  1188. insSrc.id = "acid_src";
  1189. insSrc.className = "bkWMgd";
  1190. if (!document.querySelector("#acid_src")) {
  1191. var child = document.querySelector("#ires>#rso>.bkWMgd");
  1192. child.parentNode.insertBefore(insSrc, child);
  1193. }
  1194. var moveNodes;
  1195. moveNodes = document.querySelectorAll(".bkWMgd:not([id])>div:not([class='srg'])");
  1196. for (var i = 0; i < moveNodes.length; i++) {
  1197. insSrc.insertBefore(moveNodes[i], insSrc.children[0]);
  1198. }
  1199. }
  1200. } else {
  1201. }
  1202. }, 50);
  1203. } catch (e) {
  1204. console.log(e);
  1205. }
  1206. },
  1207. //居中显示 --- 必须是百度和谷歌的搜索结果页面,其他页面不能加载的--已经通过脚本include标签限制了一部分
  1208. centerDisplay: function () {
  1209. var result = AdsStyleMode || null;
  1210. if (document.querySelector(".acCssLoadFlag") == null && document.querySelector(".ACExtension") == null) {
  1211. debug("in样式即将加载");
  1212. var xflag = document.createElement("div");
  1213. xflag.className = "acCssLoadFlag";
  1214. document.head.appendChild(xflag);
  1215. if (result == 1) {
  1216. StyleManger.loadExpandOneStyle();
  1217. StyleManger.loadCommonStyle();
  1218. } else if (result == 2) {//单页居中
  1219. StyleManger.loadExpandOneStyle();
  1220. StyleManger.loadCommonStyle();
  1221. StyleManger.loadOnePageStyle();
  1222. } else if (result == 3) { //双页居中
  1223. this.twoPageDisplay();
  1224. StyleManger.loadCommonStyle();
  1225. StyleManger.loadTwoPageStyle();
  1226. } else if(result == 4){ // 三列
  1227. this.twoPageDisplay();
  1228. StyleManger.loadCommonStyle();
  1229. StyleManger.loadTwoPageStyle();
  1230. StyleManger.loadThreePageStyle();
  1231. } else if(result == 5){ // 四列
  1232. this.twoPageDisplay();
  1233. StyleManger.loadCommonStyle();
  1234. StyleManger.loadTwoPageStyle();
  1235. StyleManger.loadFourPageStyle();
  1236. }
  1237. debug("in样式运行结束");
  1238. }else{
  1239. debug("-in样式数据失败");
  1240. }
  1241. if (SiteTypeID != SiteType.BAIDU && SiteTypeID != SiteType.GOOGLE && SiteTypeID != SiteType.BING) return;
  1242. // 如果是百度 && ((地址替换->包含wd关键词[替换之后不等-是百度结果页面]) || 有右边栏-肯定是百度搜索结果页 || value中存在搜索内容) return;
  1243. // 如果是百度 && 没有(百度搜索结果的标志-[存在]百度的内容) return;
  1244. if (SiteTypeID == SiteType.BAIDU && !(location.href.replace(/(&|\?)wd=/, "") != location.href || document.querySelector("#content_left") ||
  1245. ((document.querySelector("#kw") && document.querySelector("#kw").getAttribute("value"))||"") != ""
  1246. )) {
  1247. StyleManger.loadCSSToPlain();
  1248. return;
  1249. }
  1250. // 如果是谷歌 && (地址替换->是谷歌图像页面 || 是地图页面)[替换要变] return;
  1251. if (SiteTypeID == SiteType.GOOGLE && location.href.replace(/tbm=(isch|lcl|shop|flm)/, "") != location.href){
  1252. StyleManger.loadCSSToPlain();
  1253. return;
  1254. }
  1255. /**护眼Style最后载入**/
  1256. if(HuYanMode == true || document.querySelector("style[class*='darkreader']")!=null) StyleManger.loadHuYanStyle();
  1257. // 启用所有样式表
  1258. StyleManger.loadPlainToCSS();
  1259. },
  1260. init: function () {
  1261. if (isGoogleImageUrl) return;
  1262. this.centerDisplay();
  1263. }
  1264. };
  1265. debug("调用加载自定义css");
  1266. ControlManager.init();
  1267. return StyleManger;
  1268. }
  1269. }(); // 读取个人设置信息
  1270. }
  1271. })();
  1272. }();

QingJ © 2025

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