Bing URL Modifier

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

  1. // ==UserScript==
  2. // @name Bing URL Modifier
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1
  5. // @description 在访问bing.com时检测URL是否符合特定条件,并修改URL
  6. // @author DeepSeek & awa
  7. // @match *://www.bing.com/*
  8. // @match *://cn.bing.com/*
  9. // @grant none
  10. // @license MIT
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. 'use strict';
  15.  
  16. // 空函数:用于检测URL是否符合特定条件
  17. function checkUrlCondition(url) {
  18. return url.includes('&cvid=') || url.includes('&FPIG=') || url.includes('&form=')
  19. }
  20.  
  21. // 空函数:用于修改URL
  22. function modifyUrl(url) {
  23. return url.replace(/&cvid=[0-9A-F]+/g, '').replace(/&FPIG=[0-9A-F]+/g, '').replace(/&form=[A-Z]+/g, '')
  24. }
  25.  
  26. // 获取当前URL
  27. const currentUrl = window.location.href;
  28.  
  29. // 检测URL是否符合条件
  30. if (checkUrlCondition(currentUrl)) {
  31. // 修改URL
  32. const newUrl = modifyUrl(currentUrl);
  33.  
  34. // 跳转到修改后的URL
  35. history.replaceState({}, '', newUrl)
  36. window.location.href = newUrl
  37. }
  38. })();