ShitJournal PDF Tools

Add read and download buttons for ShitJournal PDFs

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

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.

(I already have a user style manager, let me install it!)

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

})();