Greasy Fork

Greasy Fork is available in English.

Site Quick Open网页快开

Click on the lower left button in the search engine, quickly open all websites.(Please allow the browser to redirect many times). 点击左下角按钮帮您快速打开搜索引擎的所有链接(请先允许浏览器多次重定向)

目前为 2022-03-04 提交的版本。查看 最新版本

// ==UserScript==
// @name         Site Quick Open网页快开
// @namespace    http://tampermonkey.net/
// @version      0.6
// @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        *.bing.com/search*
// @match        *.yahoo.com/search*
// @grant        none
// ==/UserScript==
(function () {
    //ready
    let data = [{
            name: "bing",
            aNodeClass: "b_title",
            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) {
            if (item[i].nodeType > 0) {
                item[i].getElementsByTagName("a")[0].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 () {
            for (const i in item) {
                if (item[i].nodeType != null) {
                    let link = item[i].getElementsByTagName("a")[0].href;
                    if (link != null) {
                        window.open(link);
                    }
                }
            }
        });
        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;
            }
        }
    }
})();