谷歌搜索:新建标签页打开链接

点击搜索结果中的链接时在新标签页中打开

安装此脚本?
作者推荐脚本

您可能也喜欢IBM-Weather-UI

安装此脚本
  1. // ==UserScript==
  2. // @name Google-open-in-new-tab
  3. // @name:ZH-CN 谷歌搜索:新建标签页打开链接
  4. // @name:ZH-TW 谷歌搜尋:新建標籤頁打開鏈接
  5. // @namespace https://github.com/li-zyang/
  6. // @version 1.0.2
  7. // @description Open links in the google search results in a new tab
  8. // @description:ZH-CN 点击搜索结果中的链接时在新标签页中打开
  9. // @description:ZH-TW 點擊搜索結果中的鏈接時在新標籤頁中打開
  10. // @author 阿昭
  11. // @include https://www.google.com/*
  12. // @include https://www.google.ad/*
  13. // @include https://www.google.ae/*
  14. // @include https://www.google.com.af/*
  15. // @include https://www.google.com.ag/*
  16. // @include https://www.google.com.ai/*
  17. // @include https://www.google.al/*
  18. // @include https://www.google.am/*
  19. // @include https://www.google.co.ao/*
  20. // @include https://www.google.com.ar/*
  21. // @include https://www.google.as/*
  22. // @include https://www.google.at/*
  23. // @include https://www.google.com.au/*
  24. // @include https://www.google.az/*
  25. // @include https://www.google.ba/*
  26. // @include https://www.google.com.bd/*
  27. // @include https://www.google.be/*
  28. // @include https://www.google.bf/*
  29. // @include https://www.google.bg/*
  30. // @include https://www.google.com.bh/*
  31. // @include https://www.google.bi/*
  32. // @include https://www.google.bj/*
  33. // @include https://www.google.com.bn/*
  34. // @include https://www.google.com.bo/*
  35. // @include https://www.google.com.br/*
  36. // @include https://www.google.bs/*
  37. // @include https://www.google.bt/*
  38. // @include https://www.google.co.bw/*
  39. // @include https://www.google.by/*
  40. // @include https://www.google.com.bz/*
  41. // @include https://www.google.ca/*
  42. // @include https://www.google.cd/*
  43. // @include https://www.google.cf/*
  44. // @include https://www.google.cg/*
  45. // @include https://www.google.ch/*
  46. // @include https://www.google.ci/*
  47. // @include https://www.google.co.ck/*
  48. // @include https://www.google.cl/*
  49. // @include https://www.google.cm/*
  50. // @include https://www.google.cn/*
  51. // @include https://www.google.com.co/*
  52. // @include https://www.google.co.cr/*
  53. // @include https://www.google.com.cu/*
  54. // @include https://www.google.cv/*
  55. // @include https://www.google.com.cy/*
  56. // @include https://www.google.cz/*
  57. // @include https://www.google.de/*
  58. // @include https://www.google.dj/*
  59. // @include https://www.google.dk/*
  60. // @include https://www.google.dm/*
  61. // @include https://www.google.com.do/*
  62. // @include https://www.google.dz/*
  63. // @include https://www.google.com.ec/*
  64. // @include https://www.google.ee/*
  65. // @include https://www.google.com.eg/*
  66. // @include https://www.google.es/*
  67. // @include https://www.google.com.et/*
  68. // @include https://www.google.fi/*
  69. // @include https://www.google.com.fj/*
  70. // @include https://www.google.fm/*
  71. // @include https://www.google.fr/*
  72. // @include https://www.google.ga/*
  73. // @include https://www.google.ge/*
  74. // @include https://www.google.gg/*
  75. // @include https://www.google.com.gh/*
  76. // @include https://www.google.com.gi/*
  77. // @include https://www.google.gl/*
  78. // @include https://www.google.gm/*
  79. // @include https://www.google.gr/*
  80. // @include https://www.google.com.gt/*
  81. // @include https://www.google.gy/*
  82. // @include https://www.google.com.hk/*
  83. // @include https://www.google.hn/*
  84. // @include https://www.google.hr/*
  85. // @include https://www.google.ht/*
  86. // @include https://www.google.hu/*
  87. // @include https://www.google.co.id/*
  88. // @include https://www.google.ie/*
  89. // @include https://www.google.co.il/*
  90. // @include https://www.google.im/*
  91. // @include https://www.google.co.in/*
  92. // @include https://www.google.iq/*
  93. // @include https://www.google.is/*
  94. // @include https://www.google.it/*
  95. // @include https://www.google.je/*
  96. // @include https://www.google.com.jm/*
  97. // @include https://www.google.jo/*
  98. // @include https://www.google.co.jp/*
  99. // @include https://www.google.co.ke/*
  100. // @include https://www.google.com.kh/*
  101. // @include https://www.google.ki/*
  102. // @include https://www.google.kg/*
  103. // @include https://www.google.co.kr/*
  104. // @include https://www.google.com.kw/*
  105. // @include https://www.google.kz/*
  106. // @include https://www.google.la/*
  107. // @include https://www.google.com.lb/*
  108. // @include https://www.google.li/*
  109. // @include https://www.google.lk/*
  110. // @include https://www.google.co.ls/*
  111. // @include https://www.google.lt/*
  112. // @include https://www.google.lu/*
  113. // @include https://www.google.lv/*
  114. // @include https://www.google.com.ly/*
  115. // @include https://www.google.co.ma/*
  116. // @include https://www.google.md/*
  117. // @include https://www.google.me/*
  118. // @include https://www.google.mg/*
  119. // @include https://www.google.mk/*
  120. // @include https://www.google.ml/*
  121. // @include https://www.google.com.mm/*
  122. // @include https://www.google.mn/*
  123. // @include https://www.google.ms/*
  124. // @include https://www.google.com.mt/*
  125. // @include https://www.google.mu/*
  126. // @include https://www.google.mv/*
  127. // @include https://www.google.mw/*
  128. // @include https://www.google.com.mx/*
  129. // @include https://www.google.com.my/*
  130. // @include https://www.google.co.mz/*
  131. // @include https://www.google.com.na/*
  132. // @include https://www.google.com.ng/*
  133. // @include https://www.google.com.ni/*
  134. // @include https://www.google.ne/*
  135. // @include https://www.google.nl/*
  136. // @include https://www.google.no/*
  137. // @include https://www.google.com.np/*
  138. // @include https://www.google.nr/*
  139. // @include https://www.google.nu/*
  140. // @include https://www.google.co.nz/*
  141. // @include https://www.google.com.om/*
  142. // @include https://www.google.com.pa/*
  143. // @include https://www.google.com.pe/*
  144. // @include https://www.google.com.pg/*
  145. // @include https://www.google.com.ph/*
  146. // @include https://www.google.com.pk/*
  147. // @include https://www.google.pl/*
  148. // @include https://www.google.pn/*
  149. // @include https://www.google.com.pr/*
  150. // @include https://www.google.ps/*
  151. // @include https://www.google.pt/*
  152. // @include https://www.google.com.py/*
  153. // @include https://www.google.com.qa/*
  154. // @include https://www.google.ro/*
  155. // @include https://www.google.ru/*
  156. // @include https://www.google.rw/*
  157. // @include https://www.google.com.sa/*
  158. // @include https://www.google.com.sb/*
  159. // @include https://www.google.sc/*
  160. // @include https://www.google.se/*
  161. // @include https://www.google.com.sg/*
  162. // @include https://www.google.sh/*
  163. // @include https://www.google.si/*
  164. // @include https://www.google.sk/*
  165. // @include https://www.google.com.sl/*
  166. // @include https://www.google.sn/*
  167. // @include https://www.google.so/*
  168. // @include https://www.google.sm/*
  169. // @include https://www.google.sr/*
  170. // @include https://www.google.st/*
  171. // @include https://www.google.com.sv/*
  172. // @include https://www.google.td/*
  173. // @include https://www.google.tg/*
  174. // @include https://www.google.co.th/*
  175. // @include https://www.google.com.tj/*
  176. // @include https://www.google.tl/*
  177. // @include https://www.google.tm/*
  178. // @include https://www.google.tn/*
  179. // @include https://www.google.to/*
  180. // @include https://www.google.com.tr/*
  181. // @include https://www.google.tt/*
  182. // @include https://www.google.com.tw/*
  183. // @include https://www.google.co.tz/*
  184. // @include https://www.google.com.ua/*
  185. // @include https://www.google.co.ug/*
  186. // @include https://www.google.co.uk/*
  187. // @include https://www.google.com.uy/*
  188. // @include https://www.google.co.uz/*
  189. // @include https://www.google.com.vc/*
  190. // @include https://www.google.co.ve/*
  191. // @include https://www.google.vg/*
  192. // @include https://www.google.co.vi/*
  193. // @include https://www.google.com.vn/*
  194. // @include https://www.google.vu/*
  195. // @include https://www.google.ws/*
  196. // @include https://www.google.rs/*
  197. // @include https://www.google.co.za/*
  198. // @include https://www.google.co.zm/*
  199. // @include https://www.google.co.zw/*
  200. // @include https://www.google.cat/*
  201. // @exclude none
  202. // @require https://cdn.staticfile.org/jquery/3.4.1/jquery.min.js
  203. // @grant GM_setValue
  204. // @grant GM_getValue
  205. // @grant GM_deleteValue
  206. // @grant GM_addStyle
  207. // @grant GM_setClipboard
  208. // @grant GM_xmlhttpRequest
  209. // @grant GM_registerMenuCommand
  210. // @connect *
  211. // @noframes
  212. // @run-at document-end
  213. // @note v1.0.0 2020-03-15 First published
  214. // @note v1.0.1 2020-03-26 Fixed bug: uncaught mutation
  215. // @note v1.0.2 2020-07-15 Fixed local google search domain mismatch
  216. // ==/UserScript==
  217.  
  218. // All google search domains: https://www.google.com.hk/supported_domains
  219.  
  220. (function() {
  221. 'use strict';
  222. $('#taw a').attr('target', '_blank').attr('rel', 'noopener');
  223. $('#taw div:nth-of-type(2) a').attr('target', '');
  224. $('#res a').attr('target', '_blank').attr('rel', 'noopener');
  225. $('#rhs a').attr('target', '_blank').attr('rel', 'noopener');
  226. $('#taw a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  227. $('#res a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  228. $('#rhs a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  229. let observer = new MutationObserver(function(mulist) {
  230. for (let mutation of mulist) {
  231. if (mutation.type == 'childList') {
  232. let jq_target = $(mutation.target);
  233. let caught = false;
  234. jq_target.parents().each(function() {
  235. if ($(this).attr('id') == 'taw') {
  236. caught = true;
  237. $('#taw a').attr('target', '_blank').attr('rel', 'noopener');
  238. $('#taw a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  239. $('#taw div:nth-of-type(2) a').attr('target', '');
  240. } else if ($(this).attr('id') == 'res') {
  241. caught = true;
  242. $('#res a').attr('target', '_blank').attr('rel', 'noopener');
  243. $('#res a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  244. } else if ($(this).attr('id') == 'rhs') {
  245. caught = true;
  246. $('#rhs a').attr('target', '_blank').attr('rel', 'noopener');
  247. $('#rhs a').unbind().removeAttr('onmousedown').removeAttr('onclick');
  248. }
  249. });
  250. /*
  251. if (!caught) {
  252. console.log('uncaught mutation:', jq_target);
  253. console.log('parents:', jq_target.parents());
  254. } */
  255. }
  256. }
  257. });
  258. observer.observe($('#rcnt')[0], {
  259. childList: true,
  260. subtree: true
  261. });
  262. })();

QingJ © 2025

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