Sage Journals Redirect

将Sage期刊请求重定向至中国镜像站

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Greasemonkey lub Violentmonkey.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, wymagana jest instalacje jednego z następujących rozszerzeń: Tampermonkey, Violentmonkey.

Aby zainstalować ten skrypt, wymagana będzie instalacja rozszerzenia Tampermonkey lub Userscripts.

You will need to install an extension such as Tampermonkey to install this script.

Aby zainstalować ten skrypt, musisz zainstalować rozszerzenie menedżera skryptów użytkownika.

(Mam już menedżera skryptów użytkownika, pozwól mi to zainstalować!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Będziesz musiał zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

Musisz zainstalować rozszerzenie menedżera stylów użytkownika, aby zainstalować ten styl.

(Mam już menedżera stylów użytkownika, pozwól mi to zainstalować!)

// ==UserScript==
// @name         Sage Journals Redirect
// @version      0.3
// @description  将Sage期刊请求重定向至中国镜像站
// @namespace    https://greasyfork.org/en/users/30-opsomh
// @match        *://journals.sagepub.com/*
// @grant        none
// @run-at       document-start
// @license      MIT
// ==/UserScript==

(function() {
    'use strict';

    const currentUrl = new URL(location.href);

    // 仅处理主站请求
    if (currentUrl.hostname !== 'journals.sagepub.com') return;

    // 提取DOI编号(支持多种URL结构)
    const doiPathRegex = /^\/(?:doi|loi)\/(?:abs|full|pdf|epub)\/(.+)/;
    const match = currentUrl.pathname.match(doiPathRegex);

    if (match) {
        window.stop(); // 立即停止加载

        const doi = match[1].replace(/\/$/, ''); // 去除可能存在的末尾斜杠
        const newUrl = new URL(`https://sage.cnpereading.com/paragraph/article/`);

        // 构建查询参数
        newUrl.searchParams.set('doi', doi);

        // 保留原始锚点(如有)
        newUrl.hash = currentUrl.hash;

        // 执行重定向
        location.replace(newUrl.href);
    }
})();