// ==UserScript== // @name Magnet Kinozal.tv // @version 0.2002 // @description Magnet maker for kinozal.tv // @match https://kinozal.tv/details.php* // @match https://kinozal.tv/comment.php* // @run-at document-end // @grant none // @copyright 2022, 4ipon4ik // @license MIT // @namespace https://greasyfork.org/users/752356 // @downloadURL https://update.greasyfork.icu/scripts/443388/Magnet%20Kinozaltv.user.js // @updateURL https://update.greasyfork.icu/scripts/443388/Magnet%20Kinozaltv.meta.js // ==/UserScript== const parser = new DOMParser(); // Storing download button reference. const downButt = document.querySelector(".mn1_content > table > tBody > tr > td"); // Creating little magnet svg icon from fontawesome website. Only added 25px sized dimentions, whitch corresponds to download button height. const magnetIcon = ''; // Main function -> async so we can use await syntax with fetch. (async () => { // Fetching torrent hash string. const response = await (await fetch(`/get_srv_details.php?id=${(new URL(location.href)).searchParams.get("id")}&action=2`)).text(); // Converting response text to dom element, so we can easily traverse and extract torrent hash with querySelector. const dom = parser.parseFromString(response, "text/html"); const torrentHash = dom.documentElement.querySelector("ul > li:first-child").innerText.substr(10); // And finally adding magnet link to the page. 🙂 downButt.insertAdjacentHTML("afterend", `${magnetIcon}`); })(); // Self invoking function.