leetcode cn/en site switcher

Leetcode中英文网站切换

As of 2023-10-28. See the latest version.

  1. // ==UserScript==
  2. // @name leetcode cn/en site switcher
  3. // @namespace http://tampermonkey.net/
  4. // @license MIT
  5. // @version 0.1
  6. // @description Leetcode中英文网站切换
  7. // @author GeeMaple
  8. // @match *://leetcode.com/*
  9. // @match *://leetcode.cn/*
  10. // @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
  11.  
  12. // ==/UserScript==
  13.  
  14. (function() {
  15. 'use strict';
  16. document.addEventListener('keydown', function(event) {
  17. if ((event.ctrlKey && event.key === '`')) {
  18. event.preventDefault();
  19. let url = window.location.href;
  20. if (url.includes('leetcode.com')) {
  21. window.location.assign(url.replace('leetcode.com', 'leetcode.cn'))
  22. } else {
  23. window.location.assign(url.replace('leetcode.cn', 'leetcode.com'))
  24. }
  25. }
  26. });
  27. })();