Forked from bigshans/whoogle-open-link-in-new-tab.user.js
Created
April 25, 2022 02:49
-
-
Save harry159821/1c47f6fa7d97402bcbba8ce6d44560e8 to your computer and use it in GitHub Desktop.
whoogle-open-link-in-new-tab.user.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // ==UserScript== | |
| // @name whoogle search 链接打开方式修改 | |
| // @namespace http://tampermonkey.net/ | |
| // @version 0.1 | |
| // @description try to take over the world! | |
| // @author bigshans | |
| // @include https://whoogle.sdf.org/search/* | |
| // @icon https://www.google.com/s2/favicons?domain=sdf.org | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| function range(n) { | |
| return [...Array(n).keys()]; | |
| } | |
| function addOpenBlank() { | |
| let nodeList = document.querySelectorAll('.ZINbbc'); | |
| const length = nodeList.length; | |
| let newNodeList = []; | |
| for (const i of range(length)) { | |
| newNodeList.push(nodeList[i]); | |
| } | |
| for (const node of newNodeList) { | |
| if (node.querySelectorAll('.mEUgP').length) { | |
| continue; | |
| } | |
| if (node.querySelectorAll('.nMymef').length) { | |
| continue; | |
| } | |
| let as = node.querySelectorAll('a'); | |
| for (const a of as) { | |
| a.setAttribute('target', '_blank'); | |
| } | |
| } | |
| } | |
| setTimeout(addOpenBlank, 500); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment