LeetCode 使用快捷键在中国站和美国站间跳转

按下Ctrl+`时跳转到另一个站点对应的页面

目前為 2023-06-28 提交的版本,檢視 最新版本

// ==UserScript==
// @name         LeetCode 使用快捷键在中国站和美国站间跳转
// @namespace    http://tampermonkey.net/
// @version      1.0
// @license      MIT
// @description  按下Ctrl+`时跳转到另一个站点对应的页面
// @match        *://*leetcode.cn/*
// @match        *://*leetcode.com/*
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    document.addEventListener('keydown', function(event) {
        if (event.ctrlKey && event.key === '`') {
            event.preventDefault();
            let url = window.location.href;
            if (url.includes('leetcode.com')) {
                window.open(url.replace('leetcode.com', 'leetcode.cn'), '_blank');
            } else {
                window.open(url.replace('leetcode.cn', 'leetcode.com'), '_blank');
            }
        }
    });
})();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址