1337x - Torrent page improvements

Makes titles longer on the torrent page and optionally enables the detail box when available.

  1. // ==UserScript==
  2. // @name 1337x - Torrent page improvements
  3. // @namespace NotNeo
  4. // @version 1.5.6
  5. // @description Makes titles longer on the torrent page and optionally enables the detail box when available.
  6. // @author NotNeo
  7. // @license unlicense
  8. // @match *://*.1337x.to/account
  9. // @match *://*.1337x.to/torrent/*
  10. // @match *://*.1337x.st/account
  11. // @match *://*.1337x.st/torrent/*
  12. // @match *://*.1337x.ws/account
  13. // @match *://*.1337x.ws/torrent/*
  14. // @match *://*.1337x.eu/account
  15. // @match *://*.1337x.eu/torrent/*
  16. // @match *://*.1337x.se/account
  17. // @match *://*.1337x.se/torrent/*
  18. // @match *://*.1337x.is/account
  19. // @match *://*.1337x.is/torrent/*
  20. // @match *://*.1337x.gd/account
  21. // @match *://*.1337x.gd/torrent/*
  22. // @grant GM_getValue
  23. // @grant GM_setValue
  24. // @grant GM_deleteValue
  25. // ==/UserScript==
  26.  
  27. var imdbThing, foundIMDB, containerFailureCounter = 0;
  28.  
  29. var domainArr = [
  30. "1337x.to/account",
  31. "1337x.st/account",
  32. "1337x.ws/account",
  33. "1337x.eu/account",
  34. "1337x.se/account",
  35. "1337x.is/account",
  36. "1337x.gd/account"
  37. ]
  38.  
  39. function AreInAccount() {
  40. let istrue = false;
  41. domainArr.forEach(function(cur){
  42. if(window.location.href.indexOf(cur) >= 0) {
  43. istrue = true;
  44. return false; //breaks out of foreach, not outer function
  45. }
  46. });
  47. return istrue;
  48. }
  49.  
  50. var hideStreamButt = false;
  51. var hideAnonButt = false;
  52. var hideDirectButt = false;
  53. var usingDetailBox = true;
  54. var usingIMDBLinker = true;//setting to default
  55.  
  56. if( GM_getValue("usingDetailBox") != null ) {
  57. usingDetailBox = GM_getValue("usingDetailBox"); //overriding with saved settings if there is one
  58. }
  59. if( GM_getValue("hideAnonButt") != null ) {
  60. hideAnonButt = GM_getValue("hideAnonButt"); //overriding with saved settings if there is one
  61. }
  62. if( GM_getValue("hideStreamButt") != null ) {
  63. hideStreamButt = GM_getValue("hideStreamButt"); //overriding with saved settings if there is one
  64. }
  65. if( GM_getValue("hideDirectButt") != null ) {
  66. hideDirectButt = GM_getValue("hideDirectButt"); //overriding with saved settings if there is one
  67. }
  68. if( GM_getValue("usingIMDBLinker") != null ) {
  69. usingIMDBLinker = GM_getValue("usingIMDBLinker"); //overriding with saved settings if there is one
  70. }
  71.  
  72. var imdbInfoText = "If the uploader has an imdb link anywhere in his description, then the button will take you directly to the imdb page for that movie.\\nIf however there is no imdb link in the description, the button will take you to the search results page for the movie name instead.";
  73.  
  74. if(AreInAccount()) { //if on settings page
  75. document.getElementById("settings").innerHTML = '<br><input type="checkbox" value="1" name="useDetail" id="useDetailCheckbox" style="transform: scale(1.5);"> <label for="useDetailCheckbox">Show detail box for torrents, when available.</label><br>' +
  76. '<input type="checkbox" value="1" name="useIMDB" id="usingIMDBLinker" style="transform: scale(1.5);"> <label for="usingIMDBLinker">Show IMDb link button in detail box.</label> <a href="#" onclick="alert(\''+imdbInfoText+'\'); return false;" ><b>?</b></a><br>' +
  77. '<input type="checkbox" value="1" name="hideAnon" id="hideAnonCheckbox" style="transform: scale(1.5);"> <label for="hideAnonCheckbox">Hide the "Anonymous Download" button</label><br>' +
  78. '<input type="checkbox" value="1" name="hideDirect" id="hideDirectCheckbox" style="transform: scale(1.5);"> <label for="hideDirectCheckbox">Hide the "Direct Download" button</label><br>' +
  79. '<input type="checkbox" value="1" name="hideStream" id="hideStreamCheckbox" style="transform: scale(1.5);"> <label for="hideStreamCheckbox">Hide the "Play Now (Stream)" button</label><br>' + document.getElementById("settings").innerHTML;
  80.  
  81. document.getElementById("useDetailCheckbox").checked = usingDetailBox; //settings checkbox checked value to saved value (or default, if none are saved)
  82. document.getElementById("hideAnonCheckbox").checked = hideAnonButt; //settings checkbox checked value to saved value (or default, if none are saved)
  83. document.getElementById("hideDirectCheckbox").checked = hideDirectButt; //settings checkbox checked value to saved value (or default, if none are saved)
  84. document.getElementById("hideStreamCheckbox").checked = hideStreamButt; //settings checkbox checked value to saved value (or default, if none are saved)
  85. document.getElementById("usingIMDBLinker").checked = usingIMDBLinker; //settings checkbox checked value to saved value (or default, if none are saved)
  86.  
  87. document.getElementById("useDetailCheckbox").onchange = function() { //on value change
  88. usingDetailBox = document.getElementById("useDetailCheckbox").checked; //settings current value to the the new
  89. GM_setValue("usingDetailBox", usingDetailBox); //saving current value
  90. };
  91. document.getElementById("hideAnonCheckbox").onchange = function() { //on value change
  92. hideAnonButt = document.getElementById("hideAnonCheckbox").checked; //settings current value to the the new
  93. GM_setValue("hideAnonButt", hideAnonButt); //saving current value
  94. };
  95. document.getElementById("hideDirectCheckbox").onchange = function() { //on value change
  96. hideDirectButt = document.getElementById("hideDirectCheckbox").checked; //settings current value to the the new
  97. GM_setValue("hideDirectButt", hideDirectButt); //saving current value
  98. };
  99. document.getElementById("hideStreamCheckbox").onchange = function() { //on value change
  100. hideStreamButt = document.getElementById("hideStreamCheckbox").checked; //settings current value to the the new
  101. GM_setValue("hideStreamButt", hideStreamButt); //saving current value
  102. };
  103. document.getElementById("usingIMDBLinker").onchange = function() { //on value change
  104. usingIMDBLinker = document.getElementById("usingIMDBLinker").checked; //settings current value to the the new
  105. GM_setValue("usingIMDBLinker", usingIMDBLinker); //saving current value
  106. };
  107. }
  108. else {
  109. var title = document.getElementsByTagName("title")[0].textContent;
  110. title = title.substring(9, title.length-16);
  111. var titleArea = document.getElementsByClassName("box-info-heading")[0];
  112. if(titleArea.getElementsByTagName("span").length == 2 && title.length > 100) {
  113. title = title.substring(0, 100) + "...";
  114. } else if(titleArea.getElementsByTagName("span").length >= 3 && title.length > 85) {
  115. title = title.substring(0, 85) + "...";
  116. }
  117. titleArea.getElementsByTagName("h1")[0].textContent = title;
  118.  
  119. if(usingDetailBox) {
  120. var realDetailBox = document.getElementsByClassName("torrent-detail")[0];
  121. if(realDetailBox !== undefined) {
  122. if(!(realDetailBox.offsetWidth > 0 && realDetailBox.offsetHeight > 0)) { //if realDetailBox is not visible, make own
  123. var datHTML = realDetailBox.innerHTML;
  124. document.getElementsByClassName("torrent-category-detail")[0].innerHTML += '<div class="torrent-detail clearfix" style="display: inline-block; position: relative; margin-top: 10px; width: 100%;">'+datHTML+'</div>';
  125. }
  126. }
  127. }
  128.  
  129. if(usingIMDBLinker) {
  130. foundIMDB = document.getElementById("description").innerHTML.split("imdb.com/title/tt")[1].split(/[^0-9]+/)[0];
  131. foundIMDB = "tt"+foundIMDB;
  132. if (foundIMDB != null) { //if code was found...
  133. if (!/^tt[0-9]{6,}[0-9]$/.test(foundIMDB)) { //if code is invalid...
  134. foundIMDB = null; //...make it null
  135. }
  136. }
  137. imdbThing = `<span class="imdbRatingPlugin" data-user="ur000000000" data-title="`+foundIMDB+`" data-style="p2">
  138. <a href="https://www.imdb.com/title/`+foundIMDB+`/?ref_=plg_rt_1"><img src="https://ia.media-imdb.com/images/G/01/imdb/plugins/rating/images/imdb_37x18.png" alt="" /></a>
  139. </span>`;
  140.  
  141. if(document.getElementsByClassName("torrent-detail")[0]) {
  142. addGlobalStyle(`.imdbRatingPlugin .rating { background: none; height: unset; position: unset; max-width: unset; } .imdbRatingPlugin { position: absolute; top: 0; right: 0; z-index: 9999; } .torrent-detail-info h3 { margin-right: 105px; }`);
  143. WaitForContainerThenInsertAndActivate();
  144. }
  145. else if(foundIMDB != null) {
  146. document.querySelectorAll("#description > p:first-child")[0].innerHTML += imdbThing;
  147. addGlobalStyle(`
  148. #description span.imdbRatingPlugin > .rating .ofTen {padding: 0; line-height: 9px;}
  149. #description span.imdbRatingPlugin > .rating .ofTen::after { content: ""; }
  150. #description span.imdbRatingPlugin > .rating { padding: 0; background: none; height: unset; position: unset; max-width: unset; font-size: 15px; line-height: 15px;}
  151. #description span.imdbRatingPlugin > .rating::after { content: ""; }
  152. #description span.imdbRatingPlugin::after { content: ""; }
  153. #description span.imdbRatingPlugin {display: inline-block; line-height: unset; position: absolute; right: 20px; margin: 3px 0 0 0;}
  154. #description span.imdbRatingPlugin img { vertical-align: middle; }
  155.  
  156. `);
  157. ActivateIMDBScript();
  158. }
  159. }
  160.  
  161. if(hideStreamButt || hideAnonButt || hideDirectButt) {
  162. try {
  163. document.querySelectorAll("div.torrent-detail-page ul > li > a").forEach(function(el){
  164. //alert(el.textContent);
  165. if((hideStreamButt && el.textContent == "Play No‌w (Str‌eam)") || (hideAnonButt && el.textContent == "An‌on‌ymous Download") || (hideDirectButt && el.textContent == "Dir‌ect Download")) {
  166. el.parentNode.style.display = 'none';
  167. }
  168. });
  169. } catch(err) {
  170. alert("Error getting Stream/Anon button. Please report this via PM to \"NotNeo\"");
  171. }
  172. }
  173. }
  174.  
  175. function WaitForContainerThenInsertAndActivate() {
  176. let targetLocation = document.getElementById("mCSB_1_container");
  177. if(targetLocation === null) {
  178. containerFailureCounter++;
  179. if(containerFailureCounter >= 200) //Give up if after ~20 seconds we still cannot find the container
  180. {
  181. alert("Error getting infobox description container.");
  182. return;
  183. }
  184. setTimeout(WaitForContainerThenInsertAndActivate, 100);
  185. }
  186. else {
  187. targetLocation.innerHTML += imdbThing;
  188. if(foundIMDB != null) {
  189. ActivateIMDBScript();
  190. }
  191. else {
  192. let movieName = document.querySelectorAll(".torrent-detail-info h3 a")[0].textContent;
  193. document.querySelectorAll(".imdbRatingPlugin > a")[0].href = "https://www.imdb.com/find?q="+movieName.trim().replace(/\s/g, "+")+"&s=tt";
  194. }
  195. }
  196. }
  197.  
  198. function ActivateIMDBScript() {
  199. let imdbScript=document.createElement("script");
  200. imdbScript.id="imdb-rating-api";
  201. imdbScript.src="https://ia.media-imdb.com/images/G/01/imdb/plugins/rating/js/rating.js";
  202. let place = document.getElementsByClassName("imdbRatingPlugin")[0];
  203. place.parentNode.insertBefore(imdbScript, place);
  204. }
  205.  
  206. function addGlobalStyle(css) {
  207. var head, style;
  208. head = document.getElementsByTagName('head')[0];
  209. if (!head) { return; }
  210. style = document.createElement('style');
  211. style.type = 'text/css';
  212. style.innerHTML = css;
  213. head.appendChild(style);
  214. }

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址