Last active
June 10, 2022 08:34
-
-
Save bigshans/ab4b797742b4171817436758784d72c7 to your computer and use it in GitHub Desktop.
whoogle-open-link-in-new-tab.user.js
This file contains 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 You | |
// @include https://whoogle.sdf.org/search/* | |
// @icon https://www.google.com/s2/favicons?domain=black-white-rabbito.monster | |
// @grant none | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
function range(n) { | |
return [...Array(n).keys()]; | |
} | |
function addOpenBlank() { | |
let nodeList = document.querySelectorAll('.pkphOe'); | |
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