Bing URL Modifier

在访问bing.com时检测URL是否符合特定条件,并修改URL

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Bing URL Modifier
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  在访问bing.com时检测URL是否符合特定条件,并修改URL
// @author       DeepSeek & awa
// @match        *://www.bing.com/*
// @match        *://cn.bing.com/*
// @grant        none
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    // 空函数:用于检测URL是否符合特定条件
    function checkUrlCondition(url) {
        return url.includes('&cvid=') || url.includes('&FPIG=') || url.includes('&form=')
    }

    // 空函数:用于修改URL
    function modifyUrl(url) {
        return url.replace(/&cvid=[0-9A-F]+/g, '').replace(/&FPIG=[0-9A-F]+/g, '').replace(/&form=[A-Z]+/g, '')
    }

    // 获取当前URL
    const currentUrl = window.location.href;

    // 检测URL是否符合条件
    if (checkUrlCondition(currentUrl)) {
        // 修改URL
        const newUrl = modifyUrl(currentUrl);

        // 跳转到修改后的URL
        history.replaceState({}, '', newUrl)
        window.location.href = newUrl
    }
})();