// ==UserScript== // @name magnet kinozal // @version 0.2012 // @description Magnet maker for kinozal.tv, kinozal.guru, kinozal.me // @match https://kinozal.tv/details.php* // @match https://kinozal.tv/comment.php* // @match https://kinozal.guru/details.php* // @match https://kinozal.guru/comment.php* // @match https://kinozal.me/details.php* // @match https://kinozal.me/comment.php* // @run-at document-end // @grant none // @copyright 2022, 4ipon4ik, vanoc // @namespace vanoc // @license MIT // @downloadURL https://update.greasyfork.icu/scripts/524047/magnet%20kinozal.user.js // @updateURL https://update.greasyfork.icu/scripts/524047/magnet%20kinozal.meta.js // ==/UserScript== // за исходник взят https://greasyfork.org/ru/scripts/443388-magnet-kinozal-tv // заменена иконка и добавлены @match kinozal.guru, kinozal.me const parser = new DOMParser(); // Storing download button reference. const downButt = document.querySelector(".mn1_content > table > tBody > tr > td"); 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.