ShitJournal PDF Tools

Add read and download buttons for ShitJournal PDFs

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 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);

})();