Do not redirect to China Version Website

try to take over the world!

目前为 2019-07-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Do not redirect to China Version Website
  3. // @namespace ATGT
  4. // @version 0.2
  5. // @description try to take over the world!
  6. // @author You
  7. // @match *://*.leetcode-cn.com/*
  8. // @match *://*.leetcode.com/*
  9. // @grant none
  10. // @run-at document-end
  11. // ==/UserScript==
  12.  
  13. (function() {
  14. console.log(`=== do not direct to china version web size ${location.host} ===`);
  15. 'use strict';
  16. if (/leetcode-cn.com$/.test(location.host)) {
  17. console.log('redirect to leetcode.com');
  18. location.host = location.host.replace(/leetcode-cn.com$/, 'leetcode.com');
  19. console.log('new location ', location.host);
  20. } else if (/leetcode.com$/.test(location.host)) {
  21. let close_btn = document.querySelector('#region_switcher .close-btn');
  22. console.log('close_btn', close_btn);
  23. setTimeout(() => { close_btn.click(); }, 500);
  24. }
  25. console.log(`=== /do not direct to china version web size ${location.host} ===`);
  26. })();