Greasy Fork is available in English.
Click on the lower left button in the search engine, quickly open all websites.(Please allow the browser to redirect many times). 点击左下角按钮帮您快速打开搜索引擎的所有链接(请先允许浏览器多次重定向)
当前为
// ==UserScript==
// @name Site Quick Open网页快开
// @namespace http://tampermonkey.net/
// @version 1.3
// @description Click on the lower left button in the search engine, quickly open all websites.(Please allow the browser to redirect many times). 点击左下角按钮帮您快速打开搜索引擎的所有链接(请先允许浏览器多次重定向)
// @author Exisi
// @match *.baidu.com/s*
// @match *.google.com.*/search*
// @match *.google.com/search*
// @match *.google.com.hk/search*
// @match *.bing.com/search*
// @match *.yahoo.com/search*
// ==/UserScript==
(function () {
"use strict";
// ready
let data = [{
name: "bing",
aNodeClass: "b_algo",
contentId: "b_content",
},
{
name: "baidu",
aNodeClass: "result c-container new-pmd",
contentId: "wrapper",
},
{
name: "google",
aNodeClass: "yuRUbf",
contentId: "main",
},
{
name: "yahoo",
aNodeClass: "compTitle options-toggle",
contentId: "results",
},
];
// get the site name
let url = window.location.href;
let type = getSiteType(url);
let item = document.getElementsByClassName(data[type].aNodeClass);
if (item != null) {
createButton(item);
}
// openlink
function quickOpen(item) {
for (const i in item) {
let parentNode = item[i].parentNode;
if (parentNode != null) {
// check for the presence of the ublacklist chrome plugin
let is_ub_blocked = parentNode.getAttribute("data-ub-blocked") ? 1 : 0;
let ub_attr = parentNode.getAttribute("data-ub-blocked");
// check for the presence of the ac-baidu script
let is_ac_baidu_script = parentNode.getAttribute("ac-needhide") ? 1 : 0;
let ac_attr = parentNode.getAttribute("data-ub-blocked");
// get type
let index = is_ub_blocked + is_ac_baidu_script;
switch (index) {
case 0: // none
if (item[i].nodeType > 0) {
click(item[i]);
}
break;
case 1: // ac_baidu or ub_blocked
if (ub_attr != null && ac_attr != null) {
if (item[i].nodeType > 0 && (ub_attr == "ub-blocked" || ac_attr == "1")) {
click(item[i]);
}
}
break;
case 2: // ac_baidu and ub_blocked
if (ub_attr != null && ac_attr != null) {
if (item[i].nodeType > 0 && ub_attr == "ub-blocked" && ac_attr == "1") {
click(item[i]);
}
}
break;
}
}
}
}
//click link
function click(item) {
let link = item.getElementsByTagName("a")[0];
if (link != null) {
let target = document.createElement("a");
target.setAttribute("href", link.getAttribute("href"));
target.setAttribute("target", "_blank");
target.click();
}
}
//add button
function createButton(item) {
var btn = document.createElement("input");
btn.setAttribute("type", "button");
btn.setAttribute("value", "🚀");
btn.setAttribute("id", "startBtn");
btn.style.background = "pink";
btn.style.color = "white";
btn.style.fontWeight = "500";
btn.style.width = "50px";
btn.style.height = "50px";
btn.style.borderRadius = "100px";
btn.style.fontSize = "14px";
btn.style.position = "fixed";
btn.style.border = "1px pink solid";
btn.style.bottom = 0;
btn.style.left = 0;
btn.style.outline = "none";
btn.style.margin = "25px";
btn.addEventListener("click", function () {
quickOpen(item);
});
document.getElementById(data[type].contentId).append(btn);
}
//get site type
function getSiteType(url) {
for (let i in data) {
if (url.search(data[i].name) > 0) {
return i;
}
}
}
})();