qBittorrent Web UI 剪貼簿支援

對qBittorrent的Web UI新增了貼上(ctrl+v)的支援,如果腳本在你的剪貼簿偵測到磁力連結,會自動新增種子

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

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

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

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

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

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

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         qBittorrent Web UI clipboard support
// @name:zh-TW   qBittorrent Web UI 剪貼簿支援
// @namespace    https://github.com/axzxc1236/
// @version      0.1
// @description  Adds ctrl+v support to qBittorrent's Web UI, if a magnet link is in your clipboard it automatically adds the torrent.
// @description:zh-tw  對qBittorrent的Web UI新增了貼上(ctrl+v)的支援,如果腳本在你的剪貼簿偵測到磁力連結,會自動新增種子
// @author       axzxc1236
// @match        https://127.0.0.1:8080/
// @grant        none
// ==/UserScript==

(function() {
    'use strict';

    // Your code here...
    navigator.permissions.query({
        name: 'clipboard-read'
    }).then(permissionStatus => {
        // Will be 'granted', 'denied' or 'prompt':
        if (permissionStatus.state == "denied") {
            alert("Clipboard permission is denied, this script will not work until you change that");
        }
    });
    document.addEventListener('paste', function(data) {
        var text = data.clipboardData.getData("text");
        if (text.startsWith("magnet:?xt=")) {
            document.getElementById('downloadButton').click();
            document.getElementById("downloadPage_iframe").contentDocument.body.onload = function() {
                this.document.body.getElementById("urls").innerText = text;
                this.document.body.getElementById("submitButton").click();
            };
        }
    });
})();