IMDB Scout

Add links from IMDB movie pages to torrent sites -- easy downloading from IMDB

当前为 2014-12-03 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDB Scout
  3. // @namespace https://greasyfork.org/users/1057-kannibalox
  4. // @description Add links from IMDB movie 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.3.2/jquery.min.js
  9. //
  10. // @version 2.26
  11. // @include http://*.imdb.com/title/tt*
  12. // @include http://*.imdb.de/title/tt*
  13. // @include http://*.imdb.es/title/tt*
  14. // @include http://*.imdb.fr/title/tt*
  15. // @include http://*.imdb.it/title/tt*
  16. // @include http://*.imdb.pt/title/tt*
  17. // @include http://*.imdb.com/search/title*
  18. // @include http://*.imdb.de/search/title*
  19. // @include http://*.imdb.es/search/title*
  20. // @include http://*.imdb.fr/search/title*
  21. // @include http://*.imdb.it/search/title*
  22. // @include http://*.imdb.pt/search/title*
  23. //
  24. // @grant GM_log
  25. // @grant GM_getValue
  26. // @grant GM_setValue
  27. // @grant GM_addStyle
  28. // @grant GM_openInTab
  29. // @grant GM_xmlhttpRequest
  30. // @grant GM_registerMenuCommand
  31. //
  32. // ==/UserScript==
  33. /*---------------------Version History--------------------
  34. 1.00 - Initial public release, everything works on barebones greasemonkey
  35.  
  36. 1.50 - Added the ability to select which sites to load from the GM script commands
  37. - Moved the required method to userscripts
  38. - Removed FH, NZB, Avax
  39. 1.60 - Added style elements and shading to display on imdb
  40.  
  41. 1.62 - Fixed bug:SCC-ARC not removing when unchecked
  42. - Alphabetized list
  43.  
  44. 1.70 - Cleaned up code
  45. - Added option to not run script on page load
  46. 1.71 - Deprecated action-box field
  47.  
  48. 1.80 - Added icons that link to OpenSubs, Criticker, RT, YT
  49.  
  50. 1.81 - Added support for tv, only displays on shows listed as 'tv series'
  51. - Added support for icheckmovies at top bar.
  52. 1.82 - Fixed title parsing for tv shows.
  53.  
  54. 1.83 - Fixed dhive not working properly
  55.  
  56. 1.90 - Set height of preference window to 450px, added scroll bar
  57.  
  58. 1.91 - Added another 11 torrent sites
  59.  
  60. 2.00 - Added auto updater
  61.  
  62. 2.01 - Added TC, FreshOn, TVT, STF, CC
  63. - Cleaned up code (tabbing)
  64. - Removed THR
  65. - Added TV-Rage to top bar
  66. 2.02 - Added PS, THC, HH, HDStar
  67. - Fixed CC false positive
  68. 2.03 - TehC now uses tt
  69. - Added Raymoz mod for AT
  70. 2.04 - Added HDbits
  71. - Added TL
  72.  
  73. 2.10 - Added genre page search functionality
  74.  
  75. 2.11 - Fixed ICM because Nuked was whining
  76.  
  77. 2.12 - Removed tvrage
  78. - Fixed iCM (added tt)
  79. - Added HDVNbits
  80. - Changed RevTT to .me
  81. - Added HDT
  82. - removed autoupdate
  83.  
  84. 2.13 - removed xvidme
  85. - reinstated autoupdate
  86. - removed google chrome code
  87. - fixed hdvn and hdt issues
  88.  
  89. 2.14 - Added @grant entries for API access
  90. - Fixed tt parser to work on imdb pages with referral info in url
  91.  
  92. 2.2 - Switch preferences window to use GM_config
  93. - Consolidate icon & site lists
  94. - Added IPT, KASS, sHD, and HDW
  95. - Fix "Open All" link
  96. - Add option for strikethroughs on search page
  97. - Removed arrays from search URLs
  98. - Spring cleaning
  99. 2.21 - Added SSL to TVT, HDME, TC, AHD, IPT, SCC
  100. - Added SSL option for CG
  101. - Added GFT, GFT-Gems, GFT-TV
  102. - Fixed SCC, SCC-ARC search URL
  103. - Removed TheBox, TheDVDClub
  104. - Added more comments, cleaned up some more stuff
  105. 2.22 - Fixed TehC, BTN, BTN-Req, THC
  106. - Added a bunch of TV sites, courtesy of seedless
  107. - Added "both" option for sites, and made changes
  108. to allow coexistences of movie and TV sites with
  109. the same name
  110. - Code re-organization, documentation
  111. - Re-added code to allow an array for searchUrl
  112. 2.22.1 - Minor fixes
  113.  
  114. 2.23 - Fixed THC, BTN
  115. - Distinguish between movies and TV on search page
  116. 2.24 - Separate load_on_start option for search page
  117. - Fix search_string on search page
  118.  
  119. 2.25 - Added some helpful text when no sites have been enabled
  120.  
  121. 2.26 - Added code to show links when on pages besides just the "front" one
  122. (e.g. http://www.imdb.com/title/tt2310332/reference)
  123. --------------------------------------------------------*/
  124.  
  125. if (window.top != window.self) //don't run on frames or iframes
  126. {
  127. //Optional: GM_log ('In frame');
  128. return;
  129. }
  130.  
  131. //------------------------------------------------------
  132. // A list of all the sites, and the data necessary to
  133. // check IMDB against them.
  134. // Each site is a python dictionary with the following attributes:
  135. // - name: The site name, abbreviated
  136. // - searchUrl: The url to perform the search, see below for how
  137. // to tailor the string to a site
  138. // - matchRegex: The string which appears if
  139. // the searchUrl DOESN'T return a result
  140. // - TV (optional): If true, it means that this site will only
  141. // show up on TV pages. By default, sites only show up on movie pages
  142. // - both (optional): Means that the site will show up
  143. // on both movie and TV pages
  144. // To create a search URL, there are three parameters
  145. // you can use inside the URL:
  146. // - %tt%: The IMDB id with the tt prefix
  147. // - %nott%: The IMDB id without the tt prefix
  148. // - $search_string%: The movie title
  149. // See below for examples
  150. //------------------------------------------------------
  151.  
  152. var sites = [
  153. { 'name': 'AHD',
  154. 'searchUrl': 'https://awesome-hd.net/torrents.php?searchstr=%search_string%',
  155. 'matchRegex': /<h2>Error 404<\/h2>/,
  156. 'TV': true},
  157. { 'name': 'BTN',
  158. 'searchUrl': 'https://broadcasthe.net/torrents.php?imdb=%tt%',
  159. 'matchRegex': /Error 404|Lost your password\?/,
  160. 'TV': true},
  161. { 'name': 'BTN-Req',
  162. 'searchUrl': 'https://broadcasthe.net/requests.php?search=%search_string%',
  163. 'matchRegex': /Nothing found|Lost your password\?/,
  164. 'TV': true},
  165. { 'name': 'TVV',
  166. 'searchUrl': 'http://tv-vault.me/torrents.php?searchstr=%search_string%',
  167. 'matchRegex': /Nothing found<\/h2>/,
  168. 'TV': true},
  169. { 'name': 'BMTV',
  170. 'searchUrl': 'https://www.bitmetv.org/browse.php?search=%search_string%',
  171. 'matchRegex': /Nothing found!<\/h2>/,
  172. 'TV': true},
  173. { 'name': 'Fresh',
  174. 'searchUrl': 'http://freshon.tv/browse.php?search=%search_string%',
  175. 'matchRegex': /Nothing found!<\/h2>/,
  176. 'TV': true},
  177. { 'name': 'TvT',
  178. 'searchUrl': 'https://www.tvtorrents.com/loggedin/search.do?search=%search_string%',
  179. 'matchRegex': /Nothing found!<\/h2>/,
  180. 'TV': true},
  181. { 'name': 'GFT',
  182. 'searchUrl': 'https://www.thegft.org/browse.php?view=0&search=%search_string%',
  183. 'matchRegex': /Nothing found!<\/h2>/,
  184. 'TV': true},
  185. { 'name': 'HDME',
  186. 'searchUrl': 'https://hdme.eu/browse.php?search=%search_string%&blah=0&cat=0&incldead=1',
  187. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/,
  188. 'TV': true},
  189. { 'name': 'IPT',
  190. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%search_string%',
  191. 'matchRegex': /<h2>Nothing found!<\/h2>|( 0 torrents )/,
  192. 'TV': true},
  193. { 'name': 'KASS',
  194. 'searchUrl': 'https://kickass.to/usearch/%search_string%',
  195. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  196. 'TV': true},
  197. { 'name': 'RevTT',
  198. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%search_string%&cat=0&incldead=1&titleonly=1',
  199. 'matchRegex': /<h2>Nothing found!<\/h2>/,
  200. 'TV': true},
  201. { 'name': 'SCC',
  202. 'searchUrl': 'https://sceneaccess.eu/browse?search=%search_string%&method=2',
  203. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/,
  204. 'TV': true},
  205. { 'name': 'SCC-ARC',
  206. 'searchUrl': 'https://sceneaccess.eu/archive?search=%search_string%&method=1',
  207. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/,
  208. 'TV': true},
  209. { 'name': 'SCC-NS',
  210. 'searchUrl': 'https://sceneaccess.eu/nonscene?search=%search_string%&method=2',
  211. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/,
  212. 'TV': true},
  213. { 'name': 'TL',
  214. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%&/categories/2,26,27,32',
  215. 'matchRegex': /Signup With Invite|Please refine your search./,
  216. 'TV': true},
  217. { 'name': 'Goem',
  218. 'searchUrl': 'http://goem.org/browse.php?s_type=2&cat=0&search=%tt%',
  219. 'matchRegex': /Try again with a refined searchstring|<h1>Note: You need cookies enabled to log in.<\/h1>/,
  220. 'both': true},
  221. { 'name': 'TPB',
  222. 'searchUrl': 'https://thepiratebay.org/search/%tt%',
  223. 'matchRegex': /No hits. Try adding an asterisk in you search phrase.<\/h2>/,
  224. 'both': true},
  225. { 'name': 'HDW',
  226. 'searchUrl': 'http://hdwing.com/browse.php?search=%search_string%',
  227. 'matchRegex': /<h2>没找到任何内容!|对不起<\/h2>/,
  228. 'both': true},
  229. { 'name': 'AT',
  230. 'searchUrl': 'http://www.asiatorrents.com/index.php?page=torrents&options=3&search=%tt%',
  231. 'matchRegex': /torrent_history/},
  232. { 'name': 'HDVN',
  233. 'searchUrl': 'http://hdvnbits.org/torrents.php?search=%tt%&search_area=4&search_mode=0',
  234. 'matchRegex': /Nothing found! Try again with a refined search string/},
  235. { 'name': 'HDT',
  236. 'searchUrl': 'http://hd-torrents.org/torrents.php?active=0&options=2&search=%tt%',
  237. 'matchRegex': /No torrents here.../},
  238. { 'name': 'TL',
  239. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%&/categories/1,8,9,10,11,12,13,14,15,29',
  240. 'matchRegex': /Signup With Invite|Please refine your search./},
  241. { 'name': 'HDb',
  242. 'searchUrl': 'http://hdbits.org/browse2.php#film/dir=null&searchtype=film&actorfilm=film&search=%tt%',
  243. 'matchRegex': /<p>Note: You need cookies enabled to log in.<\/p>/},
  244. { 'name': 'CG',
  245. 'searchUrl': 'http://cinemageddon.net/browse.php?search=%tt%',
  246. 'matchRegex': /<h2>Nothing found!<\/h2>|<h1>Not logged in!<\/h1>/},
  247. { 'name': 'CG-SSL',
  248. 'searchUrl': 'https://cinemageddon.net/browse.php?search=%tt%',
  249. 'matchRegex': /<h2>Nothing found!<\/h2>|<h1>Not logged in!<\/h1>/},
  250. { 'name': 'Demo',
  251. 'searchUrl': 'http://www.demonoid.me/files/?query=%tt%',
  252. 'matchRegex': /<b>No torrents found<\/b>|We are currently performing the daily site maintenance.<br>/},
  253. { 'name': 'Kara',
  254. 'searchUrl': 'https://www.karagarga.net/browse.php?search_type=imdb&search=%nott%',
  255. 'matchRegex': /<h2>No torrents found<\/h2>|<h1>If you want the love<\/h1>/},
  256. { 'name': 'Tik',
  257. 'searchUrl': 'http://cinematik.net/browse.php?srchdtls=1&incldead=1&search=%tt%',
  258. 'matchRegex': /The page you tried to view can only be used when you're logged in|<h2>Nothing found!<\/h2>/},
  259. { 'name': 'SM',
  260. 'searchUrl': 'http://www.surrealmoviez.info/advanced_search.php?simdb=%tt%',
  261. 'matchRegex': /0 Movies found matching search criteria|You need to be logged in to view this page/},
  262. { 'name': 'ILC',
  263. 'searchUrl': 'http://www.iloveclassics.com/browse.php?incldead=1&searchin=2&search=%tt%',
  264. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  265. { 'name': 'SDBits',
  266. '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%',
  267. 'matchRegex': /Nothing found!|<h1>You need cookies enabled to log in.<\/h1>/},
  268. { 'name': 'eThor',
  269. '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%',
  270. 'matchRegex': /Try again with a refined search string.|<h1>Note: Vous devez activer vos 'cookies' pour pouvoir vous identifier.<\/h1>/},
  271. { 'name': 'x264',
  272. 'searchUrl': 'http://x264.me/browse.php?incldead=0&xtype=0&stype=3&search=%tt%',
  273. 'matchRegex': /Try again with a refined search string.|<h1>Forgot your password?<\/h1>/},
  274. { 'name': 'FSS',
  275. 'searchUrl': 'http://fss.omnilounge.co.uk/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  276. 'matchRegex': /Try again with a different search string?|<h1>You need cookies enabled to log in.<\/h1>/},
  277. { 'name': 'HDME',
  278. 'searchUrl': 'https://hdme.eu/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  279. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/},
  280. { 'name': 'DHive',
  281. 'searchUrl': 'https://gks.gs/sphinx/?category=0&prez=&sort=normal&order=desc&q=%tt%',
  282. 'matchRegex': /Votre Recherche aucun|<h1>Mot de passe<\/h1>/},
  283. { 'name': 'CHD',
  284. 'searchUrl': 'http://chdbits.org/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=4&search_mode=0&search=%tt%',
  285. 'matchRegex': /Nothing found! Try again with a refined search string.|<h1>You need cookies enabled to log in or switch language.<\/h1>/},
  286. { 'name': 'PTP-Req',
  287. 'searchUrl': 'https://tls.passthepopcorn.me/requests.php?submit=true&search=%tt%',
  288. 'matchRegex': /Nothing found!|<h1>Keep me logged in.<\/h1>/},
  289. { 'name': 'ADVD',
  290. 'searchUrl': 'https://asiandvdclub.org/browse.php?descr=1&btnSubmit=Submit&search=%tt%',
  291. 'matchRegex': /Your search returned zero results|<h1>You need cookies enabled to log in.<\/h1>/},
  292. { 'name': 'iPlay',
  293. 'searchUrl': 'http://www.iplay.ro/browse.php?genre=1&status=0&search=%tt%',
  294. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  295. { 'name': 'ScandBits',
  296. 'searchUrl': 'http://scanbits.org/browse.php?cat=0&incldead=0&mode=0&search=%tt%',
  297. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  298. { 'name': 'TE',
  299. 'searchUrl': 'http://theempire.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  300. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  301. { 'name': 'TG',
  302. 'searchUrl': 'http://thegeeks.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  303. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  304. { 'name': 'LL',
  305. 'searchUrl': 'http://www.leecherslair.com/browse.php?blah=1&incldead=0&search=%tt%',
  306. 'matchRegex': /Try again with a refined search string|<h1>This site is under construction<\/h1>/},
  307. { 'name': 'MT',
  308. 'searchUrl': 'http://www.maroctorrent.net/torrents-search.php?cat=42&incldead=1&search=%tt%',
  309. 'matchRegex': /Aucun torrent|<h1>Les Cookies DOIVENT<\/h1>/},
  310. { 'name': 'FY',
  311. 'searchUrl': 'https://fuckyeahtorrents.com/browse.php?_by=2&cat=0&search=%tt%',
  312. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  313. { 'name': 'SCC',
  314. 'searchUrl': 'https://sceneaccess.org/browse?method=3&search=%tt%',
  315. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  316. { 'name': 'SCC-ARC',
  317. 'searchUrl': 'https://sceneaccess.org/archive?=&method=3&search=%tt%',
  318. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  319. { 'name': 'SCC-NS',
  320. 'searchUrl': 'https://sceneaccess.eu/nonscene?=&method=3&search=%tt%',
  321. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  322. { 'name': 'PTP',
  323. 'searchUrl': 'https://tls.passthepopcorn.me/torrents.php?imdb=%tt%',
  324. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  325. { 'name': 'BitHD',
  326. 'searchUrl': 'http://www.bit-hdtv.com/torrents.php?cat=0&description_search=1&search=%tt%',
  327. 'matchRegex': /<h2>No match!<\/h2>/},
  328. { 'name': 'RevTT',
  329. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%tt%',
  330. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  331. { 'name': 'AHD',
  332. 'searchUrl': 'https://awesome-hd.net/torrents.php?id=%tt%',
  333. 'matchRegex': /<h2>Error 404<\/h2>/},
  334. { 'name': 'TehC',
  335. 'searchUrl': 'https://tehconnection.eu/torrents.php?searchstr=%tt%',
  336. 'matchRegex': /You will be banned for 6 hours after your login attempts run out.|<h2>No Search Results, try reducing your search options./},
  337. { 'name': 'CC',
  338. '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%',
  339. '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/},
  340. { 'name': 'PS',
  341. 'searchUrl': 'http://polishsource.org/browse.php?incldead=0&scene=0&pl=0&sub=&search_in=both&free=0&search=%tt%',
  342. 'matchRegex': /Nic nie znaleziono|Musisz|login/},
  343. { 'name': 'THC',
  344. 'searchUrl': ['https://horrorcharnel.kicks-ass.org/browse.php?title=3&search=%tt%', 'https://horrorcharnel.kicks-ass.org/browse.php?search=%tt%&search_what=3&status=0&codec=0&category=0&18=1'],
  345. 'matchRegex': /<h1>Not logged in!<\/h1>|Sorry, nothing found!/},
  346. { 'name': 'HH',
  347. 'searchUrl': 'http://www.horrorhaven.org/search.php?stype=articles&stext=%tt%',
  348. 'matchRegex': /0 Articles found matching search criteria/},
  349. { 'name': 'HDStar',
  350. 'searchUrl': 'http://www.hdstar.org/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=1&search_mode=0&search=%tt%',
  351. 'matchRegex': /Try again with a refined search string|You need cookies enabled to log in or switch language/},
  352. { 'name': 'KASS',
  353. 'searchUrl': 'https://kickass.to/usearch/imdb%3A%nott%',
  354. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  355. { 'name': 'IPT',
  356. 'searchUrl': 'https://www.iptorrents.com/torrents/?q=%tt%',
  357. 'matchRegex': /<h2>Nothing found!<\/h2>|( 0 torrents )/},
  358. { 'name': 'sHD',
  359. 'searchUrl': 'https://scenehd.org/browse.php?options&unpack&incldead&search=%search_string%',
  360. 'matchRegex': /<h2>No torrents found!<\/h2>/},
  361. { 'name': 'GFT',
  362. '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',
  363. 'matchRegex': /Nothing found!<\/h2>/},
  364. { 'name': 'GFT-Gems',
  365. 'searchUrl': 'https://www.thegft.org/browse.php?view=1&search=%tt%&searchtype=0',
  366. 'matchRegex': /Nothing found!<\/h2>/},
  367. ];
  368.  
  369. icon_sites = [
  370. { 'name': 'OpenSubtitles',
  371. 'icon': 'http://www.opensubtitles.org/favicon.ico',
  372. 'searchUrl': "http://www.opensubtitles.org/en/search/imdbid-%tt%"},
  373. { 'name': 'Youtube',
  374. 'icon': 'http://www.youtube.com/favicon.ico',
  375. 'searchUrl': 'http://www.youtube.com/results?search_query="%search_string%"&search=Search'},
  376. { 'name': 'Rotten Tomatoes',
  377. 'icon': "http://www.rottentomatoes.com/favicon.ico",
  378. 'searchUrl': "http://www.rottentomatoes.com/alias?type=imdbid&s=%nott%"},
  379. { 'name': 'Criticker',
  380. 'icon': 'http://www.criticker.com/favicon.ico',
  381. 'searchUrl': 'http://www.criticker.com/?st=movies&h=%search_string%&g=Go'},
  382. { 'name': 'iCheckMovies',
  383. 'icon': 'http://www.icheckmovies.com/favicon.ico',
  384. 'searchUrl': 'http://www.icheckmovies.com/search/movies/?query=%tt%'},
  385. ];
  386.  
  387. function replace_search_url_params(search_url, movie_id, movie_title) {
  388. var search_string = movie_title.replace(/ +\(.*/, '').replace(/[^a-zA-Z0-9]/g, ' ').replace(/ +/g, '+');
  389. if ($.isArray(search_url)) {
  390. search_array = [];
  391. $.each(search_url, function(index, url) {
  392. search_array[index] = replace_search_url_params(url, movie_id, movie_title);
  393. });
  394. return search_array;
  395. }
  396. return search_url.replace('%tt%', 'tt'+movie_id)
  397. .replace('%nott%', movie_id)
  398. .replace('%search_string%', search_string);
  399. }
  400.  
  401. // Adds search links to an element
  402. function add_link(elem, search_url, link_text, strikeout) {
  403. var a = $('<a />').attr('href',search_url).attr('target','_blank');
  404.  
  405. if (strikeout) {
  406. a.append($('<s />').append(link_text));
  407. } else {
  408. a.append(link_text);
  409. }
  410.  
  411. if (!onSearchPage) {
  412. // A little bit of trickery to make matches appear first in a list
  413. if (strikeout) {
  414. $('#pirateheader').append(a).append(' ');
  415. } else {
  416. $('#piratefound').append(a).append(' ');
  417. }
  418. } else {
  419. var result_box = $(elem).find('td.result_box');
  420. if (result_box.length > 0) {
  421. $(result_box).append(a);
  422. } else {
  423. $(elem).append($('<td />').append(a).addClass('result_box'));
  424. }
  425. }
  426. }
  427.  
  428. // Performs an ajax request to determine whether or not a url should be displayed
  429. function maybe_add_link(elem, link_text, search_url, search_fail_match, success_match) {
  430. if (typeof(success_match) === 'undefined') success_match = false;
  431. // If the search URL is an array, recurse briefly on the elements.
  432. if ($.isArray(search_url)) {
  433. $.each(search_url, function(index, url) {
  434. maybe_add_link(elem, link_text+'_'+(index+1).toString(), url, search_fail_match, success_match);
  435. });
  436. return;
  437. }
  438. GM_xmlhttpRequest({
  439. method: 'GET',
  440. url: search_url,
  441. onload: function (responseDetails) {
  442. if (String(responseDetails.responseText).match(search_fail_match) ? !(success_match) : success_match) {
  443. if (onSearchPage ? GM_config.get('strikeout_links_search') : GM_config.get('strikeout_links_movie')) {
  444. add_link(elem, search_url, link_text, true);
  445. }
  446. // If we're on the search page and it isn't found on PTP
  447. if (onSearchPage && link_text == 'PTP') {
  448. var box = $(elem).find('td.result_box');
  449. if (box.length > 0) {
  450. box.css('background-color','green');
  451. } else {
  452. $(elem).append($('<td />').css('background-color','green').addClass('result_box'));
  453. }
  454. }
  455. } else {
  456. add_link(elem, search_url, link_text, false);
  457. }
  458. }
  459. });
  460. }
  461.  
  462. // Run code to create fields and display sites
  463. function perform(elem, movie_id, movie_title, is_tv) {
  464. siteShown = false;
  465. $.each(sites, function(index, site) {
  466. if (site['show']) {
  467. siteShown = true;
  468. // If we're on a TV page, only show TV links.
  469. if (Boolean(site['TV']) == is_tv || Boolean(site['both'])) {
  470. searchUrl = replace_search_url_params(site['searchUrl'], movie_id, movie_title);
  471. maybe_add_link(elem, site['name'], searchUrl, site['matchRegex']);
  472. }
  473. }
  474. });
  475. if (!siteShown) {
  476. $(elem).append("It seems there aren't any sites enabled. You can access your preferences via the Greasemonkey option \"Preferences for IMDB Scout\", which may be under a sub-menu.");
  477. }
  478. }
  479.  
  480. //------------------------------------------------------
  481. // Button Code
  482. //------------------------------------------------------
  483.  
  484. function display_button() {
  485. var p = $('<p />').attr('id', 'piratebutton');
  486. p.append($('<button>Load IMDB Scout</button>').click(function() {
  487. $('#piratebutton').remove();
  488. if (onSearchPage) {
  489. performSearch();
  490. } else {
  491. performPage();
  492. }
  493. }));
  494. if (onSearchPage) {
  495. $('#sidebar').append(p);
  496. } else {
  497. $('h1.header:first').parent().append(p);
  498. }
  499. }
  500.  
  501. //------------------------------------------------------
  502. // Icons at top bar
  503. //------------------------------------------------------
  504.  
  505. // Adds a dictionary of icons to the top of the page.
  506. // Unlike the other URLs, they aren't checked to see if the movie exists.
  507. function addIconBar(movie_id, movie_title) {
  508. if ($('h1.header:first').length) {
  509. var iconbar = $('h1.header:first');
  510. } else {
  511. var iconbar = $('#tn15title .title-extra');
  512. }
  513. $.each(icon_sites, function(index, site) {
  514. var searchUrl = replace_search_url_params(site['searchUrl'], movie_id, movie_title);
  515. var image = $('<img />').attr({'style': '-moz-opacity: 0.4;',
  516. 'width': '16',
  517. 'border': '0',
  518. 'src': site['icon'],
  519. 'title': site['name']});
  520. var html = $('<span />').append($('<a />').attr('href', searchUrl).addClass('iconbar_icon').append(image));
  521. iconbar.append(html).append(' ');
  522. });
  523. //If we have access to the function
  524. if (GM_openInTab) {
  525. var aopenall = $("<a />").text("Open All")
  526. .attr("href", "javascript:;")
  527. .attr('style', 'font-weight:bold;font-size:10px;font-family: Calibri, Verdana, Arial, Helvetica, sans-serif;');
  528. aopenall.click( function () {
  529. $('.iconbar_icon').each(function () {
  530. GM_openInTab($(this).attr('href'));
  531. });
  532. }, false);
  533. iconbar.append(aopenall);
  534. }
  535. }
  536.  
  537. //------------------------------------------------------
  538. // Search page code
  539. //------------------------------------------------------
  540.  
  541. function performSearch(){
  542. //Perform in search page
  543. var styles = '.result_box {width: 335px} .result_box a { margin-right: 5px; color: #444;} ';
  544. styles += ' .result_box a:visited { color: red;}';
  545. styles += ' #imdb2leech_tuned {position: fixed; bottom: 10px; right: 10px; z-index: 1000;} ';
  546. styles += ' #content-2-wide #main, #content-2-wide .maindetails_center {margin-left: 5px; width: 1001px;} ';
  547. GM_addStyle(styles);
  548. //Loop through each result row
  549. $('div#main table.results tr.detailed').each(function(){
  550. var link = $(this).find('.title>a');
  551. var is_tv = Boolean($(this).find('.year_type').html().match('TV Series'));
  552. movie_title = link.html();
  553. movie_id = link.attr('href').match(/tt([0-9]*)\/?$/)[1];
  554. $(this).find('span.genre a').each(function(){
  555. if($(this).html() == "Adult") {
  556. $(this).parent().parent().parent().css('background-color','red');
  557. }
  558. });
  559. perform($(this), movie_id, movie_title, is_tv);
  560. });
  561. }
  562.  
  563. //------------------------------------------------------
  564. // TV/movie page code
  565. //------------------------------------------------------
  566.  
  567. function performPage() {
  568. //alert($("title").text());
  569. var movie_title = $("title").text().match(/^(.*?) \(/)[1];
  570. var movie_id = document.URL.match(/\/tt([0-9]+)\//)[1].trim('tt');
  571. var is_tv_page = Boolean($("title").text().match("TV Series"));
  572. //Create area to put links in
  573. var p = $('<p />').append(GM_config.get('pirate_header_text')).attr('id', 'pirateheader').attr('style', 'font-weight:bold; color:black; background-color: lightgray;');
  574. p.append($('<span />').attr('id', 'piratefound'));
  575. if ( $('h1.header:first').length) {
  576. $('h1.header:first').parent().append(p);
  577. } else {
  578. $('#tn15rating').before(p);
  579. }
  580. perform($('#pirateheader'), movie_id, movie_title, is_tv_page);
  581. addIconBar(movie_id, movie_title);
  582. }
  583.  
  584. //------------------------------------------------------
  585. // Code being run (main)
  586. //------------------------------------------------------
  587.  
  588. // Get everything configured
  589.  
  590. // Create the non-site dictionary for GM_config
  591. var config_fields = {
  592. 'pirate_header_text': {
  593. 'label': 'Header text:',
  594. 'type': 'text',
  595. 'default': 'Pirate this film: '
  596. },
  597. 'load_on_start': {
  598. 'label': 'Load on start?',
  599. 'type': 'checkbox',
  600. 'default': true
  601. },
  602. 'load_on_start_search': {
  603. 'label': 'Load on start on search page?',
  604. 'type': 'checkbox',
  605. 'default': true
  606. },
  607. 'strikeout_links_search': {
  608. 'label': 'Strike out links on search page?',
  609. 'type': 'checkbox',
  610. 'default': true
  611. },
  612. 'strikeout_links_movie': {
  613. 'label': 'Strike out links on movie page?',
  614. 'type': 'checkbox',
  615. 'default': true
  616. },
  617. };
  618.  
  619. // Sort the sites into a consistent pattern
  620. sites.sort(function (a, b) {
  621. return a['name'].toLowerCase() > b['name'].toLowerCase();
  622. });
  623.  
  624. // Add each site GM_config
  625. // The GM_config default for checkboxes is false
  626. $.each(sites, function(index, site) {
  627. config_fields['show_'+site['name']+(site['TV']?"_TV":"")] = {
  628. 'label': 'Show '+site['name']+(site['TV']?" (TV)":"")+'?',
  629. 'type': 'checkbox'
  630. }
  631. });
  632.  
  633. // Initialize and register GM_config
  634. GM_config.init({
  635. 'id': 'imbd_scout',
  636. 'title': 'IMDB Scout Preferences',
  637. 'fields': config_fields
  638. });
  639. GM_registerMenuCommand('Preferences for IMDB Scout', function() {GM_config.open()});
  640.  
  641. // Fetch per-site values from GM_config
  642. $.each(sites, function(index, site) {
  643. site['show'] = GM_config.get('show_'+site['name']+(site['TV']?"_TV":""));
  644. });
  645.  
  646. // Are we on a search page?
  647. // This variable is camelCased to show it's global
  648. // Hopefully it can be factored out of the global scope in the future
  649. var onSearchPage = Boolean(location.href.match('search'));
  650.  
  651. $('title').ready(function() {
  652. if (!onSearchPage && GM_config.get('load_on_start')) {
  653. performPage();
  654. } else if (onSearchPage && GM_config.get('load_on_start_search')) {
  655. performSearch();
  656. } else {
  657. display_button();
  658. }
  659. });