纽约时报中文网切换为双语

自动切换纽约时报中文网为双语,并且默认设置为简体中文。

// ==UserScript==
// @name         纽约时报中文网切换为双语
// @license      MIT
// @namespace    [email protected]
// @version      1.0
// @description  自动切换纽约时报中文网为双语,并且默认设置为简体中文。
// @author       Marcus Xu
// @match        *://cn.nytimes.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=nytimes.com
// @run-at       document-start
// @grant        GM_cookie

// ==/UserScript==

(function () {
    'use strict';

    if (location.pathname === '/zh-hant/') {
        location.href = 'https://cn.nytimes.com/tools/r.html?url=/&langkey=zh-hans'
    }

    // 详情文章页面,比如 "/technology/20250814/coding-ai-jobs-students/"
    const articlePattern = /^\/[a-z-]+\/\d+\/[a-z0-9-]+\//i;

    if (articlePattern.test(location.pathname)) {
        // 当前页面是文章详情页面
        console.log('文章详情页面')
        if (location.pathname.endsWith('/zh-hant/')) {
            location.pathname = location.pathname.replace('/zh-hant/', '/zh-hans/dual/')
        } else if (location.pathname.endsWith('/zh-hans/')) {
            location.pathname += 'dual/'
        } else if (location.pathname.endsWith('/dual/')) {
        } else {
            location.pathname += 'dual/'
        }
    }

})();

QingJ © 2025

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