CN Bing return to Global Bing

重定向国内版bing到国际版bing

  1. // ==UserScript==
  2. // @name CN Bing return to Global Bing
  3. // @namespace http://tampermonkey.net/
  4. // @version 0.1.3
  5. // @description 重定向国内版bing到国际版bing
  6. // @author You
  7. // @license MIT
  8. // @match https://cn.bing.com/search*
  9. // @match https://cn.bing.com/*
  10. // @match https://www.bing.com
  11. // @match https://cn.bing.com/
  12. // @match https://cn.bing.com
  13. // @match https://global.bing.com/*
  14. // @match https://www.bing.com/
  15. // @match https://bing.com/*
  16. // @match https://bing.com/
  17. // @match https://www.bing.com/search*
  18. // @icon https://www.google.com/s2/favicons?sz=64&domain=bing.com
  19. // @grant none
  20. // ==/UserScript==
  21.  
  22. (function() {
  23. 'use strict';
  24.  
  25. var global_bing = "https://global.bing.com/search?setmkt=en-US&setlang=en-US&filt=custom&cc=US";
  26. let current_url = window.location.href;
  27. if (current_url == "https://global.bing.com/?scope=web&cc=US" || current_url.startsWith("https://global.bing.com/account" )){
  28.  
  29. return 0;}
  30. var query = "";
  31. var cc = "";
  32. var mkt = "";
  33. var lang = "";
  34. var filters = "";
  35. var form = "";
  36. if (current_url.match (/[\?\&]q=([^\&\#]+)[\&\#]/i)){
  37. query = current_url.match (/[\?\&]q=([^\&\#]+)[\&\#]/i) [1];}
  38.  
  39. if (current_url == "https://cn.bing.com/" || current_url == "https://cn.bing.com"){
  40. window.location.replace("https://global.bing.com/?FORM=Z9FD1")
  41. return 0;
  42. }
  43.  
  44.  
  45. if (current_url.startsWith("https://cn.bing.com") || current_url.startsWith("https://www.bing.com") && query == ""){
  46. window.location.hostname = "global.bing.com"
  47. if(current_url.match(/[\?\&]*=([^\&\#]+)[\&\#]/i)){
  48. window.location.href(window.location+"&setmkt=en-US&setlang=en-US&cc=US")}
  49. else{
  50. window.location.href(window.location+"?setmkt=en-US&setlang=en-US&cc=US")
  51. }
  52. return 0;
  53. }
  54.  
  55.  
  56. if (!current_url.startsWith("https://global.bing.com") && query != "" ) {
  57. window.location.hostname = "global.bing.com"
  58. window.location.href(window.location+"&setmkt=en-US&setlang=en-US&cc=US")
  59. return 0;
  60.  
  61. }
  62.  
  63. if (current_url.match (/[\?\&]cc=([^\&\#]+)[\&\#]/i)){
  64. cc = current_url.match (/[\?\&]cc=([^\&\#]+)[\&\#]/i) [1];}
  65. if (current_url.match (/[\?\&]setmkt=([^\&\#]+)[\&\#]/i)){
  66. mkt = current_url.match (/[\?\&]setmkt=([^\&\#]+)[\&\#]/i) [1];}
  67. if (current_url.match (/[\?\&]setlang=([^\&\#]+)[\&\#]/i)){
  68. lang = current_url.match (/[\?\&]setlang=([^\&\#]+)[\&\#]/i) [1];}
  69. if (current_url.match (/[\?\&]filters=([^\&\#]+)[\&\#]/i)){
  70. filters = current_url.match (/[\?\&]filters=([^\&\#]+)[\&\#]/i) [1];}
  71. if (current_url.match (/[\?\&]FORM=([^\&\#]+)[\&\#]/i)){
  72. form = current_url.match (/[\?\&]FORM=([^\&\#]+)[\&\#]/i) [1];}
  73.  
  74. if (current_url.startsWith("https://global.bing.com") && (cc.endsWith("CN") || mkt.endsWith("CN") || lang.endsWith("CN")||mkt == "" || lang == "")){
  75. window.location.hostname = "global.bing.com"
  76. if(current_url.match(/[\?\&]*=([^\&\#]+)[\&\#]/i)){
  77. window.location.replace(window.location+"&setmkt=en-US&setlang=en-US&cc=US")}
  78. else{
  79. window.location.replace(window.location+"?setmkt=en-US&setlang=en-US&cc=US")
  80. }
  81. return 0;
  82. return 0;
  83. }
  84.  
  85. document.body.innerHTML = document.body.innerHTML.replace(/cn.bing.com/g,"global.bing.com");
  86.  
  87. // Your code here...
  88. })();