// ==UserScript== // @name [RED] FL link in notifications // @namespace https://greasyfork.org/users/321857-anakunda // @version 1.0 // @description Zzzzzz // @author Anakunda // @match https://redacted.ch/torrents.php?*action=notify // @match https://orpheus.network/torrents.php?*action=notify // @iconURL https://redacted.ch/favicon.ico // @downloadURL none // ==/UserScript== (function() { 'use strict'; if (document.getElementById('fl_tokens') == null) return; document.querySelectorAll('span.torrent_action_buttons > a.button_dl').forEach(function(a) { if (a.parentNode.parentNode.querySelector('strong.tl_free') != null) return; var ref = a.parentNode.parentNode.parentNode.parentNode.querySelector(':scope > td:nth-of-type(6)'); if (ref != null && /^(\d+(?:\.\d+))\s*(\w?B)\b/i.test(ref.textContent.trim())) { let size = Math.round(RegExp.$1 * 1024**['B', 'KB', 'MB', 'GB', 'TB'].indexOf(RegExp.$2.toUpperCase())); if (size > 2 * 1024**3) return; // tokens apply only on torrents up to 2GB } ref = a.nextElementSibling; var button_fl = a.cloneNode(true); button_fl.search += '&usetoken=1'; button_fl.className = 'tooltip button_fl'; button_fl.text = 'FL'; button_fl.title = 'Use a FL Token'; button_fl.style.fontWeight = 700; //button_fl.style.color = 'green'; button_fl.onclick = function(e) { return confirm('Are you sure you want to use a freeleech token here?') }; button_fl.onmouseover = function(e) { o.showTooltip(); }; button_fl.onmouseout = function(e) { o.hideTooltip(); }; a.parentNode.insertBefore(button_fl, ref); a.parentNode.insertBefore(document.createTextNode(' | '), ref); }); })();