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