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

  1. // ==UserScript==
  2. // @name real-debrid torrents: textbox with all links
  3. // @namespace https://github.com/Alistair1231/my-userscripts/
  4. // @version 0.2.4
  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. // @require https://code.jquery.com/jquery-3.6.0.min.js
  10. // @license MIT
  11. // ==/UserScript==
  12. // https://openuserjs.org/scripts/Alistair1231/real-debrid_torrents_textbox_with_all_links
  13. // https://greasyfork.org/en/scripts/439014-real-debrid-torrents-textbox-with-all-links
  14.  
  15. (function () {
  16.  
  17.  
  18. var linkButton = document.createElement("input");
  19. linkButton.type = "button";
  20. linkButton.value = "Show Links";
  21. linkButton.onclick = function () {
  22. createTextArea();
  23. }
  24. // align right
  25. jQuery(linkButton).css("float", "inline-end");
  26. // make vertically centered
  27. jQuery(linkButton).css("margin-top", "10px");
  28.  
  29. jQuery(".content_separator_mini")[1].append(linkButton);
  30.  
  31.  
  32. function createTextArea() {
  33. var textbox = document.createElement("textarea");
  34.  
  35. jQuery(textbox).css({ "position": "fixed", "width": "80%", "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": "10%", "top": "8%" });
  36. // get all the links
  37. var links = jQuery.makeArray(jQuery("tr form[action='./downloader'] textarea")).map(e => e.value);
  38. var names = jQuery.makeArray(jQuery("tbody td.t-left span")).map(x => x.innerText);
  39. names.forEach((x, i) => {
  40. links[i] = links[i] + "#name=" + x;
  41. console.log(links[i]);
  42. });
  43. // add the links to the textbox
  44. textbox.value = links.join('\n');
  45.  
  46. document.getElementsByTagName("body")[0].prepend(textbox);
  47. // highlight the text in the textbox
  48. textbox.select();
  49.  
  50.  
  51. //create close button in top right corner
  52. var close = document.createElement("div");
  53. jQuery(close).css({ "position": "fixed", "top": "10%", "right": "10%", "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" });
  54. close.innerHTML = "X";
  55. //when button clicked remove elements
  56. jQuery(close).click(function () {
  57. jQuery(textbox).remove();
  58. jQuery(close).remove();
  59. });
  60.  
  61. // remove elements when escape is pressed
  62. jQuery(document).keyup(function (e) {
  63. if (e.keyCode == 27) {
  64. jQuery(textbox).remove();
  65. jQuery(close).remove();
  66. }
  67. });
  68.  
  69. //remove elements when clicked outside of them
  70. jQuery(document).click(function (e) {
  71. if (e.target != textbox && e.target != close && e.target != linkButton) {
  72. jQuery(textbox).remove();
  73. jQuery(close).remove();
  74. }
  75. });
  76. document.getElementsByTagName("body")[0].prepend(close);
  77.  
  78.  
  79. }
  80. })();