// ==UserScript== // @name [RED/OPS] FL link in notifications/better.php // @namespace https://greasyfork.org/users/321857-anakunda // @version 1.02 // @description Adds direct [FL] button to all notifications and better pages listings // @author Anakunda // @match https://redacted.ch/torrents.php?action=notify* // @match https://redacted.ch/torrents.php?page=*&action=notify* // @match https://redacted.ch/better.php?method=* // @match https://redacted.ch/better.php?page=*&method=* // @match https://orpheus.network/torrents.php?action=notify* // @match https://orpheus.network/torrents.php?page=*&action=notify* // @match https://orpheus.network/better.php?method=* // @match https://orpheus.network/better.php?page=*&method=* // @downloadURL none // ==/UserScript== 'use strict'; if (document.getElementById('fl_tokens') == null) return; switch (document.location.pathname) { case '/torrents.php': document.body.querySelectorAll('span.torrent_action_buttons > a.button_dl').forEach(function(a) { if (a.parentNode.parentNode.querySelector('strong.tl_free') != null) return; let ref = a.parentNode.parentNode.parentNode.parentNode.querySelector(':scope > td:nth-of-type(6)'); if (ref != null && /^(\d+(?:\.\d+))\s*(\w?B)\b/.test(ref.textContent.trim())) { let size = Math.round(RegExp.$1 * (2**10)**['B', 'KB', 'MB', 'GB', 'TB', 'PB'].indexOf(RegExp.$2.toUpperCase())); if (size > 2 * 2**20) return; // tokens apply only on torrents up to 2GB } ref = a.nextElementSibling; const button_fl = a.cloneNode(true); const searchParams = new URLSearchParams(button_fl.search); searchParams.set('usetoken', 1); button_fl.search += searchParams; button_fl.className = 'tooltip button_fl'; button_fl.text = 'FL'; button_fl.title = 'Use a FL Token'; button_fl.style.fontWeight = 700; button_fl.onclick = evt => confirm('Are you sure you want to use a freeleech token here?'); a.parentNode.insertBefore(button_fl, ref); a.parentNode.insertBefore(document.createTextNode(' | '), ref); }); break; case '/better.php': document.body.querySelectorAll('table.torrent_table > tbody > tr span.torrent_links_block').forEach(function(span) { if (span.querySelector('a.tl_free') != null) return; let button_fl = Array.prototype.find.call(span.getElementsByTagName('A'), a => a.textContent.trim() == 'DL'); if (button_fl) button_fl = button_fl.cloneNode(true); else return; const searchParams = new URLSearchParams(button_fl.search); searchParams.set('usetoken', 1); button_fl.search += searchParams; button_fl.className = 'brackets tooltip button_fl'; button_fl.text = 'FL'; button_fl.title = 'Use a FL Token'; button_fl.style.fontWeight = 700; button_fl.onclick = evt => confirm('Are you sure you want to use a freeleech token here?'); span.prepend(button_fl, ' '); }); break; }