[RED] FL link in notifications

yes

目前為 2020-12-19 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

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

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         [RED] FL link in notifications
// @namespace    https://greasyfork.org/users/321857-anakunda
// @version      1.01
// @description  yes
// @author       Anakunda
// @match        https://redacted.ch/torrents.php?*action=notify*
// @match        https://orpheus.network/torrents.php?*action=notify*
// @iconURL      https://redacted.ch/favicon.ico
// ==/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/.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);
  });
})();