Bing Direct Link

This script is for removing Bing Redirect link, but this doesn't support privacy, as it fetch the redirect result of the URL

目前為 2023-07-12 提交的版本,檢視 最新版本

// ==UserScript==
// @name         Bing Direct Link
// @namespace    http://github.com/benyaminl
// @version      0.13
// @description  This script is for removing Bing Redirect link, but this doesn't support privacy, as it fetch the redirect result of the URL
// @author       Benyamin Limanto
// @match        https://www.bing.com/*
// @icon         https://icons.duckduckgo.com/ip2/bing.com.ico
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    function replaceTheRestOfURL() {
        var urls = document.querySelectorAll("li.b_algo a[href*='https://www.bing.com/ck']:not(.b_logoArea)");
        for(i=0;i < urls.length; i++)
        {
            let url = urls[i];
            fetch(url.href)
                .then(r => r.text())
                .then(d => {
                let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");

                url.href = realUrl;
            });
        }
    }

    var urlBody = document.querySelectorAll(".tilk");
    var i = -1;
    for(i=0; i < urlBody.length; i++)
    {
        let url = urlBody[i];
        let stringUrl = url.querySelector("cite");

        if (!(stringUrl.innerText.includes("...") || stringUrl.innerText.includes("…")))
        {
            let httpPrefix = (stringUrl.innerText.substr(0,4) == "http") ? "" : "http://";
            url.href = httpPrefix + stringUrl.innerText;
            let h2Url = url.parentNode.parentNode.querySelector("h2 a");

            h2Url.href = httpPrefix + stringUrl.innerText;
        }
        else
        {
            fetch(url.href)
            .then(r => r.text())
            .then(d => {
                let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
                let h2Url = url.parentNode.parentNode.querySelector("h2 a");
                h2Url.href = realUrl;
            });
        }
    }

    var urlCard = document.querySelectorAll(".rd_sg_ttl");
    for(i=0; i < urlCard.length; i++)
    {
        let url = urlCard[i];
        let cite = urlCard[i].parentNode.querySelector("cite");
        if (!(cite.innerText.includes("...") || cite.innerText.includes("…")))
        {
            let httpPrefix = (cite.innerText.substr(0,4) == "http") ? "" : "http://";
            url.querySelector("a").href = httpPrefix + cite.innerText;
        }
        else
        {
            fetch(url.querySelector("a").href)
            .then(r => r.text())
            .then(d => {
                let realUrl = d.match(/https:\/\/.+/i)[0].replace("\";","");
                url.querySelector("a").href = realUrl;
            });
        }
    }

    replaceTheRestOfURL();

    // Hook for rest dynamic part of page, using timeout
    var resultCard = document.querySelectorAll(".b_algo");
    console.log(resultCard);
    for (i = 0; i < resultCard.length; i++)
    {
        let card = resultCard[i];
        console.log(card);
        card.addEventListener("click", function() {
            setTimeout(replaceTheRestOfURL, 1000);
        });
    }

})();

QingJ © 2025

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