Bing 跳转链接直达 remove redirect link 去除搜索界面 bing.com/ck 的重定向

去除 bing.com/ck 的重定向直达网站

当前为 2023-12-30 提交的版本,查看 最新版本

// ==UserScript==
// @name         Bing 跳转链接直达 remove redirect link 去除搜索界面 bing.com/ck 的重定向
// @name:zh      Bing 跳转链接直达 remove redirect link 去除搜索界面 bing.com/ck 的重定向
// @name:ja      Bing remove redirect link
// @name:en      Bing remove redirect link
// @description:en  remove bing.com/ck
// @description:ja  remove bing.com/ck
// @description  去除 bing.com/ck 的重定向直达网站
// @namespace    TropicLinear_space
// @version      2023-12-30
// @author       TropicLinear
// @icon         https://cn.bing.com/sa/simg/favicon-trans-bg-blue-mg.ico
// @match        *://*.bing.com/search*
// @grant        none
// @license      MIT
// @run-at       document-end
// ==/UserScript==

(function() {
    'use strict';
    if (/https?:\/\/(?:[\w]+\.)?bing\.com\//.test(location.href)) {
        let timer;
        function throttle(callback, limit) {
            return function () {
                const context = this, args = arguments;
                clearTimeout(timer);
                timer = setTimeout(function () {
                    callback.apply(context, args);
                }, limit);
            };
        }

        const observer = new MutationObserver(throttle((mutations, obs) => {
            document.querySelectorAll('[href^="https://www.bing.com/ck/a"]').forEach(element => {
                const match = element.href.match(/&u=([^&]+)/);
                const encodedUrl = match[1].slice(2);
                if (match && /^[A-Za-z0-9=_-]+$/.test(encodedUrl)) {
                    try {
                        const decodedUrl = atob(encodedUrl.replace(/_/g, "/").replace(/-/g, "+")); // a1 + Base64 encoded URL
                        element.href = decodedUrl;
                    } catch (e) {
                        console.info('Bing URL Decode Error:', encodedUrl);
                    }
                }
            });
        }, 2));

        const config = { childList: true, subtree: true };
        observer.observe(document.body, config);
    }
})();

QingJ © 2025

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