跳转到Seaborn对应的中文网站

自动尝试跳转到Seaborn对应的中文网站

// ==UserScript==
// @name         跳转到Seaborn对应的中文网站
// @namespace    http://tampermonkey.net/
// @version      2025-03-17
// @description  自动尝试跳转到Seaborn对应的中文网站
// @author       zsjng
// @match        https://seaborn.pydata.org/*
// @grant        none
// @include      https://seaborn.pydata.org/*
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';
    const currentUrl = new URL(window.location.href);
    const excludePath = '/search.html'; // 排除路径配置项
    try {
        // 双重验证逻辑:域名匹配且路径不包含排除项
        if (currentUrl.hostname.startsWith('seaborn.pydata.org')
            && !currentUrl.pathname.startsWith(excludePath)) {
            const redirectUrl = new URL(
                `${currentUrl.protocol}//seaborn.org.cn${currentUrl.pathname}${currentUrl.search}${currentUrl.hash}`
            );
            setTimeout(() => window.location.href = redirectUrl, 100);
        }
    } catch (error) {
        console.error('Redirect failed:', error);
    }
})();

QingJ © 2025

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