YTS.mx - Copy Magnet Button

Adds a "Copy Magnet" button to every movie quality on YTS.mx for easy access.

当前为 2025-05-18 提交的版本,查看 最新版本

您需要先安装一个扩展,例如 篡改猴Greasemonkey暴力猴,之后才能安装此脚本。

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

您需要先安装一个扩展,例如 篡改猴暴力猴,之后才能安装此脚本。

您需要先安装一个扩展,例如 篡改猴Userscripts ,之后才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。

您需要先安装用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         YTS.mx - Copy Magnet Button
// @name:id      YTS.mx - Tombol Salin Magnet
// @namespace    https://github.com/Horyzontalhoror/yts_copymagnet
// @version      2.0
// @description  Adds a "Copy Magnet" button to every movie quality on YTS.mx for easy access.
// @description:id Menambahkan tombol "Salin Magnet" di setiap kualitas film YTS.mx untuk menyalin tautan magnet dengan mudah.
// @author       Horyzontalhoror
// @license      MIT
// @match        https://yts.mx/movies/*
// @grant        GM_setClipboard
// @icon         https://raw.githubusercontent.com/Horyzontalhoror/yts_copymagnet/main/icon.png
// @tags         YTS.mx, magnet, torrent
// ==/UserScript==

(function () {
    'use strict';

    // Function to display toast with icon
    function showToast(message, icon = "🎉") {
        const toast = document.createElement('div');
        toast.innerHTML = `<span style="margin-right: 8px;">${icon}</span>${message}`;
        toast.style.position = 'fixed';
        toast.style.bottom = '20px';
        toast.style.right = '20px';
        toast.style.padding = '10px 15px';
        toast.style.background = '#00e054';
        toast.style.color = 'white';
        toast.style.borderRadius = '5px';
        toast.style.fontWeight = 'bold';
        toast.style.boxShadow = '0 0 10px rgba(0,0,0,0.3)';
        toast.style.zIndex = 10000;
        toast.style.opacity = '1';
        toast.style.display = 'flex';
        toast.style.alignItems = 'center';
        toast.style.transition = 'opacity 0.5s ease';

        document.body.appendChild(toast);

        setTimeout(() => {
            toast.style.opacity = '0';
            setTimeout(() => {
                toast.remove();
            }, 500);
        }, 3000);
    }

    window.addEventListener('load', function () {
        setTimeout(() => {
            const magnetLinks = document.querySelectorAll('a[href^="magnet:?"]');

            magnetLinks.forEach(link => {
                if (link.nextSibling && link.nextSibling.classList && link.nextSibling.classList.contains('copy-magnet-btn')) {
                    return;
                }

                const copyBtn = document.createElement("button");
                copyBtn.textContent = "Copy Magnet";
                copyBtn.className = "copy-magnet-btn";
                copyBtn.style.marginLeft = "10px";
                copyBtn.style.padding = "5px 10px";
                copyBtn.style.border = "none";
                copyBtn.style.background = "#00e054";
                copyBtn.style.color = "white";
                copyBtn.style.fontWeight = "bold";
                copyBtn.style.cursor = "pointer";
                copyBtn.style.borderRadius = "5px";

                copyBtn.addEventListener("click", (e) => {
                    e.preventDefault();
                    GM_setClipboard(link.href);
                    showToast("Magnet link copied!", "📎");
                });

                link.parentNode.insertBefore(copyBtn, link.nextSibling);
            });

        }, 1000);
    });
})();