Sage Journals Redirect

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

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==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);
    }
})();