[RED] FL link in notifications

Zzzzzz

目前为 2019-12-08 提交的版本,查看 最新版本

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