ShitJournal PDF Tools

Add read and download buttons for ShitJournal PDFs

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey, το Greasemonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Violentmonkey για να εγκαταστήσετε αυτόν τον κώδικα.

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το Tampermonkey ή το Userscripts για να εγκαταστήσετε αυτόν τον κώδικα.

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

Θα χρειαστεί να εγκαταστήσετε μια επέκταση διαχείρισης κώδικα χρήστη για να εγκαταστήσετε αυτόν τον κώδικα.

(Έχω ήδη έναν διαχειριστή κώδικα χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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.

(Έχω ήδη έναν διαχειριστή στυλ χρήστη, επιτρέψτε μου να τον εγκαταστήσω!)

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

})();