Torrenter

Adds links to torrent sites on popular movie websites.

当前为 2021-10-06 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name Torrenter
  3. // @namespace http://www.google.com/search?q=mabakay
  4. // @version 1.63
  5. // @description Adds links to torrent sites on popular movie websites.
  6. // @description:pl-PL Dodaje linki do stron z torrentami na popularnych stronach o filmach.
  7. // @author mabakay
  8. // @copyright 2010 - 2021, mabakay
  9. // @date 06 October 2021
  10. // @license MIT
  11. // @run-at document-end
  12. // @icon64URL https://raw.githubusercontent.com/mabakay/torrenter/master/torrenter_64.png
  13. // @supportURL https://github.com/mabakay/torrenter
  14. // @match http://www.filmweb.pl/*
  15. // @match https://www.filmweb.pl/*
  16. // @match http://release24.pl/*
  17. // @match https://release24.pl/*
  18. // @match http://www.imdb.com/*
  19. // @match https://www.imdb.com/*
  20. // @grant none
  21. // ==/UserScript==
  22.  
  23. (function () {
  24. 'use strict';
  25.  
  26. var engines = [
  27. "https://thepiratebay10.org/search/{0}/0/7/0",
  28. "https://rarbg.to/torrents.php?search={0}&order=seeders&by=DESC",
  29. "http://1337x.to/search/{0}/1/",
  30. "https://torrentz2eu.org/index.html?q={0}",
  31. "https://yts.mx/browse-movies/{0}/all/all/0/seeds/0/all",
  32. "https://eztv.re/search/{0}",
  33. "https://zooqle.com/search?q={0}&s=ns&v=t&sd=d",
  34. "https://www.torrentdownloads.me/search/?new=1&s_cat=0&search={0}",
  35. "https://www.limetorrents.pro/search/all/{0}/seeds/1/"
  36. ];
  37.  
  38. var hostName = window.location.hostname;
  39.  
  40. setTimeout(function() { processSite(hostName); }, 250);
  41.  
  42. function processSite(hostName) {
  43. switch (hostName) {
  44. case "release24.pl":
  45. processRelease24();
  46. break;
  47.  
  48. case "www.filmweb.pl":
  49. processFilmweb();
  50. break;
  51.  
  52. case "www.imdb.com":
  53. processImdb();
  54. break;
  55. }
  56. }
  57.  
  58. function createLinkSpan(tag, title, style, itemStyle) {
  59. var span = document.createElement(tag);
  60. span.setAttribute("id", "Torrenter");
  61. span.setAttribute("style", style);
  62.  
  63. for (var i = 0; i < engines.length; i++) {
  64. var link = document.createElement("a");
  65. link.setAttribute("href", format(engines[i], encodeURIComponent(title)));
  66.  
  67. if (itemStyle) {
  68. link.setAttribute("style", itemStyle);
  69. }
  70.  
  71. var urlRegex = /(https?:\/\/)(.+?)\//;
  72. var regexResult = engines[i].match(urlRegex);
  73. link.innerHTML = getFavIconImg(regexResult[2]);
  74.  
  75. link.setAttribute("title", regexResult[2]);
  76.  
  77. if (i > 0) {
  78. var separator = document.createElement("span");
  79. separator.innerHTML = "&nbsp;|&nbsp;";
  80.  
  81. span.appendChild(separator);
  82. }
  83.  
  84. span.appendChild(link);
  85. }
  86.  
  87. return span;
  88. }
  89.  
  90. function getFavIconImg(url) {
  91. return '<img src="http://www.google.com/s2/favicons?domain=' + url + '" width="16px" height="16px">';
  92. }
  93.  
  94. function format(str) {
  95. for (var i = 1; i < arguments.length; i++) {
  96. var argNum = "{" + (i - 1) + "}";
  97.  
  98. str = str.replace(argNum, arguments[i]);
  99. }
  100.  
  101. return str;
  102. }
  103.  
  104. function processRelease24() {
  105. var titleElement = document.getElementById("mainwindow");
  106. var loopCount = titleElement.childElementCount > 3 ? titleElement.childElementCount - 3 : 2;
  107.  
  108. for (var i = 1; i < loopCount; i++) {
  109. var elem = titleElement.children[i];
  110.  
  111. if (elem.className === "wpis") {
  112. var title_regex = /\"(.*)\"\s*(\(([0-9]{4})\))?/;
  113. var match = elem.children[0].children[0].innerHTML.match(title_regex);
  114.  
  115. if (match != null) {
  116. var title = match[1];
  117.  
  118. if (match.length === 4 && match[3]) {
  119. title += " " + match[3];
  120. }
  121.  
  122. var span = createLinkSpan("span", title, "margin-left: 3em; font-weight: normal;", "position: relative; top: 5px;");
  123.  
  124. elem.children[2].children[0].children[0].children[0].children[0].children[1].children[0].children[0].children[0].appendChild(
  125. span
  126. );
  127. }
  128. }
  129. }
  130. }
  131.  
  132. function processFilmweb() {
  133. var titleElement = document.querySelector(".filmCoverSection__title span");
  134. var title;
  135.  
  136. if (titleElement) {
  137. var smallTitleElement = document.querySelector(".filmCoverSection__orginalTitle");
  138.  
  139. if (smallTitleElement) {
  140. title = smallTitleElement.innerText;
  141. } else {
  142. title = document.querySelector(".filmCoverSection__title span").innerText;
  143. }
  144.  
  145. var year = document.querySelector(".filmCoverSection__year").innerText;
  146. var yearRegexp = /([0-9]{4})/;
  147. var match = year.match(yearRegexp);
  148.  
  149. if (match != null) {
  150. title += " " + match[1];
  151. }
  152. }
  153.  
  154. var headerElement = document.querySelector('.filmCoverSection__type');
  155. if (headerElement && title) {
  156. headerElement.appendChild(createLinkSpan("span", title, "margin-left: 1em; font-size: 0.7em; display: inline-flex;", "position: relative; top: 2px;"), titleElement.nextSibling);
  157. }
  158. }
  159.  
  160. function processImdb() {
  161. var style = "margin-top: 0.5em; font-size: 0.7em;";
  162. var titleElement = document.querySelector('[class*="TitleHeader__TitleText"]')
  163. var title;
  164. var hasSmallTitle = false;
  165.  
  166. if (titleElement) {
  167. var smallTitleElement = document.querySelector('[class*="OriginalTitle__OriginalTitle"]')
  168.  
  169. if (smallTitleElement) {
  170. style = "margin-left: 1.5em; font-size: 0.7em; margin-bottom: 0.5em; display: inline-block;";
  171. titleElement = smallTitleElement;
  172. hasSmallTitle = true;
  173.  
  174. title = smallTitleElement.childNodes[0].nodeValue;
  175.  
  176. // Remove "Original title" prefix
  177. var titleRegexp = /Original title: (.*)|.*/;
  178. var titleMatch = title.match(titleRegexp);
  179.  
  180. if (titleMatch != null) {
  181. title = titleMatch[1];
  182. }
  183. } else {
  184. title = titleElement.childNodes[0].nodeValue;
  185. }
  186.  
  187. var yearElement = document.querySelector('[class*="TitleBlockMetaData__ListItemText"]')
  188. if (yearElement) {
  189. var year = yearElement.textContent;
  190. var yearRegexp = /([0-9]{4})/;
  191. var match = year.match(yearRegexp);
  192.  
  193. if (match != null) {
  194. title += " " + match[1];
  195. }
  196. }
  197. }
  198.  
  199. if (titleElement && title) {
  200. if (hasSmallTitle) {
  201. titleElement.appendChild(createLinkSpan("span", title, style));
  202. } else {
  203. titleElement.parentElement.appendChild(createLinkSpan("div", title, style));
  204. }
  205. }
  206. }
  207. })();