IMDb Scout

Add links from IMDb pages to torrent sites -- easy downloading from IMDb

当前为 2017-12-24 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb Scout
  3. // @namespace https://greasyfork.org/users/1057-kannibalox
  4. // @description Add links from IMDb pages to torrent sites -- easy downloading from IMDb
  5. //
  6. // Preference window for userscripts, hosted by greasyfork:
  7. // @require https://greasyfork.org/libraries/GM_config/20131122/GM_config.js
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.11.3/jquery.min.js
  9. //
  10. // @version 4.4.2
  11. // @include http://*.imdb.tld/title/tt*
  12. // @include http://*.imdb.tld/search/title*
  13. //
  14. // @connect *
  15. // @grant GM_log
  16. // @grant GM_getValue
  17. // @grant GM_setValue
  18. // @grant GM_addStyle
  19. // @grant GM_openInTab
  20. // @grant GM_xmlhttpRequest
  21. // @grant GM_registerMenuCommand
  22. //
  23. // ==/UserScript==
  24. /*---------------------Version History--------------------
  25. 1.00 - Initial public release, everything works on barebones greasemonkey
  26.  
  27. 1.50 - Added the ability to select which sites to load from the GM script commands
  28. - Moved the required method to userscripts
  29. - Removed FH, NZB, Avax
  30.  
  31. 1.60 - Added style elements and shading to display on imdb
  32.  
  33. 1.62 - Fixed bug:SCC-ARC not removing when unchecked
  34. - Alphabetized list
  35.  
  36. 1.70 - Cleaned up code
  37. - Added option to not run script on page load
  38.  
  39. 1.71 - Deprecated action-box field
  40.  
  41. 1.80 - Added icons that link to OpenSubs, Criticker, RT, YT
  42.  
  43. 1.81 - Added support for tv, only displays on shows listed as 'tv series'
  44. - Added support for icheckmovies at top bar.
  45.  
  46. 1.82 - Fixed title parsing for tv shows.
  47.  
  48. 1.83 - Fixed dhive not working properly
  49.  
  50. 1.90 - Set height of preference window to 450px, added scroll bar
  51.  
  52. 1.91 - Added another 11 torrent sites
  53.  
  54. 2.00 - Added auto updater
  55.  
  56. 2.01 - Added TC, FreshOn, TVT, STF, CC
  57. - Cleaned up code (tabbing)
  58. - Removed THR
  59. - Added TV-Rage to top bar
  60.  
  61. 2.02 - Added PS, THC, HH, HDStar
  62. - Fixed CC false positive
  63.  
  64. 2.03 - TehC now uses tt
  65. - Added Raymoz mod for AT
  66.  
  67. 2.04 - Added HDbits
  68. - Added TL
  69.  
  70. 2.10 - Added genre page search functionality
  71.  
  72. 2.11 - Fixed ICM because Nuked was whining
  73.  
  74. 2.12 - Removed tvrage
  75. - Fixed iCM (added tt)
  76. - Added HDVNbits
  77. - Changed RevTT to .me
  78. - Added HDT
  79. - removed autoupdate
  80.  
  81. 2.13 - removed xvidme
  82. - reinstated autoupdate
  83. - removed google chrome code
  84. - fixed hdvn and hdt issues
  85.  
  86. 2.14 - Added @grant entries for API access
  87. - Fixed tt parser to work on imdb pages with referral info in url
  88.  
  89. 2.2 - Switch preferences window to use GM_config
  90. - Consolidate icon & site lists
  91. - Added IPT, KASS, sHD, and HDW
  92. - Fix "Open All" link
  93. - Add option for strikethroughs on search page
  94. - Removed arrays from search URLs
  95. - Spring cleaning
  96.  
  97. 2.21 - Added SSL to TVT, HDME, TC, AHD, IPT, SCC
  98. - Added SSL option for CG
  99. - Added GFT, GFT-Gems, GFT-TV
  100. - Fixed SCC, SCC-ARC search URL
  101. - Removed TheBox, TheDVDClub
  102. - Added more comments, cleaned up some more stuff
  103.  
  104. 2.22 - Fixed TehC, BTN, BTN-Req, THC
  105. - Added a bunch of TV sites, courtesy of seedless
  106. - Added "both" option for sites, and made changes
  107. to allow coexistence of movie and TV sites with
  108. the same name
  109. - Code re-organization, documentation
  110. - Re-added code to allow an array for searchUrl
  111.  
  112. 2.22.1 - Minor fixes
  113.  
  114. 2.23 - Fixed THC, BTN
  115. - Distinguish between movies and TV on search page
  116.  
  117. 2.24 - Separate load_on_start option for search page
  118. - Fix search_string on search page
  119.  
  120. 2.25 - Added some helpful text when no sites have been enabled
  121.  
  122. 2.26 - Added code to show links when on pages besides just the "front" one
  123. (e.g. http://www.imdb.com/title/tt2310332/reference)
  124.  
  125. 2.26.1 - Correctly detect TV shows when on aforementioned pages.
  126.  
  127. 2.3 - Incorporate a bunch of changes courtesy of Inguin:
  128. - Added SSL to AT, TE, D-noid, TG, YT, RT
  129. - Changed tracker short titles to canonical form ADC, KG
  130. - Updated D-noid from .me to .pw
  131. - Fixed broken AT search; also updated to use .me so avoids redirect
  132. - Added BitHQ, ET (eutorrents)
  133. - Removed two broken THC; replaced with one fixed
  134. - Removed iplay, horrorhaven, hdstar, scandbits, leecherslair
  135. - Removed needless CG http/https duplication - plenty of listed sites self-sign
  136. - A-Z sites list for readability
  137. - Cleanup YT search string
  138. - Copyedits
  139. - Clean up code (tabs, trailing spaces)
  140. - Use consistent naming style
  141. - Added Letterboxd, Subscene to icons
  142. - Added options for showing icons
  143.  
  144. 2.31 - Added preliminary check for TSH
  145. - Change all SCC links to .org
  146.  
  147. 2.31.1 - Typo fix
  148.  
  149. 2.32 - On uncertain pages, display both movie and TV sites
  150.  
  151. 2.33 - Add year to possible search params
  152. - Add rutorrent
  153.  
  154. 2.33.1 - Change KG to .in
  155.  
  156. 2.33.2 - Change TSH to .me
  157.  
  158. 2.34 - Updated AT, TPB
  159. - Removed HDWing, TVT and CHDBits
  160. - Added RARBG
  161. - Re-added reverse match checking to support rarbg
  162.  
  163. 2.35 - Fixed YouTube icon, add SubtitleSeeker icon
  164. - Added FL.ro, bB, BHD, HDS
  165. - Fixed TL, TehC, HDb, HDVN, AHD, KG
  166. - Renamed reverseMatch to positiveMatch
  167.  
  168. 2.36 - Added Wikipedia to icon sites
  169.  
  170. 2.36.1 - Typo fix
  171.  
  172. 2.37 - Add PxHD
  173.  
  174. 2.38 - Fix subtitle seeker
  175. - Added CG-c
  176. - Added FilmAffinity
  177. - Added option to skip http check entirely
  178.  
  179. 2.38.1 - Typo fix
  180.  
  181. 2.38.2 - Global replace parameters
  182.  
  183. 2.38.3 - Typo fix
  184.  
  185. 3.00 - Clean up some formatting
  186. - Add support for new IMDb page format
  187. - Update jquery
  188.  
  189. 3.0.1 - Added Classix
  190.  
  191. 3.0.2 - Updated documentation/comments
  192.  
  193. 3.0.3 - Removed GOEM, FY, PS, MT
  194. - Added Metacritic, CanIStream.It?, AllMovie, Facebook, Amazon, Cartoon Chaos, MySpleen, Secret Cinema
  195. - Fixed Wikipedia icon
  196.  
  197. 3.1 - Handle HTTP failures less silently
  198.  
  199. 3.1.1 - Fix KASS
  200.  
  201. 3.1.2 - Fix TPB, TE, HDT
  202. - Add MTV, DVDSeed
  203.  
  204. 3.1.3 - Add M-T, UHDB, HDC, Blu-ray.com
  205. - Fix scenehd, RT
  206.  
  207. 3.1.4 - Add HDClub
  208.  
  209. 3.2 - Fix the button on new-style pages
  210.  
  211. 3.2.1 - Fix AHD
  212.  
  213. 3.3 - Be less obnoxious about failed calls
  214.  
  215. 3.4 - Add Netflix icon
  216. - Remove a default parameter to satisfy Chrome
  217.  
  218. 3.5 - Add KZ, NNM, BB-HD, t411, TD, Rutor
  219. - Fix HDClub
  220. - Fix preferences in Chrome, sort sites properly
  221.  
  222. 3.5.1 - Remove DHive, Fix AHD
  223.  
  224. 4.0 - Bring in UI changes courtesy of janot
  225. - Add spaceEncode and goToUrl to site options
  226. - Add option to show results as links instead of text
  227. - Differentiate between missing and logged out
  228. - General refactoring
  229.  
  230. 4.1 - Add RARAT
  231.  
  232. 4.2 - Fix t411
  233. - Use magic .tld domain in @include
  234.  
  235. 4.3 - Set @connect in metadata block
  236.  
  237. 4.3.1 - Fix THC
  238.  
  239. 4.3.2 - Add AR, TtN
  240. - Add year and "trailer" to youtube search
  241. - Fix M-team
  242.  
  243. 4.3.3 - Fix BitHQ, PTP-Req, SCC
  244.  
  245. 4.3.4 - Fix M-team, myspleen, avistaz, eutorrents
  246. - Removed KAT
  247.  
  248. 4.3.5 - Fix IPT, Freshon
  249. - Add ExtraTorrent
  250.  
  251. 4.3.6 - Fix Demonoid, EuTorrents (now CinemaZ)
  252. - Fix "Actually search for torrents" option
  253. - Add PrivateHD for movies and tv
  254.  
  255. 4.3.7 - Apply CinemaZ fixes to AvistaZ as well
  256.  
  257. 4.3.8 - Fix SurrealMoviez and MySpleen, switch to new PTP url
  258.  
  259. 4.3.9 - Fix criticker, add CN
  260.  
  261. 4.3.10 - Fix Netflix, MTV
  262.  
  263. 4.3.11 - Add CHD back
  264.  
  265. 4.3.12 - Fix typo
  266.  
  267. 4.4 - Fix BeyondHD
  268. - Allow unicode when searching by name
  269.  
  270. 4.4.1 - Add trakt.tv
  271.  
  272. 4.4.2 - Fix SC
  273. --------------------------------------------------------*/
  274.  
  275.  
  276. if (window.top != window.self) // Don't run on frames or iframes
  277. {
  278. return;
  279. }
  280.  
  281. //------------------------------------------------------
  282. // A list of all the sites, and the data necessary to
  283. // check IMDb against them.
  284. // Each site is a dictionary with the following attributes:
  285. // - name:
  286. // The site name, abbreviated
  287. // - searchUrl:
  288. // The URL to perform the search against, see below for how
  289. // to tailor the string to a site
  290. // - matchRegex:
  291. // The string which appears if the searchUrl *doesn't* return a result
  292. // - postiveMatch:
  293. // Changes the test to return true if the searchUrl *does* return
  294. // a result that matches matchRegex
  295. // - TV (optional):
  296. // If true, it means that this site will only show up on TV pages.
  297. // By default, sites only show up on movie pages.
  298. // - both (optional):
  299. // Means that the site will show up on both movie and TV pages
  300. // - spaceEncode (optional):
  301. // Changes the character used to encode spaces in movie titles
  302. // The default is '+'.
  303. // - goToUrl (optional):
  304. // Most of the time the same URLs that are used for checking are
  305. // the ones that are used to actually get to the movie,
  306. // but this allows overriding that.
  307. // - loggedOutRegex (optional):
  308. // If any text on the page matches this regex, the site is treated
  309. // as being logged out, rather than mising the movie. This option is
  310. // not effected by postiveMatch.
  311. // To create a search URL, there are four parameters
  312. // you can use inside the URL:
  313. // - %tt%:
  314. // The IMDb id with the tt prefix (e.g. tt0055630)
  315. // - %nott%:
  316. // The IMDb id without the tt prefix (e.g. 0055630)
  317. // - %search_string%:
  318. // The movie title (e.g. Yojimbo)
  319. // - %year%:
  320. // The movie year (e.g. 1961)
  321. // See below for examples
  322. //------------------------------------------------------
  323.  
  324. var sites = [
  325. { 'name': 'ADC',
  326. 'searchUrl': 'https://asiandvdclub.org/browse.php?descr=1&btnSubmit=Submit&search=%tt%',
  327. 'matchRegex': /Your search returned zero results|<h1>You need cookies enabled to log in.<\/h1>/,
  328. 'both': true},
  329. { 'name': 'AHD',
  330. 'searchUrl': 'https://awesome-hd.me/torrents.php?id=%tt%',
  331. 'matchRegex': /Your search did not match anything.|<h2>Error 404<\/h2>/,
  332. 'both': true},
  333. { 'name': 'AR',
  334. 'searchUrl': 'https://alpharatio.cc/torrents.php?searchstr=%search_string%+%year%&filter_cat[6]=1&filter_cat[7]=1&filter_cat[8]=1&filter_cat[9]=1',
  335. 'matchRegex': /Your search did not match anything/},
  336. { 'name': 'AR',
  337. 'searchUrl': 'https://alpharatio.cc/torrents.php?searchstr=%search_string%&filter_cat[1]=1&filter_cat[2]=1&filter_cat[3]=1&filter_cat[4]=1&filter_cat[5]=1',
  338. 'matchRegex': /Your search did not match anything/,
  339. 'TV': true},
  340. { 'name': 'AT',
  341. 'searchUrl': 'https://avistaz.to/movies?search=&imdb=%tt%',
  342. 'matchRegex': /class="overlay-container"/,
  343. 'positiveMatch': true},
  344. { 'name': 'AT',
  345. 'searchUrl': 'https://avistaz.to/tv-shows?search=&imdb=%tt%',
  346. 'matchRegex': /class="overlay-container"/,
  347. 'positiveMatch': true,
  348. 'TV': true},
  349. { 'name': 'Blutopia',
  350. 'searchUrl': 'https://blutopia.xyz/search?name=%search_string%',
  351. 'both': true},
  352. { 'name': 'bB',
  353. 'searchUrl': 'https://baconbits.org/torrents.php?action=basic&filter_cat[9]=1&searchstr=%search_string%+%year%',
  354. 'matchRegex': /Your search was way too l33t|You will be banned for 6 hours after your login attempts run out/},
  355. { 'name': 'bB',
  356. 'searchUrl': 'https://baconbits.org/torrents.php?action=basic&filter_cat[8]=1&filter_cat[10]=1&searchstr=%search_string%',
  357. 'matchRegex': /Your search was way too l33t|You will be banned for 6 hours after your login attempts run out/,
  358. 'TV': true},
  359. { 'name': 'BB-HD',
  360. 'searchUrl': 'https://bluebird-hd.org/browse.php?search=&incldead=0&cat=0&dsearch=%tt%&stype=or',
  361. 'matchRegex': /Nothing found|Ничего не найдено/,
  362. 'both': true},
  363. { 'name': 'BHD',
  364. 'searchUrl': 'https://beyondhd.xyz/browse.php?search=%tt%&searchin=title&incldead=1',
  365. 'matchRegex': /Nothing found!|Please login or Register a personal account to access our user area and great community/},
  366. { 'name': 'BHD',
  367. 'searchUrl': 'https://beyondhd.xyz/browse.php?c40=1&c44=1&c48=1&c89=1&c46=1&c45=1&search=%search_string%&searchin=title&incldead=0',
  368. 'matchRegex': /Nothing found!|Please login or Register a personal account to access our user area and great community/,
  369. 'TV': true},
  370. { 'name': 'BitHD',
  371. 'searchUrl': 'http://www.bit-hdtv.com/torrents.php?cat=0&search=%tt%',
  372. 'matchRegex': /<h2>No match!<\/h2>/},
  373. { 'name': 'BitHQ',
  374. 'searchUrl': 'http://www.bithq.org/search.php?search=%search_string%&options=AND&in=original&incldead=1',
  375. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  376. { 'name': 'BMTV',
  377. 'searchUrl': 'https://www.bitmetv.org/browse.php?search=%search_string%',
  378. 'matchRegex': /Nothing found!<\/h2>/,
  379. 'TV': true},
  380. { 'name': 'BTN',
  381. 'searchUrl': 'https://broadcasthe.net/torrents.php?imdb=%tt%',
  382. 'matchRegex': /Error 404|Lost your password\?/,
  383. 'TV': true},
  384. { 'name': 'BTN-Req',
  385. 'searchUrl': 'https://broadcasthe.net/requests.php?search=%search_string%',
  386. 'matchRegex': /Nothing found|Lost your password\?/,
  387. 'TV': true},
  388. { 'name': 'CaCh',
  389. 'searchUrl': 'http://www.cartoonchaos.org/index.php?page=torrents&search=%search_string%&category=0&options=0&active=0',
  390. 'matchRegex': />Av.<\/td>\s*<\/tr>\s*<\/table>|not authorized to view the Torrents/,
  391. 'both': true},
  392. { 'name': 'CC',
  393. 'searchUrl': 'http://www.cine-clasico.com/foros/search.php?terms=any&author=&sc=1&sf=all&sr=posts&sk=t&sd=d&st=0&ch=300&t=0&submit=Search&keywords=%tt%',
  394. 'matchRegex': /You will be banned for 6 hours after your login attempts run out.|You must specify at least one word to search for. Each word must consist of at least 3 characters and must not contain more than 14 characters excluding wildcards.|Disculpe/},
  395. { 'name': 'CG',
  396. 'searchUrl': 'https://cinemageddon.net/browse.php?search=%tt%',
  397. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  398. 'loggedOutRegex': 'Not logged in!'},
  399. { 'name': 'CG-c',
  400. 'searchUrl': 'https://cinemageddon.net/cocks/endoscope.php?what=imdb&q=%tt%',
  401. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  402. 'loggedOutRegex': 'Not logged in!'},
  403. { 'name': 'CHD',
  404. 'searchUrl': 'https://chdbits.co/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=4&search_mode=0&search=%tt%',
  405. 'matchRegex': /Nothing found/},
  406. { 'name': 'Classix',
  407. 'searchUrl': 'http://classix-unlimited.co.uk/torrents-search.php?search=%search_string%',
  408. 'matchRegex': /Nothing Found<\/div>/},
  409. { 'name': 'Demnoid',
  410. 'searchUrl': 'http://www.demonoid.pw/files/?query=%tt%',
  411. 'matchRegex': /<b>No torrents found<\/b>|We are currently performing the daily site maintenance.<br>/,
  412. 'both': true},
  413. { 'name': 'DVDSeed',
  414. 'searchUrl': 'http://www.dvdseed.eu/browse2.php?search=%tt%&wheresearch=2&incldead=1&polish=0&nuke=0&rodzaj=0',
  415. 'matchRegex': /Nic tutaj nie ma!<\/h2>/},
  416. { 'name': 'ET',
  417. 'searchUrl': 'https://cinemaz.to/movies?search=&imdb=%tt%',
  418. 'matchRegex': /class="overlay-container"/,
  419. 'positiveMatch': true},
  420. { 'name': 'ET',
  421. 'searchUrl': 'https://cinemaz.to/tv-shows?search=&imdb=%tt%',
  422. 'matchRegex': /class="overlay-container"/,
  423. 'positiveMatch': true,
  424. 'TV': true},
  425. { 'name': 'eThor',
  426. 'searchUrl': 'http://ethor.net/browse.php?stype=b&c23=1&c20=1&c42=1&c5=1&c19=1&c25=1&c6=1&c37=1&c43=1&c7=1&c9=1&advcat=0&incldead=0&includedesc=1&search=%tt%',
  427. 'matchRegex': /Try again with a refined search string.|<h1>Note: Vous devez activer vos 'cookies' pour pouvoir vous identifier.<\/h1>/},
  428. { 'name': 'ExtraTorrent',
  429. 'searchUrl': 'https://extratorrent.cc/search/?search=%search_string%+%year%',
  430. 'matchRegex': /total <b>0<\/b> torrents found/},
  431. { 'name': 'FL',
  432. 'searchUrl': 'https://filelist.ro/browse.php?search=%tt%',
  433. 'matchRegex': /<h2>Nu s-a găsit nimic!<\/h2>/,
  434. 'both': true},
  435. { 'name': 'FSS',
  436. 'searchUrl': 'http://fss.omnilounge.co.uk/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  437. 'matchRegex': /Try again with a different search string?|<h1>You need cookies enabled to log in.<\/h1>/},
  438. { 'name': 'GFT',
  439. 'searchUrl': 'https://www.thegft.org/browse.php?view=0&c2=1&c1=1&c9=1&c11=1&c48=1&c8=1&c18=1&c49=1&c7=1&c38=1&c46=1&c5=1&c13=1&c26=1&c37=1&c19=1&c47=1&c17=1&c4=1&c22=1&c25=1&c20=1&c3=1&search=%tt%&searchtype=0',
  440. 'matchRegex': /Nothing found!<\/h2>/},
  441. { 'name': 'GFT',
  442. 'searchUrl': 'https://www.thegft.org/browse.php?view=0&search=%search_string%',
  443. 'matchRegex': /Nothing found!<\/h2>/,
  444. 'TV': true},
  445. { 'name': 'GFT-Gems',
  446. 'searchUrl': 'https://www.thegft.org/browse.php?view=1&search=%tt%&searchtype=0',
  447. 'matchRegex': /Nothing found!<\/h2>/},
  448. { 'name': 'HD',
  449. 'searchUrl': 'http://hounddawgs.org/torrents.php?type=&userid=&searchstr=&searchimdb=%tt%&searchlang=&searchtags=&order_by=s3&order_way=desc&showOnly=#results',
  450. 'matchRegex': /<h2>Din søgning gav intet resultat.<\/h2>/,
  451. 'both': true},
  452. { 'name': 'HDb',
  453. 'searchUrl': 'https://hdbits.org/browse.php?c3=1&c1=1&c4=1&c2=1&imdb=%tt%',
  454. 'matchRegex': /Nothing here!|You need cookies enabled to log in/,
  455. 'both': true},
  456. { 'name': 'HDC',
  457. 'searchUrl': 'https://hdchina.club/torrents.php?incldead=0&spstate=0&inclbookmarked=0&boardid=0&seeders=&search=%tt%&search_area=4&search_mode=2',
  458. 'matchRegex': /Nothing found! Try again with a refined search string./},
  459. { 'name': 'HDClub',
  460. 'searchUrl': 'http://hdclub.org/browse.php?webdl=0&3d=0&search=&incldead=0&dsearch=%tt%',
  461. 'matchRegex': /Nothing was found|Ничего не найдено|Нічого не знайдено/,
  462. 'both': true},
  463. { 'name': 'HDME',
  464. 'searchUrl': 'https://hdme.eu/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  465. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/},
  466. { 'name': 'HDME',
  467. 'searchUrl': 'https://hdme.eu/browse.php?search=%search_string%&blah=0&cat=0&incldead=1',
  468. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/,
  469. 'TV': true},
  470. { 'name': 'HDS',
  471. 'searchUrl': 'https://hdsky.me/torrents.php?incldead=1&search=%tt%&search_area=4&search_mode=0',
  472. 'matchRegex': /Nothing found! Try again with a refined search string|Email:hdsky.me@gmail.com/},
  473. { 'name': 'HDS',
  474. 'searchUrl': 'https://hdsky.me/torrents.php?cat402=1&cat403=1&incldead=1&search=%search_string%&search_area=0&search_mode=0',
  475. 'matchRegex': /Nothing found! Try again with a refined search string|Email:hdsky.me@gmail.com/,
  476. 'TV': true},
  477. { 'name': 'HDSpace',
  478. 'icon': 'http://www.favicon.by/ico/5991df36e3635.ico',
  479. 'searchUrl': 'https://hd-space.org/index.php?page=torrents&active=0&options=2&search=%nott%',
  480. 'both': true},
  481. { 'name': 'HDT',
  482. 'icon': 'https://hdts.ru/favicon.ico',
  483. 'searchUrl': 'http://hd-torrents.org/torrents.php?active=0&options=2&search=%tt%',
  484. 'matchRegex': /No torrents here.../,
  485. 'both': true},
  486. { 'name': 'HDVN',
  487. 'searchUrl': 'http://torviet.com/torrents.php?search=%tt%&search_area=4&search_mode=0',
  488. 'matchRegex': /Nothing found! Try again with a refined search string|You need cookies enabled to log in or switch language/,
  489. 'both': true},
  490. { 'name': 'ILC',
  491. 'searchUrl': 'http://www.iloveclassics.com/browse.php?incldead=1&searchin=2&search=%tt%',
  492. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  493. { 'name': 'IPT',
  494. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%tt%',
  495. 'matchRegex': /<h1 style="color:yellow">No Torrents Found!/},
  496. { 'name': 'IPT',
  497. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%search_string%',
  498. 'matchRegex': /<h1 style="color:yellow">No Torrents Found!/,
  499. 'TV': true},
  500. { 'name': 'KG',
  501. 'searchUrl': 'https://www.karagarga.in/browse.php?search_type=imdb&search=%nott%',
  502. 'matchRegex': /<h2>No torrents found|<h1>If you want the love<\/h1>/},
  503. { 'name': 'KZ',
  504. 'searchUrl': 'http://kinozal.tv/browse.php?s=%search_string%+%year%&g=0&c=1002&v=0&d=0&w=0&t=0&f=0',
  505. 'matchRegex': 'Нет активных раздач, приносим извинения. Пожалуйста, уточните параметры поиска'},
  506. { 'name': 'KZ',
  507. 'searchUrl': 'http://kinozal.tv/browse.php?s=%search_string%+%year%&g=0&c=1001&v=0&d=0&w=0&t=0&f=0',
  508. 'matchRegex': 'Нет активных раздач, приносим извинения. Пожалуйста, уточните параметры поиска',
  509. 'TV': true},
  510. { 'name': 'M-T',
  511. 'searchUrl': 'https://tp.m-team.cc/movie.php?incldead=1&spstate=0&inclbookmarked=0&search=%tt%&search_area=4&search_mode=2',
  512. 'matchRegex': /Nothing here!|Try again with a refined search string./},
  513. { 'name': 'MS',
  514. 'searchUrl': 'http://www.myspleen.org/browse.php?search=%search_string%&title=0&cat=0',
  515. 'matchRegex': /<strong>Nothing found!<\/strong>|<title>MySpleen :: Login<\/title>/,
  516. 'both': true},
  517. { 'name': 'MTV',
  518. 'searchUrl': 'https://www.morethan.tv/torrents.php?searchstr=%search_string%+%year%&tags_type=1&order_by=time&order_way=desc&group_results=1&filter_cat%5B1%5D=1&action=basic&searchsubmit=1',
  519. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  520. { 'name': 'MTV',
  521. 'searchUrl': 'https://www.morethan.tv/torrents.php?searchstr=%search_string%&tags_type=1&order_by=time&order_way=desc&group_results=1&filter_cat%5B2%5D=1&action=basic&searchsubmit=1',
  522. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/,
  523. 'TV': true},
  524. { 'name': 'NNM',
  525. 'searchUrl': 'https://nnm-club.me/forum/tracker.php?nm=%search_string%+%year%',
  526. 'matchRegex': 'Не найдено',
  527. 'both': true},
  528. { 'name': 'NB',
  529. 'searchUrl': 'https://norbits.net/browse.php?incldead=1&fullsearch=0&scenerelease=0&imdbsearch=%tt%&imdb_from=0&imdb_to=0&search=',
  530. 'matchRegex': /<h3>Ingenting her!<\/h3>/,
  531. 'both': true},
  532. { 'name': 'NBL',
  533. 'searchUrl': 'https://nebulance.io/torrents.php?order_by=time&order_way=desc&searchtext=%search_string%&search_type=0&taglist=&tags_type=0',
  534. 'matchRegex': /Your search did not match anything/,
  535. 'TV': true},
  536. { 'name': 'PHD',
  537. 'searchUrl': 'https://privatehd.to/movies?search=&imdb=%tt%',
  538. 'matchRegex': /class="overlay-container"/,
  539. 'positiveMatch': true},
  540. { 'name': 'PHD',
  541. 'searchUrl': 'https://privatehd.to/tv-shows?search=&imdb=%tt%',
  542. 'matchRegex': /class="overlay-container"/,
  543. 'positiveMatch': true,
  544. 'TV': true},
  545. { 'name': 'PTN',
  546. 'icon': 'https://piratethenet.org/pic/favicon.ico',
  547. 'searchUrl': 'https://piratethenet.org/browseold.php?incldead=1&_by=3&search=%tt%',
  548. 'matchRegex': /Nothing found!/,
  549. 'both': true},
  550. { 'name': 'PTP',
  551. 'searchUrl': 'https://passthepopcorn.me/torrents.php?imdb=%tt%',
  552. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  553. { 'name': 'PTP-Req',
  554. 'searchUrl': 'https://passthepopcorn.me/requests.php?submit=true&search=%tt%',
  555. 'matchRegex': /Your search did not match anything.|<h1>Keep me logged in.<\/h1>/},
  556. { 'name': 'PxHD',
  557. 'searchUrl': 'https://pixelhd.me/torrents.php?groupname=&year=&tmdbover=&tmdbunder=&tmdbid=&imdbover=&imdbunder=&imdbid=%tt%&order_by=time&order_way=desc&taglist=&tags_type=1&filterTorrentsButton=Filter+Torrents',
  558. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  559. { 'name': 'RARAT',
  560. 'searchUrl': 'https://rarat.org/api/v1/torrents?extendedSearch=false&hideOld=false&index=0&limit=15&order=asc&page=search&searchText=%tt%&sort=n#https://rarat.org/search?search=%tt%',
  561. 'goToUrl': 'https://rarat.org/search?search=%tt%',
  562. 'matchRegex': /^$/,
  563. 'both': true},
  564. { 'name': 'RARBG',
  565. 'searchUrl': 'https://rarbg.to/torrents.php?imdb=%tt%',
  566. 'matchRegex': '//dyncdn.me/static/20/images/imdb_thumb.gif',
  567. 'positiveMatch': true,
  568. 'both': true},
  569. { 'name': 'RevTT',
  570. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%tt%',
  571. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  572. { 'name': 'RevTT',
  573. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%search_string%&cat=0&incldead=1&titleonly=1',
  574. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  575. 'TV': true},
  576. { 'name': 'RuT',
  577. 'searchUrl': 'https://rutracker.org/forum/tracker.php?nm=%search_string%',
  578. 'matchRegex': 'Не найдено',
  579. 'both': true},
  580. { 'name': 'Rutor',
  581. 'searchUrl': 'http://rutor.info/search/0/0/010/0/%tt%',
  582. 'matchRegex': 'Результатов поиска 0',
  583. 'both': true},
  584. { 'name': 'SC',
  585. 'searchUrl': 'https://secret-cinema.pw/torrents.php?searchstr=%search_string%',
  586. 'matchRegex': /Your search did not match anything\.|There was a problem executing the query/,
  587. 'both': true},
  588. { 'name': 'SC-F',
  589. 'searchUrl': 'https://secret-cinema.pw/forums.php?action=search&search=%tt%',
  590. 'matchRegex': /Nothing found!|You do not have permission to view these forums\./,
  591. 'both': true},
  592. { 'name': 'SDBits',
  593. 'searchUrl': 'http://sdbits.org/browse.php?c6=1&c3=1&c1=1&c4=1&c5=1&c2=1&m1=1&incldead=0&from=&to=&imdbgt=0&imdblt=10&uppedby=&imdb=&search=%tt%',
  594. 'matchRegex': /Nothing found!|<h1>You need cookies enabled to log in.<\/h1>/},
  595. { 'name': 'sHD',
  596. 'searchUrl': 'https://scenehd.org/browse.php?search=%tt%',
  597. 'matchRegex': /<h2>No torrents found!<\/h2>/},
  598. { 'name': 'SM',
  599. 'searchUrl': 'https://surrealmoviez.info/search.php?stext=%tt%',
  600. 'matchRegex': /0 Movies found matching search criteria|You need to be logged in to view this page/},
  601. { 'name': 'TBD',
  602. 'icon': 'https://1.bp.blogspot.com/-F2JeKtPCJYI/VgjpVxwMO4I/AAAAAAAAADg/VyNyp-yW9Ac/s1600/TBD.ico',
  603. 'searchUrl': 'http://www.torrentbd.com/torrent/torrents-search.php?search=%search_string%',
  604. 'matchRegex': /No torrents were found based on your search criteria./,
  605. 'both': true},
  606. { 'name': 'TD',
  607. 'searchUrl': 'https://www.torrentday.com/browse.php?search=%search_string%&cata=yes&c29=1&c30=1&c25=1&c11=1&c5=1&c3=1&c21=1&c22=1&c13=1&c44=1&c1=1&c24=1&c32=1&c31=1&c33=1&c46=1&c14=1&c26=1&c7=1&c2=1',
  608. 'matchRegex': /Nothing found!/,
  609. 'both': true},
  610. { 'name': 'TE',
  611. 'searchUrl': 'http://theempire.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  612. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/,
  613. 'both': true},
  614. { 'name': 'TehC',
  615. 'searchUrl': 'https://tehconnection.eu/torrents.php?action=basic&searchstr=%tt%',
  616. 'matchRegex': /You will be banned for 6 hours after your login attempts run out.|<h2>No Search Results, try reducing your search options./},
  617. { 'name': 'TG',
  618. 'searchUrl': 'https://thegeeks.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  619. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/,
  620. 'both': true},
  621. { 'name': 'THC',
  622. 'searchUrl': 'https://horrorcharnel.org/browse.php?search=%nott%&cat=0&incldead=1',
  623. 'matchRegex': /<h1>Not logged in!<\/h1>|<h2>Nothing found!<\/h2>/},
  624. { 'name': 'Tik',
  625. 'searchUrl': 'http://cinematik.net/browse.php?srchdtls=1&incldead=1&search=%tt%',
  626. 'matchRegex': /The page you tried to view can only be used when you're logged in|<h2>Nothing found!<\/h2>/},
  627. { 'name': 'TL',
  628. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%+%year%/categories/1,8,9,10,11,12,13,14,15,29',
  629. 'matchRegex': /Signup With Invite|Please refine your search./},
  630. { 'name': 'TL',
  631. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%/categories/2,26,27,32',
  632. 'matchRegex': /Signup With Invite|Please refine your search./,
  633. 'TV': true},
  634. { 'name': 'TPB',
  635. 'searchUrl': 'https://thepiratebay.org/search/%tt%',
  636. 'matchRegex': /No hits. Try adding an asterisk in you search phrase.<\/h2>/,
  637. 'both': true},
  638. { 'name': 'TVV',
  639. 'searchUrl': 'http://tv-vault.me/torrents.php?searchstr=%search_string%',
  640. 'matchRegex': /Nothing found<\/h2>/,
  641. 'TV': true},
  642. { 'name': 'UHDB',
  643. 'searchUrl': 'https://uhdbits.org/torrents.php?action=advanced&groupname=%tt%',
  644. 'matchRegex': /Your search did not match anything./},
  645. { 'name': 'x264',
  646. 'searchUrl': 'http://x264.me/browse.php?incldead=0&xtype=0&stype=3&search=%tt%',
  647. 'matchRegex': /Try again with a refined search string.|<h1>Forgot your password?<\/h1>/}
  648. ];
  649.  
  650. var icon_sites = [
  651. { 'name': 'OpenSubtitles',
  652. 'searchUrl': 'http://www.opensubtitles.org/en/search/imdbid-%tt%'},
  653. { 'name': 'YouTube.com',
  654. 'searchUrl': 'https://www.youtube.com/results?search_query="%search_string%"+%year%+trailer'},
  655. { 'name': 'Rotten Tomatoes',
  656. 'searchUrl': 'https://www.rottentomatoes.com/search/?search=%search_string%'},
  657. { 'name': 'Criticker',
  658. 'searchUrl': 'https://www.criticker.com/?search=%search_string%&type=films'},
  659. { 'name': 'iCheckMovies',
  660. 'searchUrl': 'https://www.icheckmovies.com/search/movies/?query=%tt%'},
  661. { 'name': 'Letterboxd',
  662. 'searchUrl': 'http://letterboxd.com/imdb/%nott%'},
  663. { 'name': 'Subscene',
  664. 'searchUrl': 'http://subscene.com/subtitles/title?q=%search_string%'},
  665. { 'name': 'SubtitleSeeker',
  666. 'searchUrl': 'http://www.subtitleseeker.com/%nott%/Movie/Releases/English/'},
  667. { 'name': 'Wikipedia',
  668. 'searchUrl': 'https://en.wikipedia.org/w/index.php?search=%search_string%&go=Go'},
  669. { 'name': 'FilmAffinity',
  670. 'searchUrl': 'http://www.filmaffinity.com/en/advsearch.php?stext=%search_string%&stype[]=title&fromyear=%year%&toyear=%year%',
  671. 'showByDefault': false},
  672. { 'name': 'Metacritic',
  673. 'searchUrl': 'http://www.metacritic.com/search/all/%search_string%/results?cats[movie]=1&cats[tv]=1&search_type=advanced&sort=relevancy',
  674. 'showByDefault': false},
  675. { 'name': 'Can I Stream.It? (Movie)',
  676. 'searchUrl': 'http://www.canistream.it/search/movie/%search_string%',
  677. 'showByDefault': false},
  678. { 'name': 'Can I Stream.It? (TV)',
  679. 'searchUrl': 'http://www.canistream.it/search/tv/%search_string%',
  680. 'showByDefault': false},
  681. { 'name': 'AllMovie',
  682. 'searchUrl': 'http://www.allmovie.com/search/movies/%search_string%',
  683. 'showByDefault': false},
  684. { 'name': 'Facebook',
  685. 'searchUrl': 'https://www.facebook.com/search/str/%search_string%/keywords_pages',
  686. 'showByDefault': false},
  687. { 'name': 'Amazon',
  688. 'searchUrl': 'http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dmovies-tv&field-keywords=%search_string%',
  689. 'showByDefault': false},
  690. { 'name': 'Netflix',
  691. 'searchUrl': 'http://www.netflix.com/search/%search_string%',
  692. 'showByDefault': false},
  693. { 'name': 'Blu-ray.com',
  694. 'searchUrl': 'http://www.blu-ray.com/search/?quicksearch=1&quicksearch_country=all&quicksearch_keyword=%search_string%+&section=bluraymovies',
  695. 'showByDefault': false},
  696. { 'name': 'trakt.tv',
  697. 'icon': 'https://walter.trakt.tv/hotlink-ok/public/favicon.ico',
  698. 'searchUrl': 'https://trakt.tv/search?query=%search_string%',
  699. 'showByDefault': false}
  700. ];
  701.  
  702. // For internal use (order matters)
  703. var valid_states = [
  704. 'found',
  705. 'missing',
  706. 'logged_out',
  707. 'error'
  708. ]
  709.  
  710. function replaceSearchUrlParams(site, movie_id, movie_title) {
  711. var search_url = site['searchUrl']
  712. // If an array, do a little bit of recursion
  713. if ($.isArray(search_url)) {
  714. var search_array = [];
  715. $.each(search_url, function(index, url) {
  716. search_array[index] = replaceSearchUrlParams(url, movie_id, movie_title);
  717. });
  718. return search_array;
  719. }
  720. var space_replace = ('spaceEncode' in site) ? site['spaceEncode'] : '+'
  721. var search_string = movie_title.replace(/ +\(.*/, '').replace(/\s+/g, space_replace);
  722. var movie_year = document.title.replace(/^(.+) \((.*)([0-9]{4})(.*)$/gi, '$3');
  723. return search_url.replace(/%tt%/g, 'tt' + movie_id)
  724. .replace(/%nott%/g, movie_id)
  725. .replace(/%search_string%/g, search_string)
  726. .replace(/%year%/g, movie_year);
  727. }
  728.  
  729. function getPageSetting(key) {
  730. return (onSearchPage ? GM_config.get(key + '_search') : GM_config.get(key + '_movie'))
  731. }
  732.  
  733. // Small utility function to return a site's icon
  734. function getFavicon(site, hide_on_err) {
  735. if (typeof(hide_on_err) === 'undefined') hide_on_err = false;
  736. if ('icon' in site) {
  737. var favicon = site['icon'];
  738. } else {
  739. var url = new URL(site['searchUrl'])
  740. var favicon = url.origin + '\/favicon.ico';
  741. }
  742. var img = $('<img />').attr({'style': '-moz-opacity: 0.4; border: 0; vertical-align: text-top',
  743. 'width': '16',
  744. 'src': favicon,
  745. 'title': site['name'],
  746. 'alt': site['name']});
  747. if (hide_on_err) img.attr('onerror', "this.style.display='none';");
  748. return img;
  749. }
  750.  
  751. // Adds search links to an element
  752. // state should always be one of the values defined in valid_states
  753. function addLink(elem, link_text, target, site, state) {
  754. var link = $('<a />').attr('href', target).attr('target', '_blank');
  755. if ($.inArray(state, valid_states) < 0) {
  756. console.log("Unknown state " + state);
  757. }
  758. if (getPageSetting('use_icons')) {
  759. var icon = getFavicon(site);
  760. icon.css({'border-width': '3px', 'border-style': 'solid', 'border-radius': '2px'});
  761. if (state == 'error' || state == 'logged_out') {
  762. icon.css('border-color', 'red');
  763. } else if (state == 'missing') {
  764. icon.css('border-color', 'yellow');
  765. } else {
  766. icon.css('border-color', 'green');
  767. }
  768. link.append(icon);
  769. } else {
  770. if (state == 'missing' || state == 'error' || state == 'logged_out') {
  771. link.append($('<s />').append(link_text));
  772. } else {
  773. link.append(link_text);
  774. }
  775. if (state == 'error' || state == 'logged_out') {
  776. link.css('color', 'red');
  777. }
  778. }
  779.  
  780. if (!onSearchPage) {
  781. $('#imdbscout_' + state).append(link).append(' ');
  782. } else {
  783. var result_box = $(elem).find('td.result_box');
  784. if (result_box.length > 0) {
  785. $(result_box).append(link);
  786. } else {
  787. $(elem).append($('<td />').append(link).addClass('result_box'));
  788. }
  789. }
  790. }
  791.  
  792. // Performs an ajax request to determine
  793. // whether or not a url should be displayed
  794. function maybeAddLink(elem, link_text, search_url, site) {
  795. // If the search URL is an array, recurse briefly on the elements.
  796. if ($.isArray(search_url)) {
  797. $.each(search_url, function(index, url) {
  798. maybeAddLink(elem, link_text + '_' + (index + 1).toString(), url, site);
  799. });
  800. return;
  801. }
  802. var target = site['goToUrl'];
  803. var success_match = ('positiveMatch' in site) ? site['positiveMatch'] : false;
  804. GM_xmlhttpRequest({
  805. method: 'GET',
  806. url: search_url,
  807. onload: function(response_details) {
  808. if (String(response_details.responseText).match(site['matchRegex']) ? !(success_match) : success_match) {
  809. if (!getPageSetting('hide_missing')) {
  810. addLink(elem, link_text, target, site, 'missing');
  811. }
  812. } else if (site['loggedOutRegex'] && String(response_details.responseText).match(site['loggedOutRegex'])) {
  813. addLink(elem, link_text, target, site, 'logged_out');
  814. } else {
  815. addLink(elem, link_text, target, site, 'found');
  816. }
  817. },
  818. onerror: function(response) {
  819. addLink(elem, link_text, target, site, 'error');
  820. },
  821. onabort: function(response) {
  822. addLink(elem, link_text, target, site, 'error');
  823. }
  824. });
  825. }
  826.  
  827. // Run code to create fields and display sites
  828. function perform(elem, movie_id, movie_title, is_tv, is_movie) {
  829. var site_shown = false;
  830. $.each(sites, function(index, site) {
  831. if (site['show']) {
  832. site_shown = true;
  833. // If we're on a TV page, only show TV links.
  834. if ((Boolean(site['TV']) == is_tv ||
  835. Boolean(site['both'])) ||
  836. (!is_tv && !is_movie)) {
  837. searchUrl = replaceSearchUrlParams(site, movie_id, movie_title);
  838. // Ugly hack
  839. if ('goToUrl' in site) {
  840. site['goToUrl'] = replaceSearchUrlParams({
  841. 'searchUrl': site['goToUrl'],
  842. 'spaceEncode': ('spaceEncode' in site) ? site['spaceEncode'] : '+'
  843. }, movie_id, movie_title);
  844. } else {
  845. site['goToUrl'] = searchUrl;
  846. }
  847. if (getPageSetting('call_http')) {
  848. maybeAddLink(elem, site['name'], searchUrl, site);
  849. } else {
  850. addLink(elem, site['name'], searchUrl, site, 'found');
  851. }
  852. }
  853. }
  854. });
  855. if (!site_shown) {
  856. $(elem).append('No sites enabled! You can change this via the Greasemonkey option "IMDb Scout Preferences".');
  857. }
  858. }
  859.  
  860. //------------------------------------------------------
  861. // Button Code
  862. //------------------------------------------------------
  863.  
  864. function displayButton() {
  865. var p = $('<p />').attr('id', 'imdbscout_button');
  866. p.append($('<button>Load IMDb Scout</button>').click(function() {
  867. $('#imdbscout_button').remove();
  868. if (onSearchPage) {
  869. performSearch();
  870. } else {
  871. performPage();
  872. }
  873. }));
  874. if (onSearchPage) {
  875. $('#sidebar').append(p);
  876. } else if ($('h1.header:first').length) {
  877. $('h1.header:first').parent().append(p);
  878. } else {
  879. $('#title-overview-widget').parent().append(p);
  880. }
  881. }
  882.  
  883. //------------------------------------------------------
  884. // Icons at top bar
  885. //------------------------------------------------------
  886.  
  887. // Adds a dictionary of icons to the top of the page.
  888. // Unlike the other URLs, they aren't checked to see if the movie exists.
  889. function addIconBar(movie_id, movie_title) {
  890. if ($('h1.header:first').length) {
  891. var iconbar = $('h1.header:first').append($('<br/>'));
  892. } else if ($('.title_wrapper h1')) {
  893. var iconbar = $('.title_wrapper h1').append($('<br/>'));
  894. } else {
  895. var iconbar = $('#tn15title .title-extra');
  896. }
  897. $.each(icon_sites, function(index, site) {
  898. if (site['show']) {
  899. var search_url = replaceSearchUrlParams(site, movie_id, movie_title);
  900. var image = getFavicon(site);
  901. var html = $('<span />').append($('<a />').attr('href', search_url)
  902. .addClass('iconbar_icon').append(image));
  903. iconbar.append(html).append(' ');
  904. }
  905. });
  906. //If we have access to the openInTab function, add an Open All feature
  907. if (GM_openInTab) {
  908. var aopenall = $('<a />').text('Open All')
  909. .attr('href', 'javascript:;')
  910. .attr('style', 'font-weight:bold;font-size:10px;font-family: Calibri, Verdana, Arial, Helvetica, sans-serif;');
  911. aopenall.click(function() {
  912. $('.iconbar_icon').each(function() {
  913. GM_openInTab($(this).attr('href'));
  914. });
  915. }, false);
  916. iconbar.append(aopenall);
  917. }
  918. }
  919.  
  920. //------------------------------------------------------
  921. // Search page code
  922. //------------------------------------------------------
  923.  
  924. function performSearch() {
  925. //Add css for the new table cells we're going to add
  926. var styles = '.result_box {width: 335px}';
  927. styles += ' .result_box a { margin-right: 5px; color: #444;} ';
  928. styles += ' .result_box a:visited { color: #551A8B; }';
  929. styles += ' #content-2-wide #main, #content-2-wide';
  930. styles += ' .maindetails_center {margin-left: 5px; width: 1001px;} ';
  931. GM_addStyle(styles);
  932.  
  933. //Loop through each result row
  934. $('div#main table.results tr.detailed').each(function() {
  935. var link = $(this).find('.title>a');
  936. var is_tv = Boolean($(this).find('.year_type').html()
  937. .match('TV Series'));
  938. var is_movie = Boolean($(this).find('.year_type').html()
  939. .match(/\(([0-9]*)\)/));
  940. var movie_title = link.html();
  941. var movie_id = link.attr('href').match(/tt([0-9]*)\/?$/)[1];
  942.  
  943. $(this).find('span.genre a').each(function() {
  944. if ($(this).html() == 'Adult') {
  945. $(this).parent().parent().parent()
  946. .css('background-color', 'red');
  947. }
  948. });
  949. perform($(this), movie_id, movie_title, is_tv, is_movie);
  950. });
  951. }
  952.  
  953. //------------------------------------------------------
  954. // TV/movie page code
  955. //------------------------------------------------------
  956.  
  957. function performPage() {
  958. var movie_title = $('title').text().match(/^(.*?) \(/)[1];
  959. var movie_id = document.URL.match(/\/tt([0-9]+)\//)[1].trim('tt');
  960. var is_tv_page = Boolean($('title').text().match('TV Series')) ||
  961. Boolean($('.tv-extra').length);
  962. var is_movie_page = Boolean($('title').text().match(/.*? \(([0-9]*)\)/));
  963. //Create area to put links in
  964. perform(getLinkArea(), movie_id, movie_title,
  965. is_tv_page, is_movie_page);
  966. addIconBar(movie_id, movie_title);
  967. }
  968.  
  969. //------------------------------------------------------
  970. // Find/create elements
  971. //------------------------------------------------------
  972.  
  973. function getLinkArea() {
  974. // If it already exists, just return it
  975. if ($('#imdbscout_header').length) {
  976. return $('#imdbscout_header');
  977. }
  978. var p = $('<p />').append('<h2>' + GM_config.get('imdbscout_header_text') + '</h2>').attr('id', 'imdbscout_header').css({
  979. 'padding': '0px 20px',
  980. 'font-weight': 'bold'
  981. });
  982. $.each(valid_states, function(i, name) {
  983. if (GM_config.get('one_line')) {
  984. p.append($('<span />').attr('id', 'imdbscout_' + name));
  985. } else {
  986. var title = $('<span>' + name.replace('_', ' ') + ': </span>').css({
  987. 'textTransform': 'capitalize',
  988. 'min-width': '100px',
  989. 'display': 'inline-block'
  990. });
  991. p.append($('<div />').attr('id', 'imdbscout_' + name).append(title));
  992. }
  993. });
  994. if ($('h1.header:first').length) {
  995. $('h1.header:first').parent().append(p);
  996. } else if ($('#title-overview-widget').length) {
  997. $('#title-overview-widget').parent().append(p);
  998. } else {
  999. $('#tn15rating').before(p);
  1000. }
  1001. return $('#imdbscout_header');
  1002. }
  1003.  
  1004. //------------------------------------------------------
  1005. // Code being run (main)
  1006. //------------------------------------------------------
  1007.  
  1008. // Get everything configured
  1009.  
  1010. // Create the non-site dictionary for GM_config
  1011. var config_fields = {
  1012. 'imdbscout_header_text': {
  1013. 'label': 'Header text:',
  1014. 'type': 'text',
  1015. 'default': 'Pirate this film: '
  1016. },
  1017. 'call_http_movie': {
  1018. 'section': 'Movie Page:',
  1019. 'type': 'checkbox',
  1020. 'label': 'Actually check for torrents?',
  1021. 'default': true
  1022. },
  1023. 'load_on_start_movie': {
  1024. 'type': 'checkbox',
  1025. 'label': 'Load on start?',
  1026. 'default': true
  1027. },
  1028. 'hide_missing_movie': {
  1029. 'type': 'checkbox',
  1030. 'label': 'Hide missing links?',
  1031. 'default': false
  1032. },
  1033. 'use_icons_movie': {
  1034. 'type': 'checkbox',
  1035. 'label': 'Use icons instead of text?',
  1036. 'default': false
  1037. },
  1038. 'one_line': {
  1039. 'type': 'checkbox',
  1040. 'label': 'Show results on one line?',
  1041. 'default': true
  1042. },
  1043. 'call_http_search': {
  1044. 'section': 'Search Page:',
  1045. 'type': 'checkbox',
  1046. 'label': 'Actually check for torrents?',
  1047. 'default': true
  1048. },
  1049. 'load_on_start_search': {
  1050. 'type': 'checkbox',
  1051. 'label': 'Load on start?',
  1052. 'default': true
  1053. },
  1054. 'hide_missing_search': {
  1055. 'type': 'checkbox',
  1056. 'label': 'Hide missing links?',
  1057. 'default': false
  1058. },
  1059. 'use_icons_search': {
  1060. 'type': 'checkbox',
  1061. 'label': 'Use icons instead of text?',
  1062. 'default': false
  1063. }
  1064. };
  1065.  
  1066. // Add each site to a GM_config dictionary schema
  1067. // The GM_config default for checkboxes is false
  1068. $.each(sites, function(index, site) {
  1069. config_fields['show_' + site['name'] + (site['TV'] ? '_TV' : '')] = {
  1070. 'section': (index == 0) ? ['Torrents:'] : '',
  1071. 'type': 'checkbox',
  1072. 'label': ' ' + site['name'] + (site['TV'] ? ' (TV)' : '')
  1073. };
  1074. });
  1075.  
  1076. // Icon sites should be shown by default though,
  1077. // since they barely use any resources.
  1078. $.each(icon_sites, function(index, icon_site) {
  1079. config_fields['show_icon_' + icon_site['name']] = {
  1080. 'section': (index == 0) ? ['Other sites:'] : '',
  1081. 'type': 'checkbox',
  1082. 'label': ' ' + icon_site['name'],
  1083. 'default': ('showByDefault' in icon_site) ?
  1084. icon_site['showByDefault'] : true
  1085. };
  1086. });
  1087.  
  1088. // Initialize and register GM_config
  1089. GM_config.init({
  1090. 'id': 'imdb_scout',
  1091. 'title': 'IMDb Scout Preferences',
  1092. 'fields': config_fields,
  1093. 'css': '.section_header { \
  1094. background: white !important; \
  1095. color: black !important; \
  1096. border: 0px !important; \
  1097. text-align: left !important;} \
  1098. .field_label { \
  1099. font-weight: normal !important;}',
  1100. 'events':
  1101. {
  1102. 'open': function() {
  1103. $('#imdb_scout').contents().find('#imdb_scout_section_2').find('.field_label').each(function(index, label) {
  1104. url = new URL(sites[index].searchUrl);
  1105. $(label).append(' ' + '<a class="grey_link" target="_blank" style="color: gray; text-decoration : none" href="' + url.origin + '">'
  1106. + (/www./.test(url.hostname) ? url.hostname.match(/www.(.*)/)[1] : url.hostname) + '</a>');
  1107. $(label).prepend(getFavicon(sites[index], true));
  1108. });
  1109. $('#imdb_scout').contents().find('#imdb_scout_section_3').find('.field_label').each(function(index, label) {
  1110. $(label).prepend(getFavicon(icon_sites[index], true));
  1111. });
  1112. }
  1113. }
  1114. });
  1115. GM_registerMenuCommand('IMDb Scout Preferences', function() {GM_config.open()});
  1116.  
  1117. // Fetch per-site values from GM_config
  1118. $.each(sites, function(index, site) {
  1119. site['show'] = GM_config.get('show_' + site['name'] +
  1120. (site['TV'] ? '_TV' : ''));
  1121. });
  1122.  
  1123. $.each(icon_sites, function(index, icon_site) {
  1124. icon_site['show'] = GM_config.get('show_icon_' + icon_site['name']);
  1125. });
  1126.  
  1127. // Are we on a search page?
  1128. // This variable is camelCased to show it's global
  1129. // Hopefully it can be factored out of the global scope in the future
  1130. var onSearchPage = Boolean(location.href.match('search'));
  1131.  
  1132. $('title').ready(function() {
  1133. if (!onSearchPage && GM_config.get('load_on_start_movie')) {
  1134. performPage();
  1135. } else if (onSearchPage && GM_config.get('load_on_start_search')) {
  1136. performSearch();
  1137. } else {
  1138. displayButton();
  1139. }
  1140. });