leetcode cn/en site switcher

Leetcode中英文网站切换,使用ctr+`(Esc下面,数字1左边那个按钮)

Verze ze dne 28. 10. 2023. Zobrazit nejnovější verzi.

  1. // ==UserScript==
  2. // @name leetcode cn/en site switcher
  3. // @namespace http://tampermonkey.net/
  4. // @license MIT
  5. // @version 0.2
  6. // @description Leetcode中英文网站切换,使用ctr+`(Esc下面,数字1左边那个按钮)
  7. // @description 屏蔽中文跳转banner,可以将"||leetcode.cn/api/is_china_ip/"填入到adblocker
  8. // @author GeeMaple
  9. // @match *://leetcode.com/*
  10. // @match *://leetcode.cn/*
  11. // @icon https://www.google.com/s2/favicons?sz=64&domain=leetcode.com
  12.  
  13. // ==/UserScript==
  14.  
  15. (function() {
  16. 'use strict';
  17.  
  18. document.addEventListener('keydown', function(event) {
  19. if ((event.ctrlKey && event.key === '`')) {
  20. event.preventDefault();
  21. let url = window.location.href;
  22. if (url.includes('leetcode.com')) {
  23. window.location.assign(url.replace('leetcode.com', 'leetcode.cn'))
  24. } else {
  25. window.location.assign(url.replace('leetcode.cn', 'leetcode.com'))
  26. }
  27. }
  28. });
  29. })();