IMDb Torrent Links - Chameleon

Show links to torrent sites on IMDb film pages

  1. // ==UserScript==
  2. // @namespace HD
  3. // @name IMDb Torrent Links - Chameleon
  4. // @description Show links to torrent sites on IMDb film pages
  5. // @version 1.1.0
  6. // @author SB100
  7. // @copyright 2021, SB100 (https://openuserjs.org/users/SB100)
  8. // @license MIT
  9. // @include https://www.imdb.com/title/tt*
  10. // ==/UserScript==
  11.  
  12. // ==OpenUserJS==
  13. // @author SB100
  14. // ==/OpenUserJS==
  15.  
  16. /* jshint esversion: 6 */
  17.  
  18. /**
  19. * =============================
  20. * ADVANCED OPTIONS
  21. * =============================
  22. */
  23.  
  24. (function () {
  25. })();
  26. const CONFIG = [{
  27. name: 'YouTube',
  28. icon: 'https://www.youtube.com/s/desktop/b4335f76/img/favicon_32.png',
  29. basePath: 'https://www.youtube.com/results?search_query=',
  30. extra: {
  31. useMovieNameInstead: true,
  32. append: ' trailer'
  33. },
  34. },
  35. {
  36. name: 'ktuvit',
  37. icon: 'https://i.imgur.com/mN6ofGN.png',
  38. basePath: 'https://www.ktuvit.me/Search.aspx?q=',
  39. extra: {
  40. useMovieNameInstead: true,
  41. },
  42. },
  43.  
  44. {
  45. name: 'wizdom',
  46. icon: 'https://www.google.com/s2/favicons?domain=https://wizdom.xyz/#/',
  47. basePath: 'https://wizdom.xyz/movie/',
  48. },
  49. {
  50. name: 'subscene',
  51. icon: 'https://i.imgur.com/9d6AjB8.png',
  52. basePath: 'https://subscene.com/subtitles/searchbytitle?query=',
  53. extra: {
  54. useMovieNameInstead: true,
  55. },
  56. },
  57. {
  58. name: 'filelist',
  59. icon: 'http://i.imgur.com/tfnsPEn.jpg',
  60. basePath: 'http://filelist.io/browse.php?cat=0&searchin=0&sort=3&search=',
  61. },
  62. {
  63. name: 'iptorrents',
  64. icon: 'http://i.imgur.com/cmbcH7k.png',
  65. basePath: 'http://www.iptorrents.com/t?o=size;q=',
  66. },
  67. {
  68. name: 'hd-torrents',
  69. icon: 'http://i.imgur.com/iQfuiyn.png',
  70. basePath: 'https://hd-torrents.org/torrents.php?&active=0&order=size&search=',
  71. },
  72. {
  73. name: 'fuzer',
  74. icon: 'https://i.imgur.com/NDcWOfZ.png',
  75. basePath: 'https://www.fuzer.me/browse.php?ref_=basic&query=',
  76. },
  77. {
  78. name: 'netflix',
  79. icon: 'https://t2.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://www.netflix.com/search?q=&size=16',
  80. basePath: 'https://www.netflix.com/search?q=',
  81. extra: {
  82. useMovieNameInstead: true,
  83. },
  84. },
  85. {
  86. name: 'disneyplus',
  87. icon: 'https://t0.gstatic.com/faviconV2?client=SOCIAL&type=FAVICON&fallback_opts=TYPE,SIZE,URL&url=https://www.apps.disneyplus.com/&size=16',
  88. basePath: 'https://www.apps.disneyplus.com/il/explore?search_query=',
  89. extra: {
  90. useMovieNameInstead: true,
  91. },
  92. },
  93. ]
  94.  
  95. /**
  96. * =============================
  97. * END ADVANCED OPTIONS
  98. * DO NOT MODIFY BELOW THIS LINE
  99. * =============================
  100. */
  101.  
  102. /**
  103. * Find the IMDb ID from the URL
  104. */
  105. function getTTId() {
  106. const idMatch = window.location.href.match(/tt[\d]+/);
  107. return idMatch && idMatch[0];
  108. }
  109.  
  110. /**
  111. * Find the movie name from the header
  112. */
  113. function getMovieName() {
  114. const name = document.querySelector('[data-testid="hero__pageTitle"]');
  115. if (!name) {
  116. return '';
  117. }
  118.  
  119. return name.innerText;
  120. }
  121.  
  122. /**
  123. * Build a list of icons to be placed into the navigation bar
  124. */
  125. function buildIcons(imdbId, movieName) {
  126. const fragment = document.createDocumentFragment();
  127.  
  128. CONFIG.forEach(c => {
  129. const img = document.createElement('img');
  130. img.src = c.icon;
  131. img.title = c.name;
  132. img.classList.add('t-link__img');
  133.  
  134. const searchString = `${c.extra && c.extra.useMovieNameInstead ? movieName : imdbId}${c.extra && c.extra.append ? c.extra.append : ''}`;
  135. const a = document.createElement('a');
  136. a.href = `${c.basePath}${encodeURIComponent(searchString)}`
  137. a.target = '_self'; //blank
  138. a.rel = 'noopener noreferrer';
  139. a.classList.add('t-link');
  140.  
  141. a.appendChild(img);
  142. fragment.appendChild(a);
  143. });
  144.  
  145. return fragment;
  146. }
  147.  
  148. /**
  149. * Add the built list of icons to the navigation bar
  150. */
  151. function addIconsToSite(icons) {
  152. const nav = document.querySelector('[data-testid="hero-subnav-bar-left-block"]');
  153. if (!nav) {
  154. return;
  155. }
  156.  
  157. const li = document.createElement('li');
  158. li.classList.add('ipc-inline-list__item');
  159. li.appendChild(icons);
  160.  
  161. nav.appendChild(li);
  162. }
  163.  
  164. /**
  165. * Create a style tag to add into the document head, and add some styles to it
  166. */
  167. function createCss() {
  168. const css = `.t-link {
  169. padding: 0 4px;
  170. position: relative;
  171. top: 2px;
  172. }
  173.  
  174. .t-link__img {
  175. max-width: 24px;
  176. max-height: 24px;
  177. }`;
  178.  
  179. const style = document.createElement('style');
  180. style.type = 'text/css';
  181. style.appendChild(document.createTextNode(css));
  182.  
  183. document.head.appendChild(style);
  184. }
  185.  
  186. function onload() {
  187. createCss();
  188. const imdbId = getTTId();
  189. const movieName = getMovieName();
  190. const icons = buildIcons(imdbId, movieName);
  191. addIconsToSite(icons);
  192. }
  193.  
  194. //window.onload = onload;
  195. onload();