UofT Library Proxy

Adds a floating button to proxy Nature, ACSPublications, JAMA and ScienceDirect pages through UofT library access

スクリプトをインストールするには、Tampermonkey, GreasemonkeyViolentmonkey のような拡張機能のインストールが必要です。

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

スクリプトをインストールするには、TampermonkeyViolentmonkey のような拡張機能のインストールが必要です。

スクリプトをインストールするには、TampermonkeyUserscripts のような拡張機能のインストールが必要です。

このスクリプトをインストールするには、Tampermonkeyなどの拡張機能をインストールする必要があります。

このスクリプトをインストールするには、ユーザースクリプト管理ツールの拡張機能をインストールする必要があります。

(ユーザースクリプト管理ツールは設定済みなのでインストール!)

このスタイルをインストールするには、Stylusなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus などの拡張機能をインストールする必要があります。

このスタイルをインストールするには、Stylus tなどの拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

このスタイルをインストールするには、ユーザースタイル管理用の拡張機能をインストールする必要があります。

(ユーザースタイル管理ツールは設定済みなのでインストール!)

作者のサイトでサポートを受ける。または、このスクリプトの質問や評価の投稿はこちら通報はこちらへお寄せください
// ==UserScript==
// @name         UofT Library Proxy
// @namespace    https://gist.github.com/jackjona/3f8a0b39f23b78c6f681fa7c25b265bf
// @homepageURL  https://gist.github.com/jackjona/3f8a0b39f23b78c6f681fa7c25b265bf
// @supportURL   https://gist.github.com/jackjona/3f8a0b39f23b78c6f681fa7c25b265bf
// @version      1.2.2
// @author       Jack Jona
// @description  Adds a floating button to proxy Nature, ACSPublications, JAMA and ScienceDirect pages through UofT library access
// @match        https://www.nature.com/*
// @match        https://www.sciencedirect.com/*
// @match        https://onlinelibrary.wiley.com/*
// @match        https://*.onlinelibrary.wiley.com/*
// @match        https://www.science.org/*
// @match        https://link.springer.com/*
// @match        https://pubs.acs.org/*
// @match        https://jamanetwork.com/*
// @icon         https://icons.duckduckgo.com/ip3/library.utoronto.ca.ico
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    const PROXY_SUFFIX = '.myaccess.library.utoronto.ca';

    // If already proxied, do nothing
    if (location.hostname.includes(PROXY_SUFFIX)) return;

    // Create floating button
    const btn = document.createElement('div');
    btn.textContent = 'UofT Proxy';
    btn.style.position = 'fixed';
    btn.style.bottom = '20px';
    btn.style.right = '20px';
    btn.style.padding = '10px 14px';
    btn.style.background = '#00204E';
    btn.style.color = 'white';
    btn.style.fontSize = '14px';
    btn.style.borderRadius = '6px';
    btn.style.cursor = 'pointer';
    btn.style.zIndex = '999999';
    btn.style.boxShadow = '0 2px 6px rgba(0,0,0,0.3)';
    btn.style.opacity = '0.85';
    btn.style.transition = 'opacity 0.2s ease';
    btn.onmouseenter = () => btn.style.opacity = '1';
    btn.onmouseleave = () => btn.style.opacity = '0.85';

    document.body.appendChild(btn);

    btn.onclick = () => {
        let host = location.hostname;
        let path = location.pathname;
        let search = location.search;
        let hash = location.hash;

        // Special rule: ScienceDirect — strip /abs/ and remove query/hash
        if (host.includes('sciencedirect.com')) {
            path = path.replace('/abs/', '/');
            search = '';
            hash = '';
        }

        // Convert dots to dashes for proxy domain
        const proxiedHost = host.replace(/\./g, '-') + PROXY_SUFFIX;

        const newUrl = location.protocol + '//' + proxiedHost + path + search + hash;

        window.location.href = newUrl;
    };
})();