Bing URL Modifier

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

ستحتاج إلى تثبيت إضافة مثل 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
    }
})();