Rule34 Video Downloader (Aria2)

Send the url of videos on Rule34.xxx to your Aria2 downloader. 直接将 Rule34 视频推送到 Aria2 下载

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

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

θα χρειαστεί να εγκαταστήσετε μια επέκταση όπως το 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         Rule34 Video Downloader (Aria2)
// @namespace    http://tampermonkey.net/
// @version      2024-02-07.3
// @description  Send the url of videos on Rule34.xxx to your Aria2 downloader. 直接将 Rule34 视频推送到 Aria2 下载
// @match        https://rule34.xxx/index.php?page=post&s=view&id=*
// @grant        GM_xmlhttpRequest
// @license      MIT
// ==/UserScript==

(function () {
    'use strict';

    const ARIA2_RPC_URL = "http://127.0.0.1:16800/jsonrpc"; // 本地 Aria2 端口 16800
    const ARIA2_RPC_TOKEN = "your_token"; // Aria2 的 rpc-secret,若无则留空

    var video = document.getElementById('gelcomVideoPlayer');
    if (!video) return;

    video.parentElement.style.position = 'relative';

    var downloadButton = document.createElement('a');
    downloadButton.innerHTML = '发送到 Aria2';
    downloadButton.style.position = 'absolute';
    downloadButton.style.right = '10px';
    downloadButton.style.top = '10px';
    downloadButton.style.padding = '5px';
    downloadButton.style.backgroundColor = 'rgba(0,0,0,0.5)';
    downloadButton.style.color = 'white';
    downloadButton.style.borderRadius = '5px';
    downloadButton.style.cursor = 'pointer';
    downloadButton.style.userSelect = 'none';
    video.parentElement.appendChild(downloadButton);

    downloadButton.onclick = function () {
        const videolink = video.src || (video.querySelector('source')?.src);
        if (!videolink) return console.error("未找到视频链接");

        // 发送 Aria2 JSON-RPC 请求
        GM_xmlhttpRequest({
            method: "POST",
            url: ARIA2_RPC_URL,
            data: JSON.stringify({
                jsonrpc: "2.0",
                method: "aria2.addUri",
                id: new Date().getTime(),
                params: ARIA2_RPC_TOKEN ? [`token:${ARIA2_RPC_TOKEN}`, [videolink]] : [[videolink]]
            }),
            headers: { "Content-Type": "application/json" },
        });
    };
})();