ShitJournal PDF Tools

Add read and download buttons for ShitJournal PDFs

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         ShitJournal PDF Tools
// @match        https://shitjournal.org/preprints/*
// @grant        GM_download
// @license MIT
// @description  Add read and download buttons for ShitJournal PDFs
// @description:zh-CN  在 ShitJournal 预印本页面添加 PDF 阅读和下载按钮
// @version 0.0.1.20260308164434
// @namespace https://greasyfork.org/users/789884
// ==/UserScript==

(function() {
    'use strict';

    const match = location.pathname.match(/\/preprints\/([0-9a-f-]+)/);
    if (!match) return;

    const uuid = match[1];
    const pdfUrl = `https://files.shitjournal.org/${uuid}.pdf`;

    // 按钮容器
    const box = document.createElement("div");

    Object.assign(box.style, {
        position: "fixed",
        bottom: "20px",
        right: "20px",
        display: "flex",
        gap: "8px",
        zIndex: 999999
    });

    // 阅读按钮
    const readBtn = document.createElement("a");
    readBtn.textContent = "📖 阅读 PDF";
    readBtn.href = pdfUrl;
    readBtn.target = "_blank";

    Object.assign(readBtn.style, {
        padding: "10px 16px",
        background: "#4caf50",
        color: "white",
        textDecoration: "none",
        borderRadius: "6px",
        fontSize: "14px"
    });

    // 下载按钮
    const downloadBtn = document.createElement("button");
    downloadBtn.textContent = "⬇ 下载 PDF";

    Object.assign(downloadBtn.style, {
        padding: "10px 16px",
        background: "#1976d2",
        color: "white",
        border: "none",
        borderRadius: "6px",
        cursor: "pointer",
        fontSize: "14px"
    });

    downloadBtn.onclick = () => {
        GM_download({
            url: pdfUrl,
            name: uuid + ".pdf"
        });
    };

    box.appendChild(readBtn);
    box.appendChild(downloadBtn);
    document.body.appendChild(box);

})();