IMDb Scout

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

目前为 2017-01-27 提交的版本。查看 最新版本

  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.3.11
  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.  
  266.  
  267. if (window.top != window.self) // Don't run on frames or iframes
  268. {
  269. return;
  270. }
  271.  
  272. //------------------------------------------------------
  273. // A list of all the sites, and the data necessary to
  274. // check IMDb against them.
  275. // Each site is a dictionary with the following attributes:
  276. // - name:
  277. // The site name, abbreviated
  278. // - searchUrl:
  279. // The URL to perform the search against, see below for how
  280. // to tailor the string to a site
  281. // - matchRegex:
  282. // The string which appears if the searchUrl *doesn't* return a result
  283. // - postiveMatch:
  284. // Changes the test to return true if the searchUrl *does* return
  285. // a result that matches matchRegex
  286. // - TV (optional):
  287. // If true, it means that this site will only show up on TV pages.
  288. // By default, sites only show up on movie pages.
  289. // - both (optional):
  290. // Means that the site will show up on both movie and TV pages
  291. // - spaceEncode (optional):
  292. // Changes the character used to encode spaces in movie titles
  293. // The default is '+'.
  294. // - goToUrl (optional):
  295. // Most of the time the same URLs that are used for checking are
  296. // the ones that are used to actually get to the movie,
  297. // but this allows overriding that.
  298. // - loggedOutRegex (optional):
  299. // If any text on the page matches this regex, the site is treated
  300. // as being logged out, rather than mising the movie. This option is
  301. // not effected by postiveMatch.
  302. // To create a search URL, there are four parameters
  303. // you can use inside the URL:
  304. // - %tt%:
  305. // The IMDb id with the tt prefix (e.g. tt0055630)
  306. // - %nott%:
  307. // The IMDb id without the tt prefix (e.g. 0055630)
  308. // - %search_string%:
  309. // The movie title (e.g. Yojimbo)
  310. // - %year%:
  311. // The movie year (e.g. 1961)
  312. // See below for examples
  313. //------------------------------------------------------
  314.  
  315. var sites = [
  316. { 'name': 'ADC',
  317. 'searchUrl': 'https://asiandvdclub.org/browse.php?descr=1&btnSubmit=Submit&search=%tt%',
  318. 'matchRegex': /Your search returned zero results|<h1>You need cookies enabled to log in.<\/h1>/,
  319. 'both': true},
  320. { 'name': 'AHD',
  321. 'searchUrl': 'https://awesome-hd.me/torrents.php?id=%tt%',
  322. 'matchRegex': /Your search did not match anything.|<h2>Error 404<\/h2>/,
  323. 'both': true},
  324. { 'name': 'AR',
  325. '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',
  326. 'matchRegex': /Your search did not match anything/},
  327. { 'name': 'AR',
  328. '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',
  329. 'matchRegex': /Your search did not match anything/,
  330. 'TV': true},
  331. { 'name': 'AT',
  332. 'searchUrl': 'https://avistaz.to/movies?search=&imdb=%tt%',
  333. 'matchRegex': /class="overlay-container"/,
  334. 'positiveMatch': true},
  335. { 'name': 'AT',
  336. 'searchUrl': 'https://avistaz.to/tv-shows?search=&imdb=%tt%',
  337. 'matchRegex': /class="overlay-container"/,
  338. 'positiveMatch': true,
  339. 'TV': true},
  340. { 'name': 'bB',
  341. 'searchUrl': 'https://baconbits.org/torrents.php?action=basic&filter_cat[9]=1&searchstr=%search_string%+%year%',
  342. 'matchRegex': /Your search was way too l33t|You will be banned for 6 hours after your login attempts run out/},
  343. { 'name': 'bB',
  344. 'searchUrl': 'https://baconbits.org/torrents.php?action=basic&filter_cat[8]=1&filter_cat[10]=1&searchstr=%search_string%',
  345. 'matchRegex': /Your search was way too l33t|You will be banned for 6 hours after your login attempts run out/,
  346. 'TV': true},
  347. { 'name': 'BB-HD',
  348. 'searchUrl': 'https://bluebird-hd.org/browse.php?search=&incldead=0&cat=0&dsearch=%tt%&stype=or',
  349. 'matchRegex': /Nothing found|Ничего не найдено/,
  350. 'both': true},
  351. { 'name': 'BHD',
  352. 'searchUrl': 'https://beyondhd.me/browse.php?search=%tt%&searchin=title&incldead=1',
  353. 'matchRegex': /Nothing found!|Please login or Register a personal account to access our user area and great community/},
  354. { 'name': 'BHD',
  355. 'searchUrl': 'https://beyondhd.me/browse.php?c40=1&c44=1&c48=1&c89=1&c46=1&c45=1&search=%search_string%&searchin=title&incldead=0',
  356. 'matchRegex': /Nothing found!|Please login or Register a personal account to access our user area and great community/,
  357. 'TV': true},
  358. { 'name': 'BitHD',
  359. 'searchUrl': 'http://www.bit-hdtv.com/torrents.php?cat=0&search=%tt%',
  360. 'matchRegex': /<h2>No match!<\/h2>/},
  361. { 'name': 'BitHQ',
  362. 'searchUrl': 'http://www.bithq.org/search.php?search=%search_string%&options=AND&in=original&incldead=1',
  363. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  364. { 'name': 'BMTV',
  365. 'searchUrl': 'https://www.bitmetv.org/browse.php?search=%search_string%',
  366. 'matchRegex': /Nothing found!<\/h2>/,
  367. 'TV': true},
  368. { 'name': 'BTN',
  369. 'searchUrl': 'https://broadcasthe.net/torrents.php?imdb=%tt%',
  370. 'matchRegex': /Error 404|Lost your password\?/,
  371. 'TV': true},
  372. { 'name': 'BTN-Req',
  373. 'searchUrl': 'https://broadcasthe.net/requests.php?search=%search_string%',
  374. 'matchRegex': /Nothing found|Lost your password\?/,
  375. 'TV': true},
  376. { 'name': 'CaCh',
  377. 'searchUrl': 'http://www.cartoonchaos.org/index.php?page=torrents&search=%search_string%&category=0&options=0&active=0',
  378. 'matchRegex': />Av.<\/td>\s*<\/tr>\s*<\/table>|not authorized to view the Torrents/,
  379. 'both': true},
  380. { 'name': 'CC',
  381. '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%',
  382. '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/},
  383. { 'name': 'CG',
  384. 'searchUrl': 'https://cinemageddon.net/browse.php?search=%tt%',
  385. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  386. 'loggedOutRegex': 'Not logged in!'},
  387. { 'name': 'CG-c',
  388. 'searchUrl': 'https://cinemageddon.net/cocks/endoscope.php?what=imdb&q=%tt%',
  389. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  390. 'loggedOutRegex': 'Not logged in!'},
  391. { 'name': 'CHD',
  392. 'searchUrl': 'https://chdbits.co/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=4&search_mode=0&search=%tt%'
  393. 'matchRegex': /Nothing found/},
  394. { 'name': 'Classix',
  395. 'searchUrl': 'http://classix-unlimited.co.uk/torrents-search.php?search=%search_string%',
  396. 'matchRegex': /Nothing Found<\/div>/},
  397. { 'name': 'CN',
  398. 'searchUrl': 'https://cosanostra.me/browse.php?filename=&title=&search3=&search4=&search5=&search6=&search7=&search8=&search9=&search10=&search11=&imdbid=%tt%&sort=4&type=desc&svs_selection=&svs_name=#filter-panel',
  399. 'matchRegex': /<h2>Nothing here!<\/h2>/},
  400. { 'name': 'D-noid',
  401. 'searchUrl': 'http://www.dnoid.me/files/?query=%tt%',
  402. 'matchRegex': /<b>No torrents found<\/b>|We are currently performing the daily site maintenance.<br>/,
  403. 'both': true},
  404. { 'name': 'DVDSeed',
  405. 'searchUrl': 'http://www.dvdseed.eu/browse2.php?search=%tt%&wheresearch=2&incldead=1&polish=0&nuke=0&rodzaj=0',
  406. 'matchRegex': /Nic tutaj nie ma!<\/h2>/},
  407. { 'name': 'ET',
  408. 'searchUrl': 'https://cinemaz.to/movies?search=&imdb=%tt%',
  409. 'matchRegex': /class="overlay-container"/,
  410. 'positiveMatch': true},
  411. { 'name': 'ET',
  412. 'searchUrl': 'https://cinemaz.to/tv-shows?search=&imdb=%tt%',
  413. 'matchRegex': /class="overlay-container"/,
  414. 'positiveMatch': true,
  415. 'TV': true},
  416. { 'name': 'eThor',
  417. '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%',
  418. 'matchRegex': /Try again with a refined search string.|<h1>Note: Vous devez activer vos 'cookies' pour pouvoir vous identifier.<\/h1>/},
  419. { 'name': 'ExtraTorrent',
  420. 'searchUrl': 'https://extratorrent.cc/search/?search=%search_string%+%year%',
  421. 'matchRegex': /total <b>0<\/b> torrents found/},
  422. { 'name': 'FL',
  423. 'searchUrl': 'https://filelist.ro/browse.php?search=%tt%',
  424. 'matchRegex': /Broblem \?|Nu s-a gasit nimic!/,
  425. 'both': true},
  426. { 'name': 'Fresh',
  427. 'searchUrl': 'http://freshon.tv/browse.php?search=%search_string%',
  428. 'matchRegex': /<strong>Nothing found/,
  429. 'TV': true},
  430. { 'name': 'FSS',
  431. 'searchUrl': 'http://fss.omnilounge.co.uk/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  432. 'matchRegex': /Try again with a different search string?|<h1>You need cookies enabled to log in.<\/h1>/},
  433. { 'name': 'GFT',
  434. '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',
  435. 'matchRegex': /Nothing found!<\/h2>/},
  436. { 'name': 'GFT',
  437. 'searchUrl': 'https://www.thegft.org/browse.php?view=0&search=%search_string%',
  438. 'matchRegex': /Nothing found!<\/h2>/,
  439. 'TV': true},
  440. { 'name': 'GFT-Gems',
  441. 'searchUrl': 'https://www.thegft.org/browse.php?view=1&search=%tt%&searchtype=0',
  442. 'matchRegex': /Nothing found!<\/h2>/},
  443. { 'name': 'HD',
  444. 'searchUrl': 'http://hounddawgs.org/torrents.php?type=&userid=&searchstr=&searchimdb=%tt%&searchlang=&searchtags=&order_by=s3&order_way=desc&showOnly=#results',
  445. 'matchRegex': /<h2>Din søgning gav intet resultat.<\/h2>/,
  446. 'both': true},
  447. { 'name': 'HDb',
  448. 'searchUrl': 'https://hdbits.org/browse.php?c3=1&c1=1&c4=1&c2=1&imdb=%tt%',
  449. 'matchRegex': /Nothing here!|You need cookies enabled to log in/,
  450. 'both': true},
  451. { 'name': 'HDC',
  452. 'searchUrl': 'https://hdchina.club/torrents.php?incldead=0&spstate=0&inclbookmarked=0&boardid=0&seeders=&search=%tt%&search_area=4&search_mode=2',
  453. 'matchRegex': /Nothing found! Try again with a refined search string./},
  454. { 'name': 'HDClub',
  455. 'searchUrl': 'http://hdclub.org/browse.php?webdl=0&3d=0&search=&incldead=0&dsearch=%tt%',
  456. 'matchRegex': /Nothing was found|Ничего не найдено|Нічого не знайдено/,
  457. 'both': true},
  458. { 'name': 'HDME',
  459. 'searchUrl': 'https://hdme.eu/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  460. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/},
  461. { 'name': 'HDME',
  462. 'searchUrl': 'https://hdme.eu/browse.php?search=%search_string%&blah=0&cat=0&incldead=1',
  463. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/,
  464. 'TV': true},
  465. { 'name': 'HDS',
  466. 'searchUrl': 'https://hdsky.me/torrents.php?incldead=1&search=%tt%&search_area=4&search_mode=0',
  467. 'matchRegex': /Nothing found! Try again with a refined search string|Email:hdsky.me@gmail.com/},
  468. { 'name': 'HDS',
  469. 'searchUrl': 'https://hdsky.me/torrents.php?cat402=1&cat403=1&incldead=1&search=%search_string%&search_area=0&search_mode=0',
  470. 'matchRegex': /Nothing found! Try again with a refined search string|Email:hdsky.me@gmail.com/,
  471. 'TV': true},
  472. { 'name': 'HDT',
  473. 'searchUrl': 'http://hd-torrents.org/torrents.php?active=0&options=2&search=%tt%',
  474. 'matchRegex': /No torrents here.../,
  475. 'both': true},
  476. { 'name': 'HDVN',
  477. 'searchUrl': 'http://torviet.com/torrents.php?search=%tt%&search_area=4&search_mode=0',
  478. 'matchRegex': /Nothing found! Try again with a refined search string|You need cookies enabled to log in or switch language/,
  479. 'both': true},
  480. { 'name': 'ILC',
  481. 'searchUrl': 'http://www.iloveclassics.com/browse.php?incldead=1&searchin=2&search=%tt%',
  482. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  483. { 'name': 'IPT',
  484. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%tt%',
  485. 'matchRegex': /<h1 style="color:yellow">No Torrents Found!/},
  486. { 'name': 'IPT',
  487. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%search_string%',
  488. 'matchRegex': /<h1 style="color:yellow">No Torrents Found!/,
  489. 'TV': true},
  490. { 'name': 'KG',
  491. 'searchUrl': 'https://www.karagarga.in/browse.php?search_type=imdb&search=%nott%',
  492. 'matchRegex': /<h2>No torrents found|<h1>If you want the love<\/h1>/},
  493. { 'name': 'KZ',
  494. 'searchUrl': 'http://kinozal.tv/browse.php?s=%search_string%+%year%&g=0&c=1002&v=0&d=0&w=0&t=0&f=0',
  495. 'matchRegex': 'Нет активных раздач, приносим извинения. Пожалуйста, уточните параметры поиска'},
  496. { 'name': 'KZ',
  497. 'searchUrl': 'http://kinozal.tv/browse.php?s=%search_string%+%year%&g=0&c=1001&v=0&d=0&w=0&t=0&f=0',
  498. 'matchRegex': 'Нет активных раздач, приносим извинения. Пожалуйста, уточните параметры поиска',
  499. 'TV': true},
  500. { 'name': 'M-T',
  501. 'searchUrl': 'https://tp.m-team.cc/movie.php?incldead=1&spstate=0&inclbookmarked=0&search=%tt%&search_area=4&search_mode=2',
  502. 'matchRegex': /Nothing here!|Try again with a refined search string./},
  503. { 'name': 'MS',
  504. 'searchUrl': 'http://www.myspleen.org/browse.php?search=%search_string%&title=0&cat=0',
  505. 'matchRegex': /<strong>Nothing found!<\/strong>|<title>MySpleen :: Login<\/title>/,
  506. 'both': true},
  507. { 'name': 'MTV',
  508. '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',
  509. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  510. { 'name': 'MTV',
  511. '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',
  512. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/,
  513. 'TV': true},
  514. { 'name': 'NNM',
  515. 'searchUrl': 'https://nnm-club.me/forum/tracker.php?nm=%search_string%+%year%',
  516. 'matchRegex': 'Не найдено',
  517. 'both': true},
  518. { 'name': 'NB',
  519. 'searchUrl': 'https://norbits.net/browse.php?incldead=1&fullsearch=0&scenerelease=0&imdbsearch=%tt%&imdb_from=0&imdb_to=0&search=',
  520. 'matchRegex': /<h3>Ingenting her!<\/h3>/,
  521. 'both': true},
  522. { 'name': 'PHD',
  523. 'searchUrl': 'https://privatehd.to/movies?search=&imdb=%tt%',
  524. 'matchRegex': /class="overlay-container"/,
  525. 'positiveMatch': true},
  526. { 'name': 'PHD',
  527. 'searchUrl': 'https://privatehd.to/tv-shows?search=&imdb=%tt%',
  528. 'matchRegex': /class="overlay-container"/,
  529. 'positiveMatch': true,
  530. 'TV': true},
  531. { 'name': 'PTP',
  532. 'searchUrl': 'https://passthepopcorn.me/torrents.php?imdb=%tt%',
  533. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  534. { 'name': 'PTP-Req',
  535. 'searchUrl': 'https://passthepopcorn.me/requests.php?submit=true&search=%tt%',
  536. 'matchRegex': /Your search did not match anything.|<h1>Keep me logged in.<\/h1>/},
  537. { 'name': 'PxHD',
  538. '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',
  539. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  540. { 'name': 'RARAT',
  541. '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%',
  542. 'goToUrl': 'https://rarat.org/search?search=%tt%',
  543. 'matchRegex': /^$/,
  544. 'both': true},
  545. { 'name': 'RARBG',
  546. 'searchUrl': 'https://rarbg.to/torrents.php?imdb=%tt%',
  547. 'matchRegex': '//dyncdn.me/static/20/images/imdb_thumb.gif',
  548. 'positiveMatch': true,
  549. 'both': true},
  550. { 'name': 'RevTT',
  551. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%tt%',
  552. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  553. { 'name': 'RevTT',
  554. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%search_string%&cat=0&incldead=1&titleonly=1',
  555. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  556. 'TV': true},
  557. { 'name': 'RuT',
  558. 'searchUrl': 'http://rutracker.org/forum/tracker.php?nm=%search_string%+%year%',
  559. 'matchRegex': 'Не найдено',
  560. 'both': true},
  561. { 'name': 'Rutor',
  562. 'searchUrl': 'http://rutor.info/search/0/0/010/0/%tt%',
  563. 'matchRegex': 'Результатов поиска 0',
  564. 'both': true},
  565. { 'name': 'SC',
  566. 'searchUrl': 'http://www.secret-cinema.net/browse.php?search=%search_string%',
  567. 'matchRegex': /Try again with a refined search string\.|There was a problem executing the query/,
  568. 'both': true},
  569. { 'name': 'SC-F',
  570. 'searchUrl': 'http://www.secret-cinema.net/search.php?action=search&show_as=topics&keywords=%tt%',
  571. 'matchRegex': /Your search returned no hits\.|You do not have permission to view these forums\./,
  572. 'both': true},
  573. { 'name': 'SCC',
  574. 'searchUrl': 'https://sceneaccess.eu/all?method=3&search=%tt%',
  575. 'matchRegex': /Try again with a refined search string./,
  576. 'loggedOutRegex': /<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  577. { 'name': 'SCC',
  578. 'searchUrl': 'https://sceneaccess.eu/all?method=2&c27=27&c17=17&c11=11&c26=26&c44=44&c45=44&search=%search_string%',
  579. 'matchRegex': /Try again with a refined search string./,
  580. 'loggedOutRegex': /<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/,
  581. 'TV': true},
  582. { 'name': 'SDBits',
  583. '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%',
  584. 'matchRegex': /Nothing found!|<h1>You need cookies enabled to log in.<\/h1>/},
  585. { 'name': 'sHD',
  586. 'searchUrl': 'https://scenehd.org/browse.php?search=%tt%',
  587. 'matchRegex': /<h2>No torrents found!<\/h2>/},
  588. { 'name': 'SM',
  589. 'searchUrl': 'https://surrealmoviez.info/search.php?stext=%tt%',
  590. 'matchRegex': /0 Movies found matching search criteria|You need to be logged in to view this page/},
  591. { 'name': 't411',
  592. 'searchUrl': 'http://www.t411.ch/torrents/search/?name=%search_string%&description=&file=&user=&cat=210&subcat=&search=%40name+%search_string%+&submit=Recherche',
  593. 'matchRegex': /sultat Aucun/,
  594. 'both': true},
  595. { 'name': 'TD',
  596. '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',
  597. 'matchRegex': /Nothing found!/,
  598. 'both': true},
  599. { 'name': 'TE',
  600. 'searchUrl': 'http://theempire.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  601. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/,
  602. 'both': true},
  603. { 'name': 'TehC',
  604. 'searchUrl': 'https://tehconnection.eu/torrents.php?action=basic&searchstr=%tt%',
  605. 'matchRegex': /You will be banned for 6 hours after your login attempts run out.|<h2>No Search Results, try reducing your search options./},
  606. { 'name': 'TG',
  607. 'searchUrl': 'https://thegeeks.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  608. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/,
  609. 'both': true},
  610. { 'name': 'THC',
  611. 'searchUrl': 'https://horrorcharnel.org/browse.php?search=%nott%&cat=0&incldead=1',
  612. 'matchRegex': /<h1>Not logged in!<\/h1>|<h2>Nothing found!<\/h2>/},
  613. { 'name': 'Tik',
  614. 'searchUrl': 'http://cinematik.net/browse.php?srchdtls=1&incldead=1&search=%tt%',
  615. 'matchRegex': /The page you tried to view can only be used when you're logged in|<h2>Nothing found!<\/h2>/},
  616. { 'name': 'TL',
  617. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%+%year%/categories/1,8,9,10,11,12,13,14,15,29',
  618. 'matchRegex': /Signup With Invite|Please refine your search./},
  619. { 'name': 'TL',
  620. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%/categories/2,26,27,32',
  621. 'matchRegex': /Signup With Invite|Please refine your search./,
  622. 'TV': true},
  623. { 'name': 'TPB',
  624. 'searchUrl': 'https://thepiratebay.se/search/%tt%',
  625. 'matchRegex': /No hits. Try adding an asterisk in you search phrase.<\/h2>/,
  626. 'both': true},
  627. { 'name': 'TSH',
  628. 'searchUrl': 'https://torrentshack.me/torrents.php?searchstr=%search_string%&action=advanced&torrentname=&description=&filelist=&extrainfo=&hasnfo=&nuked=&nukedtext=&release_type=both&searchtags=&tags_type=0&order_by=s3&order_way=desc&torrent_preset=all&filter_cat%5B960%5D=1&filter_cat%5B300%5D=1&filter_cat%5B320%5D=1&filter_cat%5B400%5D=1&filter_cat%5B970%5D=1&filter_cat%5B350%5D=1&filter_cat%5B982%5D=1&filter_cat%5B983%5D=1',
  629. 'matchRegex': /Your search did not match anything./},
  630. { 'name': 'TtN',
  631. 'searchUrl': 'https://transmithe.net/torrents.php?order_by=time&order_way=desc&searchtext=%search_string%&search_type=0&taglist=&tags_type=0',
  632. 'matchRegex': /Your search did not match anything/,
  633. 'TV': true},
  634. { 'name': 'TVV',
  635. 'searchUrl': 'http://tv-vault.me/torrents.php?searchstr=%search_string%',
  636. 'matchRegex': /Nothing found<\/h2>/,
  637. 'TV': true},
  638. { 'name': 'UHDB',
  639. 'searchUrl': 'https://uhdbits.org/torrents.php?action=advanced&groupname=%tt%',
  640. 'matchRegex': /Your search did not match anything./},
  641. { 'name': 'x264',
  642. 'searchUrl': 'http://x264.me/browse.php?incldead=0&xtype=0&stype=3&search=%tt%',
  643. 'matchRegex': /Try again with a refined search string.|<h1>Forgot your password?<\/h1>/}
  644. ];
  645.  
  646. var icon_sites = [
  647. { 'name': 'OpenSubtitles',
  648. 'searchUrl': 'http://www.opensubtitles.org/en/search/imdbid-%tt%'},
  649. { 'name': 'YouTube.com',
  650. 'searchUrl': 'https://www.youtube.com/results?search_query="%search_string%"+%year%+trailer'},
  651. { 'name': 'Rotten Tomatoes',
  652. 'searchUrl': 'https://www.rottentomatoes.com/search/?search=%search_string%'},
  653. { 'name': 'Criticker',
  654. 'searchUrl': 'https://www.criticker.com/?search=%search_string%&type=films'},
  655. { 'name': 'iCheckMovies',
  656. 'searchUrl': 'https://www.icheckmovies.com/search/movies/?query=%tt%'},
  657. { 'name': 'Letterboxd',
  658. 'searchUrl': 'http://letterboxd.com/imdb/%nott%'},
  659. { 'name': 'Subscene',
  660. 'searchUrl': 'http://subscene.com/subtitles/title?q=%search_string%'},
  661. { 'name': 'SubtitleSeeker',
  662. 'searchUrl': 'http://www.subtitleseeker.com/%nott%/Movie/Releases/English/'},
  663. { 'name': 'Wikipedia',
  664. 'searchUrl': 'https://en.wikipedia.org/w/index.php?search=%search_string%&go=Go'},
  665. { 'name': 'FilmAffinity',
  666. 'searchUrl': 'http://www.filmaffinity.com/en/advsearch.php?stext=%search_string%&stype[]=title&fromyear=%year%&toyear=%year%',
  667. 'showByDefault': false},
  668. { 'name': 'Metacritic',
  669. 'searchUrl': 'http://www.metacritic.com/search/all/%search_string%/results?cats[movie]=1&cats[tv]=1&search_type=advanced&sort=relevancy',
  670. 'showByDefault': false},
  671. { 'name': 'Can I Stream.It? (Movie)',
  672. 'searchUrl': 'http://www.canistream.it/search/movie/%search_string%',
  673. 'showByDefault': false},
  674. { 'name': 'Can I Stream.It? (TV)',
  675. 'searchUrl': 'http://www.canistream.it/search/tv/%search_string%',
  676. 'showByDefault': false},
  677. { 'name': 'AllMovie',
  678. 'searchUrl': 'http://www.allmovie.com/search/movies/%search_string%',
  679. 'showByDefault': false},
  680. { 'name': 'Facebook',
  681. 'searchUrl': 'https://www.facebook.com/search/str/%search_string%/keywords_pages',
  682. 'showByDefault': false},
  683. { 'name': 'Amazon',
  684. 'searchUrl': 'http://www.amazon.com/s/ref=nb_sb_noss?url=search-alias%3Dmovies-tv&field-keywords=%search_string%',
  685. 'showByDefault': false},
  686. { 'name': 'Netflix',
  687. 'searchUrl': 'http://www.netflix.com/search/%search_string%',
  688. 'showByDefault': false},
  689. { 'name': 'Blu-ray.com',
  690. 'searchUrl': 'http://www.blu-ray.com/search/?quicksearch=1&quicksearch_country=all&quicksearch_keyword=%search_string%+&section=bluraymovies',
  691. 'showByDefault': false}
  692. ];
  693.  
  694. // For internal use (order matters)
  695. var valid_states = [
  696. 'found',
  697. 'missing',
  698. 'logged_out',
  699. 'error'
  700. ]
  701.  
  702. function replaceSearchUrlParams(site, movie_id, movie_title) {
  703. var search_url = site['searchUrl']
  704. // If an array, do a little bit of recursion
  705. if ($.isArray(search_url)) {
  706. var search_array = [];
  707. $.each(search_url, function(index, url) {
  708. search_array[index] = replaceSearchUrlParams(url, movie_id, movie_title);
  709. });
  710. return search_array;
  711. }
  712. var space_replace = ('spaceEncode' in site) ? site['spaceEncode'] : '+'
  713. var search_string = movie_title.replace(/ +\(.*/, '').replace(/[^a-zA-Z0-9]/g, ' ').replace(/ +/g, space_replace);
  714. var movie_year = document.title.replace(/^(.+) \((.*)([0-9]{4})(.*)$/gi, '$3');
  715. return search_url.replace(/%tt%/g, 'tt' + movie_id)
  716. .replace(/%nott%/g, movie_id)
  717. .replace(/%search_string%/g, search_string)
  718. .replace(/%year%/g, movie_year);
  719. }
  720.  
  721. function getPageSetting(key) {
  722. return (onSearchPage ? GM_config.get(key + '_search') : GM_config.get(key + '_movie'))
  723. }
  724.  
  725. // Small utility function to return a site's icon
  726. function getFavicon(site, hide_on_err) {
  727. if (typeof(hide_on_err) === 'undefined') hide_on_err = false;
  728. if ('icon' in site) {
  729. var favicon = site['icon'];
  730. } else {
  731. var url = new URL(site['searchUrl'])
  732. var favicon = url.origin + '\/favicon.ico';
  733. }
  734. var img = $('<img />').attr({'style': '-moz-opacity: 0.4; border: 0; vertical-align: text-top',
  735. 'width': '16',
  736. 'src': favicon,
  737. 'title': site['name'],
  738. 'alt': site['name']});
  739. if (hide_on_err) img.attr('onerror', "this.style.display='none';");
  740. return img;
  741. }
  742.  
  743. // Adds search links to an element
  744. // state should always be one of the values defined in valid_states
  745. function addLink(elem, link_text, target, site, state) {
  746. var link = $('<a />').attr('href', target).attr('target', '_blank');
  747. if ($.inArray(state, valid_states) < 0) {
  748. console.log("Unknown state " + state);
  749. }
  750. if (getPageSetting('use_icons')) {
  751. var icon = getFavicon(site);
  752. icon.css({'border-width': '3px', 'border-style': 'solid', 'border-radius': '2px'});
  753. if (state == 'error' || state == 'logged_out') {
  754. icon.css('border-color', 'red');
  755. } else if (state == 'missing') {
  756. icon.css('border-color', 'yellow');
  757. } else {
  758. icon.css('border-color', 'green');
  759. }
  760. link.append(icon);
  761. } else {
  762. if (state == 'missing' || state == 'error' || state == 'logged_out') {
  763. link.append($('<s />').append(link_text));
  764. } else {
  765. link.append(link_text);
  766. }
  767. if (state == 'error' || state == 'logged_out') {
  768. link.css('color', 'red');
  769. }
  770. }
  771.  
  772. if (!onSearchPage) {
  773. $('#imdbscout_' + state).append(link).append(' ');
  774. } else {
  775. var result_box = $(elem).find('td.result_box');
  776. if (result_box.length > 0) {
  777. $(result_box).append(link);
  778. } else {
  779. $(elem).append($('<td />').append(link).addClass('result_box'));
  780. }
  781. }
  782. }
  783.  
  784. // Performs an ajax request to determine
  785. // whether or not a url should be displayed
  786. function maybeAddLink(elem, link_text, search_url, site) {
  787. // If the search URL is an array, recurse briefly on the elements.
  788. if ($.isArray(search_url)) {
  789. $.each(search_url, function(index, url) {
  790. maybeAddLink(elem, link_text + '_' + (index + 1).toString(), url, site);
  791. });
  792. return;
  793. }
  794. var target = site['goToUrl'];
  795. var success_match = ('positiveMatch' in site) ? site['positiveMatch'] : false;
  796. GM_xmlhttpRequest({
  797. method: 'GET',
  798. url: search_url,
  799. onload: function(response_details) {
  800. if (String(response_details.responseText).match(site['matchRegex']) ? !(success_match) : success_match) {
  801. if (!getPageSetting('hide_missing')) {
  802. addLink(elem, link_text, target, site, 'missing');
  803. }
  804. } else if (site['loggedOutRegex'] && String(response_details.responseText).match(site['loggedOutRegex'])) {
  805. addLink(elem, link_text, target, site, 'logged_out');
  806. } else {
  807. addLink(elem, link_text, target, site, 'found');
  808. }
  809. },
  810. onerror: function(response) {
  811. addLink(elem, link_text, target, site, 'error');
  812. },
  813. onabort: function(response) {
  814. addLink(elem, link_text, target, site, 'error');
  815. }
  816. });
  817. }
  818.  
  819. // Run code to create fields and display sites
  820. function perform(elem, movie_id, movie_title, is_tv, is_movie) {
  821. var site_shown = false;
  822. $.each(sites, function(index, site) {
  823. if (site['show']) {
  824. site_shown = true;
  825. // If we're on a TV page, only show TV links.
  826. if ((Boolean(site['TV']) == is_tv ||
  827. Boolean(site['both'])) ||
  828. (!is_tv && !is_movie)) {
  829. searchUrl = replaceSearchUrlParams(site, movie_id, movie_title);
  830. // Ugly hack
  831. if ('goToUrl' in site) {
  832. site['goToUrl'] = replaceSearchUrlParams({
  833. 'searchUrl': site['goToUrl'],
  834. 'spaceEncode': ('spaceEncode' in site) ? site['spaceEncode'] : '+'
  835. }, movie_id, movie_title);
  836. } else {
  837. site['goToUrl'] = searchUrl;
  838. }
  839. if (getPageSetting('call_http')) {
  840. maybeAddLink(elem, site['name'], searchUrl, site);
  841. } else {
  842. addLink(elem, site['name'], searchUrl, site, 'found');
  843. }
  844. }
  845. }
  846. });
  847. if (!site_shown) {
  848. $(elem).append('No sites enabled! You can change this via the Greasemonkey option "IMDb Scout Preferences".');
  849. }
  850. }
  851.  
  852. //------------------------------------------------------
  853. // Button Code
  854. //------------------------------------------------------
  855.  
  856. function displayButton() {
  857. var p = $('<p />').attr('id', 'imdbscout_button');
  858. p.append($('<button>Load IMDb Scout</button>').click(function() {
  859. $('#imdbscout_button').remove();
  860. if (onSearchPage) {
  861. performSearch();
  862. } else {
  863. performPage();
  864. }
  865. }));
  866. if (onSearchPage) {
  867. $('#sidebar').append(p);
  868. } else if ($('h1.header:first').length) {
  869. $('h1.header:first').parent().append(p);
  870. } else {
  871. $('#title-overview-widget').parent().append(p);
  872. }
  873. }
  874.  
  875. //------------------------------------------------------
  876. // Icons at top bar
  877. //------------------------------------------------------
  878.  
  879. // Adds a dictionary of icons to the top of the page.
  880. // Unlike the other URLs, they aren't checked to see if the movie exists.
  881. function addIconBar(movie_id, movie_title) {
  882. if ($('h1.header:first').length) {
  883. var iconbar = $('h1.header:first').append($('<br/>'));
  884. } else if ($('.title_wrapper h1')) {
  885. var iconbar = $('.title_wrapper h1').append($('<br/>'));
  886. } else {
  887. var iconbar = $('#tn15title .title-extra');
  888. }
  889. $.each(icon_sites, function(index, site) {
  890. if (site['show']) {
  891. var search_url = replaceSearchUrlParams(site, movie_id, movie_title);
  892. var image = getFavicon(site);
  893. var html = $('<span />').append($('<a />').attr('href', search_url)
  894. .addClass('iconbar_icon').append(image));
  895. iconbar.append(html).append(' ');
  896. }
  897. });
  898. //If we have access to the openInTab function, add an Open All feature
  899. if (GM_openInTab) {
  900. var aopenall = $('<a />').text('Open All')
  901. .attr('href', 'javascript:;')
  902. .attr('style', 'font-weight:bold;font-size:10px;font-family: Calibri, Verdana, Arial, Helvetica, sans-serif;');
  903. aopenall.click(function() {
  904. $('.iconbar_icon').each(function() {
  905. GM_openInTab($(this).attr('href'));
  906. });
  907. }, false);
  908. iconbar.append(aopenall);
  909. }
  910. }
  911.  
  912. //------------------------------------------------------
  913. // Search page code
  914. //------------------------------------------------------
  915.  
  916. function performSearch() {
  917. //Add css for the new table cells we're going to add
  918. var styles = '.result_box {width: 335px}';
  919. styles += ' .result_box a { margin-right: 5px; color: #444;} ';
  920. styles += ' .result_box a:visited { color: #551A8B; }';
  921. styles += ' #content-2-wide #main, #content-2-wide';
  922. styles += ' .maindetails_center {margin-left: 5px; width: 1001px;} ';
  923. GM_addStyle(styles);
  924.  
  925. //Loop through each result row
  926. $('div#main table.results tr.detailed').each(function() {
  927. var link = $(this).find('.title>a');
  928. var is_tv = Boolean($(this).find('.year_type').html()
  929. .match('TV Series'));
  930. var is_movie = Boolean($(this).find('.year_type').html()
  931. .match(/\(([0-9]*)\)/));
  932. var movie_title = link.html();
  933. var movie_id = link.attr('href').match(/tt([0-9]*)\/?$/)[1];
  934.  
  935. $(this).find('span.genre a').each(function() {
  936. if ($(this).html() == 'Adult') {
  937. $(this).parent().parent().parent()
  938. .css('background-color', 'red');
  939. }
  940. });
  941. perform($(this), movie_id, movie_title, is_tv, is_movie);
  942. });
  943. }
  944.  
  945. //------------------------------------------------------
  946. // TV/movie page code
  947. //------------------------------------------------------
  948.  
  949. function performPage() {
  950. var movie_title = $('title').text().match(/^(.*?) \(/)[1];
  951. var movie_id = document.URL.match(/\/tt([0-9]+)\//)[1].trim('tt');
  952. var is_tv_page = Boolean($('title').text().match('TV Series')) ||
  953. Boolean($('.tv-extra').length);
  954. var is_movie_page = Boolean($('title').text().match(/.*? \(([0-9]*)\)/));
  955. //Create area to put links in
  956. perform(getLinkArea(), movie_id, movie_title,
  957. is_tv_page, is_movie_page);
  958. addIconBar(movie_id, movie_title);
  959. }
  960.  
  961. //------------------------------------------------------
  962. // Find/create elements
  963. //------------------------------------------------------
  964.  
  965. function getLinkArea() {
  966. // If it already exists, just return it
  967. if ($('#imdbscout_header').length) {
  968. return $('#imdbscout_header');
  969. }
  970. var p = $('<p />').append('<h2>' + GM_config.get('imdbscout_header_text') + '</h2>').attr('id', 'imdbscout_header').css({
  971. 'padding': '0px 20px',
  972. 'font-weight': 'bold'
  973. });
  974. $.each(valid_states, function(i, name) {
  975. if (GM_config.get('one_line')) {
  976. p.append($('<span />').attr('id', 'imdbscout_' + name));
  977. } else {
  978. var title = $('<span>' + name.replace('_', ' ') + ': </span>').css({
  979. 'textTransform': 'capitalize',
  980. 'min-width': '100px',
  981. 'display': 'inline-block'
  982. });
  983. p.append($('<div />').attr('id', 'imdbscout_' + name).append(title));
  984. }
  985. });
  986. if ($('h1.header:first').length) {
  987. $('h1.header:first').parent().append(p);
  988. } else if ($('#title-overview-widget').length) {
  989. $('#title-overview-widget').parent().append(p);
  990. } else {
  991. $('#tn15rating').before(p);
  992. }
  993. return $('#imdbscout_header');
  994. }
  995.  
  996. //------------------------------------------------------
  997. // Code being run (main)
  998. //------------------------------------------------------
  999.  
  1000. // Get everything configured
  1001.  
  1002. // Create the non-site dictionary for GM_config
  1003. var config_fields = {
  1004. 'imdbscout_header_text': {
  1005. 'label': 'Header text:',
  1006. 'type': 'text',
  1007. 'default': 'Pirate this film: '
  1008. },
  1009. 'call_http_movie': {
  1010. 'section': 'Movie Page:',
  1011. 'type': 'checkbox',
  1012. 'label': 'Actually check for torrents?',
  1013. 'default': true
  1014. },
  1015. 'load_on_start_movie': {
  1016. 'type': 'checkbox',
  1017. 'label': 'Load on start?',
  1018. 'default': true
  1019. },
  1020. 'hide_missing_movie': {
  1021. 'type': 'checkbox',
  1022. 'label': 'Hide missing links?',
  1023. 'default': false
  1024. },
  1025. 'use_icons_movie': {
  1026. 'type': 'checkbox',
  1027. 'label': 'Use icons instead of text?',
  1028. 'default': false
  1029. },
  1030. 'one_line': {
  1031. 'type': 'checkbox',
  1032. 'label': 'Show results on one line?',
  1033. 'default': true
  1034. },
  1035. 'call_http_search': {
  1036. 'section': 'Search Page:',
  1037. 'type': 'checkbox',
  1038. 'label': 'Actually check for torrents?',
  1039. 'default': true
  1040. },
  1041. 'load_on_start_search': {
  1042. 'type': 'checkbox',
  1043. 'label': 'Load on start?',
  1044. 'default': true
  1045. },
  1046. 'hide_missing_search': {
  1047. 'type': 'checkbox',
  1048. 'label': 'Hide missing links?',
  1049. 'default': false
  1050. },
  1051. 'use_icons_search': {
  1052. 'type': 'checkbox',
  1053. 'label': 'Use icons instead of text?',
  1054. 'default': false
  1055. }
  1056. };
  1057.  
  1058. // Add each site to a GM_config dictionary schema
  1059. // The GM_config default for checkboxes is false
  1060. $.each(sites, function(index, site) {
  1061. config_fields['show_' + site['name'] + (site['TV'] ? '_TV' : '')] = {
  1062. 'section': (index == 0) ? ['Torrents:'] : '',
  1063. 'type': 'checkbox',
  1064. 'label': ' ' + site['name'] + (site['TV'] ? ' (TV)' : '')
  1065. };
  1066. });
  1067.  
  1068. // Icon sites should be shown by default though,
  1069. // since they barely use any resources.
  1070. $.each(icon_sites, function(index, icon_site) {
  1071. config_fields['show_icon_' + icon_site['name']] = {
  1072. 'section': (index == 0) ? ['Other sites:'] : '',
  1073. 'type': 'checkbox',
  1074. 'label': ' ' + icon_site['name'],
  1075. 'default': ('showByDefault' in icon_site) ?
  1076. icon_site['showByDefault'] : true
  1077. };
  1078. });
  1079.  
  1080. // Initialize and register GM_config
  1081. GM_config.init({
  1082. 'id': 'imdb_scout',
  1083. 'title': 'IMDb Scout Preferences',
  1084. 'fields': config_fields,
  1085. 'css': '.section_header { \
  1086. background: white !important; \
  1087. color: black !important; \
  1088. border: 0px !important; \
  1089. text-align: left !important;} \
  1090. .field_label { \
  1091. font-weight: normal !important;}',
  1092. 'events':
  1093. {
  1094. 'open': function() {
  1095. $('#imdb_scout').contents().find('#imdb_scout_section_2').find('.field_label').each(function(index, label) {
  1096. url = new URL(sites[index].searchUrl);
  1097. $(label).append(' ' + '<a class="grey_link" target="_blank" style="color: gray; text-decoration : none" href="' + url.origin + '">'
  1098. + (/www./.test(url.hostname) ? url.hostname.match(/www.(.*)/)[1] : url.hostname) + '</a>');
  1099. $(label).prepend(getFavicon(sites[index], true));
  1100. });
  1101. $('#imdb_scout').contents().find('#imdb_scout_section_3').find('.field_label').each(function(index, label) {
  1102. $(label).prepend(getFavicon(icon_sites[index], true));
  1103. });
  1104. }
  1105. }
  1106. });
  1107. GM_registerMenuCommand('IMDb Scout Preferences', function() {GM_config.open()});
  1108.  
  1109. // Fetch per-site values from GM_config
  1110. $.each(sites, function(index, site) {
  1111. site['show'] = GM_config.get('show_' + site['name'] +
  1112. (site['TV'] ? '_TV' : ''));
  1113. });
  1114.  
  1115. $.each(icon_sites, function(index, icon_site) {
  1116. icon_site['show'] = GM_config.get('show_icon_' + icon_site['name']);
  1117. });
  1118.  
  1119. // Are we on a search page?
  1120. // This variable is camelCased to show it's global
  1121. // Hopefully it can be factored out of the global scope in the future
  1122. var onSearchPage = Boolean(location.href.match('search'));
  1123.  
  1124. $('title').ready(function() {
  1125. if (!onSearchPage && GM_config.get('load_on_start_movie')) {
  1126. performPage();
  1127. } else if (onSearchPage && GM_config.get('load_on_start_search')) {
  1128. performSearch();
  1129. } else {
  1130. displayButton();
  1131. }
  1132. });