1337x Extract Links and Images

CLICK START BUTTON TO BEGIN! Filters listings by seeders/looters count. Extract magnet, links and images from inside the description page to the listing page

  1. // ==UserScript==
  2. // @name 1337x Extract Links and Images
  3. // @version 1.6
  4. // @description CLICK START BUTTON TO BEGIN! Filters listings by seeders/looters count. Extract magnet, links and images from inside the description page to the listing page
  5. // @author JasonC
  6. // @match https://1337x.to/
  7. // @match https://1337x.to/*
  8. // @grant none
  9.  
  10. // @namespace https://greasyfork.org/users/165799
  11. // ==/UserScript==
  12.  
  13. var pause = true;
  14. var torRows = new Array();
  15. var torlist = document.getElementsByClassName('table-list-wrap')[0].children[0];
  16.  
  17. function FilterRows()
  18. {
  19. var filter = parseInt(prompt("Minimum Seeds","-1"));
  20. if (!isNaN(filter) && filter > 0){
  21. for(var i=1;i<torlist.rows.length;i++){
  22. if (parseInt(parseInt(torlist.rows[i].cells[1].innerText)) < filter) {
  23. torlist.deleteRow(i);i--;
  24. }
  25. }
  26. }
  27. filter = parseInt(prompt("Minimum Leeches","-1"));
  28. if (!isNaN(filter) && filter > 0){
  29. for(var j=1;j<torlist.rows.length;j++){
  30. if (parseInt(parseInt(torlist.rows[j].cells[2].innerText)) < filter) {
  31. torlist.deleteRow(j);j--;
  32. }
  33. }
  34. }
  35. for (var l=1;l<torlist.rows.length;l++)
  36. {
  37. torRows.push(torlist.rows[l]);
  38. }
  39. }
  40.  
  41. function ExtractImage()
  42. {
  43. if (pause){return;}
  44. var torRow = torRows.shift();
  45. torRow.cells[0].style.overflow = "auto";
  46. torRow.cells[0].style.maxWidth = "400px";
  47. torRow.cells[1].style.verticalAlign = "top";
  48. var torurl = torRow.cells[0].children[1].href;
  49. console.log(torurl);
  50. $.get(torurl, function (html) {
  51. if (html) {
  52. try
  53. {
  54. $(html).find("A").each(function() {
  55. if (this.href.indexOf("magnet:") != -1)
  56. {
  57. torRow.cells[0].appendChild(this);
  58. return false;
  59. }
  60. });
  61. var UsedArr = new Array();
  62. $(html).find("#description").find("A").each(function() {
  63. UsedArr.push($(this)[0].outerHTML);
  64. var link = document.createElement("A");
  65. link.style.maxWidth = "400px";
  66. link.href = $(this).attr('href');
  67. link.innerHTML = $(this).html();
  68. torRow.cells[0].appendChild(document.createElement("br"));
  69. torRow.cells[0].appendChild(link);
  70. var IMGs = link.getElementsByTagName("IMG");
  71. for (var i=0;i<IMGs.length;i++)
  72. {
  73. if (IMGs[i].attributes["data-original"])
  74. IMGs[i].src = IMGs[i].attributes["data-original"].value;
  75. }
  76. });
  77. $(html).find("#description").find("IMG").each(function() {
  78. var imgHTML = $(this)[0].outerHTML;
  79. var SkipThis = false;
  80. for(var i=0;i<UsedArr.length;i++)
  81. {
  82. if (UsedArr[i].indexOf(imgHTML) != -1){
  83. SkipThis = true;
  84. }
  85. }
  86. if (!SkipThis)
  87. {
  88. var img = document.createElement("IMG");
  89. img.src = $(this).attr('data-original');
  90. img.style.maxWidth = "400px";
  91. torRow.cells[0].appendChild(document.createElement("br"));
  92. torRow.cells[0].appendChild(img);
  93. }
  94. });
  95. }
  96. catch(e){}
  97. finally
  98. {
  99. //this.parentElement.removeChild(this);
  100. if (torRows.length > 0){
  101. ExtractImage();}
  102. }
  103. }
  104. },'html');
  105. }
  106.  
  107. (function() {
  108. var MainBtn = document.createElement('INPUT');
  109. MainBtn.type = 'button';
  110. MainBtn.style.position = 'fixed';
  111. MainBtn.style.top = '10px';
  112. MainBtn.style.left = '10px';
  113. MainBtn.style.zIndex = "9999";
  114. MainBtn.value = 'Start';
  115. MainBtn.onclick = function() {
  116. pause = !pause;
  117. if (pause){
  118. MainBtn.value = "Stop";
  119. }
  120. else{
  121. MainBtn.value = "Start";
  122. }
  123. FilterRows();
  124. ExtractImage();
  125. };
  126. document.body.appendChild(MainBtn);
  127. })();