Greasy Fork

四方坪职院学术重定向

通过重定向至图书馆包库,解锁期刊访问权限

当前为 2024-09-18 提交的版本,查看 最新版本

// ==UserScript==
// @name         四方坪职院学术重定向
// @namespace    https://example.com
// @version      1.1
// @license      MPL-2.0
// @description  通过重定向至图书馆包库,解锁期刊访问权限
// @author       https://github.com/cyan-io
// @homepage     https://github.com/cyan-io/SPC-Academic-Redirection
// @match        https://ieeexplore.ieee.org/*
// @match        https://dl.acm.org/*
// @match        https://auth.elsevier.com/*
// @match        https://www.sciencedirect.com/*
// @match        https://www.emerald.com/*
// @match        https://ieeexplore.ieee.org/*
// @match        https://www.webofknowledge.com/*
// @match        https://bg.sunwayinfo.com.cn/*
// @match        https://arxiv.org/*
// @match        https://navi.ion.org/*
// @match        https://thesis.library.caltech.edu/*
// @match        https://www.nature.com/*
// @icon         https://library.nudt.edu.cn/favicon.ico
// ==/UserScript==

(function () {
    'use strict';

    let regex = /https?:\/\/([^\/]+)\/(.*)/i;
    let match = window.location.href.match(regex);

    console.log('Debug <match>', match);

    if (match) {
        let domain = match[1];
        let path = match[2];

        let redirectUrl = 'https://'+domain.replace(/\./g, "-")+'-s.libyc.nudt.edu.cn/' + path;

        console.log('Debug <url>',redirectUrl);

        let button = document.createElement('button');
        button.innerHTML = '🔗' + redirectUrl;
        button.style.position = 'fixed';
        button.style.bottom = '20px';
        button.style.right = '20px';
        button.style.zIndex = '9999';
        button.style.backgroundColor = '#FFFFFF';
        button.style.border = '2px solid black';
        button.style.borderRadius = '5px';
        button.style.padding = '5px 10px';
        button.addEventListener('click', function () {
            window.open(redirectUrl, "_blank");
        });
        document.body.appendChild(button);
    }
})();