real-debrid torrents: textbox with all links

adds a button which when pressed creates a textbox with all links for you to copy in jDownloader2

当前为 2022-01-23 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name real-debrid torrents: textbox with all links
  3. // @namespace https://greasyfork.org/en/users/12725-alistair1231
  4. // @version 0.1
  5. // @description adds a button which when pressed creates a textbox with all links for you to copy in jDownloader2
  6. // @author Alistair1231
  7. // @match https://real-debrid.com/torrents
  8. // @icon https://icons.duckduckgo.com/ip2/real-debrid.com.ico
  9. // @grant none
  10. // @require https://code.jquery.com/jquery-3.6.0.min.js
  11. // @license GPL-3.0
  12. // ==/UserScript==
  13.  
  14. (function () {
  15.  
  16.  
  17. var linkButton = document.createElement("input");
  18. linkButton.type = "button";
  19. linkButton.value = "Show Links";
  20. linkButton.onclick = function () {
  21. createTextArea();
  22. }
  23. // align right
  24. jQuery(linkButton).css("float", "inline-end");
  25. // make vertically centered
  26. jQuery(linkButton).css("margin-top", "10px");
  27.  
  28. jQuery(".content_separator_mini")[1].append(linkButton);
  29.  
  30.  
  31. function createTextArea() {
  32. var textbox = document.createElement("textarea");
  33.  
  34. jQuery(textbox).css({ "position": "fixed", "width": "50%", "height": "80%", "z-index": "999998", "background": "rgba(0,0,0,0.7)", "color": "#fff", "font-size": "16px", "font-family": "Consolas", "padding": "10px", "resize": "none", "outline": "none", "border": "none", "box-shadow": "0 0 10px #fff", "-webkit-box-shadow": "0 0 10px #fff", "-moz-box-shadow": "0 0 10px #fff", "-o-box-shadow": "0 0 10px #fff", "left": "25%", "top": "8%" });
  35. // get all the links
  36. var links = jQuery.makeArray(jQuery("tr form[action='./downloader'] textarea")).map(e => e.value);
  37. // add the links to the textbox
  38. textbox.value = links.join('\n');
  39. document.getElementsByTagName("body")[0].prepend(textbox);
  40. // highlight the text in the textbox
  41. textbox.select();
  42.  
  43.  
  44. //create close button in top right corner
  45. var close = document.createElement("div");
  46. jQuery(close).css({ "position": "fixed", "top": "10%", "right": "25%", "width": "30px", "height": "30px", "background": "#fff", "border-radius": "50%", "cursor": "pointer", "text-align": "center", "line-height": "30px", "font-size": "25px", "font-weight": "bold", "color": "#000", "z-index": "999999" });
  47. close.innerHTML = "X";
  48. //when button clicked remove elements
  49. jQuery(close).click(function () {
  50. jQuery(textbox).remove();
  51. jQuery(close).remove();
  52. });
  53.  
  54. // remove elements when escape is pressed
  55. jQuery(document).keyup(function (e) {
  56. if (e.keyCode == 27) {
  57. jQuery(textbox).remove();
  58. jQuery(close).remove();
  59. }
  60. });
  61.  
  62. //remove elements when clicked outside of them
  63. jQuery(document).click(function (e) {
  64. if (e.target != textbox && e.target != close && e.target != linkButton) {
  65. jQuery(textbox).remove();
  66. jQuery(close).remove();
  67. }
  68. });
  69. document.getElementsByTagName("body")[0].prepend(close);
  70.  
  71.  
  72. }
  73. })();