您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
如果当前链接在 LeetCode 国际站可访问,则重定向。如果当前链接在 LeetCode 国际站不可访问(比如力扣中文站独家题库),则不做处理。
// ==UserScript== // @name 力扣中文站重定向到 LeetCode 国际站 // @namespace https://gf.qytechs.cn/zh-CN/users/459661-cycychenyi // @version 0.1.1 // @description 如果当前链接在 LeetCode 国际站可访问,则重定向。如果当前链接在 LeetCode 国际站不可访问(比如力扣中文站独家题库),则不做处理。 // @author cycychenyi // @match https://leetcode.cn/* // @match https://leetcode-cn.com/* // @grant GM_xmlhttpRequest // @connect leetcode.com // ==/UserScript== async function redirectIfPossible() { const redirectUrl = getRedirectUrl('leetcode.com'); if (await isValidUrl(redirectUrl)) { redirect(redirectUrl); } } function getRedirectUrl(redirectHostname) { const url = new URL(location.href); url.hostname = redirectHostname; return url; } async function isValidUrl(url) { const response = await visit(url); return response.status == 200; } function visit(url) { return new Promise((resolve, reject) => { GM_xmlhttpRequest({ method: 'GET', url: url, onload: response => resolve(response) }); }); } function redirect(url) { location.assign(url); } redirectIfPossible();
QingJ © 2025
镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址