IMDB Scout

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

目前為 2014-08-07 提交的版本,檢視 最新版本

  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.2
  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. --------------------------------------------------------*/
  100.  
  101. // A list of all the sites, and the data necessary to check IMDB against them
  102. // To create a search URL, there are three parameters you can use inside the URL:
  103. // - %tt%: The IMDB id with the tt prefix
  104. // - %nott%: The IMDB id without the tt prefix
  105. // - $search_string%: The movie title
  106. // See below for examples
  107. var sites = [
  108. { 'name': 'BTN',
  109. 'searchUrl': 'https://broadcasthe.net/torrents.php?searchstr=%search_string%',
  110. 'matchRegex': /Whatchoo talkin' bout willis?.<\/h2>/,
  111. 'TV': true},
  112. { 'name': 'BTN-Req',
  113. 'searchUrl': 'https://broadcasthe.net/requests.php?search=%search_string%',
  114. 'matchRegex': /Whatchoo talkin' bout willis?.<\/h2>/,
  115. 'TV': true},
  116. { 'name': 'TVV',
  117. 'searchUrl': 'http://tv-vault.me/torrents.php?searchstr=%search_string%',
  118. 'matchRegex': /Nothing found<\/h2>/,
  119. 'TV': true},
  120. { 'name': 'BMTV',
  121. 'searchUrl': 'https://www.bitmetv.org/browse.php?search=%search_string%',
  122. 'matchRegex': /Nothing found!<\/h2>/,
  123. 'TV': true},
  124. { 'name': 'Fresh',
  125. 'searchUrl': 'http://freshon.tv/browse.php?search=%search_string%',
  126. 'matchRegex': /Nothing found!<\/h2>/,
  127. 'TV': true},
  128. { 'name': 'TvT',
  129. 'searchUrl': 'http://www.tvtorrents.com/loggedin/search.do?search=%search_string%',
  130. 'matchRegex': /Nothing found!<\/h2>/,
  131. 'TV': true},
  132. { 'name': 'AT',
  133. 'searchUrl': 'http://www.asiatorrents.com/index.php?page=torrents&options=3&search=%tt%',
  134. 'matchRegex': /torrent_history/,
  135. 'success_match': true},
  136. { 'name': 'HDVN',
  137. 'searchUrl': 'http://hdvnbits.org/torrents.php?search=%tt%&search_area=4&search_mode=0',
  138. 'matchRegex': /Nothing found! Try again with a refined search string/},
  139. { 'name': 'HDT',
  140. 'searchUrl': 'http://hd-torrents.org/torrents.php?active=0&options=2&search=%tt%',
  141. 'matchRegex': /No torrents here.../},
  142. { 'name': 'TL',
  143. 'searchUrl': 'http://www.torrentleech.org/torrents/browse/index/query/%search_string%',
  144. 'matchRegex': /Signup With Invite|Please refine your search./},
  145. { 'name': 'HDb',
  146. 'searchUrl': 'http://hdbits.org/browse2.php#film/dir=null&searchtype=film&actorfilm=film&search=%tt%',
  147. 'matchRegex': /<p>Note: You need cookies enabled to log in.<\/p>/},
  148. { 'name': 'CG',
  149. 'searchUrl': 'http://cinemageddon.net/browse.php?search=%tt%',
  150. 'matchRegex': /<h2>Nothing found!<\/h2>|<h1>Not logged in!<\/h1>/},
  151. { 'name': 'TPB',
  152. 'searchUrl': 'https://thepiratebay.org/search/%tt%',
  153. 'matchRegex': /No hits. Try adding an asterisk in you search phrase.<\/h2>/},
  154. { 'name': 'Demo',
  155. 'searchUrl': 'http://www.demonoid.me/files/?query=%tt%',
  156. 'matchRegex': /<b>No torrents found<\/b>|We are currently performing the daily site maintenance.<br>/},
  157. { 'name': 'Kara',
  158. 'searchUrl': 'https://www.karagarga.net/browse.php?search_type=imdb&search=%nott%',
  159. 'matchRegex': /<h2>No torrents found<\/h2>|<h1>If you want the love<\/h1>/},
  160. { 'name': 'Tik',
  161. 'searchUrl': 'http://cinematik.net/browse.php?srchdtls=1&incldead=1&search=%tt%',
  162. 'matchRegex': /The page you tried to view can only be used when you're logged in|<h2>Nothing found!<\/h2>/},
  163. { 'name': 'SM',
  164. 'searchUrl': 'http://www.surrealmoviez.info/advanced_search.php?simdb=%tt%',
  165. 'matchRegex': /0 Movies found matching search criteria|You need to be logged in to view this page/},
  166. { 'name': 'ILC',
  167. 'searchUrl': 'http://www.iloveclassics.com/browse.php?incldead=1&searchin=2&search=%tt%',
  168. 'matchRegex': /Try again with a refined search string|<h1>Not logged in!<\/h1>/},
  169. { 'name': 'Goem',
  170. 'searchUrl': 'http://goem.org/browse.php?s_type=2&cat=0&search=%tt%',
  171. 'matchRegex': /Try again with a refined searchstring|<h1>Note: You need cookies enabled to log in.<\/h1>/},
  172. { 'name': 'SCC',
  173. 'searchUrl': 'http://sceneaccess.org/browse?method=1&search=%tt%',
  174. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  175. { 'name': 'SDBits',
  176. '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%',
  177. 'matchRegex': /Nothing found!|<h1>You need cookies enabled to log in.<\/h1>/},
  178. { 'name': 'eThor',
  179. '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%',
  180. 'matchRegex': /Try again with a refined search string.|<h1>Note: Vous devez activer vos 'cookies' pour pouvoir vous identifier.<\/h1>/},
  181. { 'name': 'x264',
  182. 'searchUrl': 'http://x264.me/browse.php?incldead=0&xtype=0&stype=3&search=%tt%',
  183. 'matchRegex': /Try again with a refined search string.|<h1>Forgot your password?<\/h1>/},
  184. { 'name': 'FSS',
  185. 'searchUrl': 'http://fss.omnilounge.co.uk/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  186. 'matchRegex': /Try again with a different search string?|<h1>You need cookies enabled to log in.<\/h1>/},
  187. { 'name': 'HDME',
  188. 'searchUrl': 'http://hdme.eu/browse.php?blah=2&cat=0&incldead=1&search=%tt%',
  189. 'matchRegex': /Try again with a refined search string.|<h1>You need cookies enabled to log in.<\/h1>/},
  190. { 'name': 'DHive',
  191. 'searchUrl': 'https://gks.gs/sphinx/?category=0&prez=&sort=normal&order=desc&q=%tt%',
  192. 'matchRegex': /Votre Recherche aucun|<h1>Mot de passe<\/h1>/},
  193. { 'name': 'CHD',
  194. 'searchUrl': 'http://chdbits.org/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=4&search_mode=0&search=%tt%',
  195. 'matchRegex': /Nothing found! Try again with a refined search string.|<h1>You need cookies enabled to log in or switch language.<\/h1>/},
  196. { 'name': 'PTP-Req',
  197. 'searchUrl': 'https://tls.passthepopcorn.me/requests.php?submit=true&search=%tt%',
  198. 'matchRegex': /Nothing found!|<h1>Keep me logged in.<\/h1>/},
  199. { 'name': 'ADVD',
  200. 'searchUrl': 'https://asiandvdclub.org/browse.php?descr=1&btnSubmit=Submit&search=%tt%',
  201. 'matchRegex': /Your search returned zero results|<h1>You need cookies enabled to log in.<\/h1>/},
  202. { 'name': 'iPlay',
  203. 'searchUrl': 'http://www.iplay.ro/browse.php?genre=1&status=0&search=%tt%',
  204. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  205. { 'name': 'ScandBits',
  206. 'searchUrl': 'http://scanbits.org/browse.php?cat=0&incldead=0&mode=0&search=%tt%',
  207. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  208. { 'name': 'TE',
  209. 'searchUrl': 'http://theempire.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  210. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  211. { 'name': 'TB',
  212. 'searchUrl': 'http://thebox.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  213. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  214. { 'name': 'TG',
  215. 'searchUrl': 'http://thegeeks.bz/browse.php?incldead=0&country=&nonboolean=1&search=%tt%',
  216. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  217. { 'name': 'LL',
  218. 'searchUrl': 'http://www.leecherslair.com/browse.php?blah=1&incldead=0&search=%tt%',
  219. 'matchRegex': /Try again with a refined search string|<h1>This site is under construction<\/h1>/},
  220. { 'name': 'MT',
  221. 'searchUrl': 'http://www.maroctorrent.net/torrents-search.php?cat=42&incldead=1&search=%tt%',
  222. 'matchRegex': /Aucun torrent|<h1>Les Cookies DOIVENT<\/h1>/},
  223. { 'name': 'TDC',
  224. 'searchUrl': 'http://thedvdclub.org/browse.php?cat=0&blah=1&incldead=1&search=%tt%',
  225. 'matchRegex': /Try again with a refined search string|<h1>Cookies must be enabled for you to log in<\/h1>/},
  226. { 'name': 'FY',
  227. 'searchUrl': 'https://fuckyeahtorrents.com/browse.php?_by=2&cat=0&search=%tt%',
  228. 'matchRegex': /Try again with a refined search string|<h1>You need cookies enabled to log in.<\/h1>/},
  229. { 'name': 'SCC-ARC',
  230. 'searchUrl': 'https://sceneaccess.org/archive?=&method=1&search=%tt%',
  231. 'matchRegex': /Try again with a refined search string.|<h1>Note: Three (3) failed login attempts will result in a temporary security lockout.<\/h1>/},
  232. { 'name': 'PTP',
  233. 'searchUrl': 'https://tls.passthepopcorn.me/torrents.php?imdb=%tt%',
  234. 'matchRegex': /<h2>Your search did not match anything.<\/h2>/},
  235. { 'name': 'BitHD',
  236. 'searchUrl': 'http://www.bit-hdtv.com/torrents.php?cat=0&description_search=1&search=%tt%',
  237. 'matchRegex': /<h2>No match!<\/h2>/},
  238. { 'name': 'RevTT',
  239. 'searchUrl': 'https://www.revolutiontt.me/browse.php?search=%tt%',
  240. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  241. { 'name': 'AHD',
  242. 'searchUrl': 'http://awesome-hd.net/torrents.php?id=%tt%',
  243. 'matchRegex': /<h2>Error 404<\/h2>/},
  244. { 'name': 'TehC',
  245. 'searchUrl': 'http://tehconnection.eu/torrents.php?searchstr=%tt%',
  246. 'matchRegex': /You will be banned for 6 hours after your login attempts run out.|<h2>No Search Results}/},
  247. { 'name': 'CC',
  248. '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%',
  249. '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/},
  250. { 'name': 'PS',
  251. 'searchUrl': 'http://polishsource.org/browse.php?incldead=0&scene=0&pl=0&sub=&search_in=both&free=0&search=%tt%',
  252. 'matchRegex': /Nic nie znaleziono|Musisz|login/},
  253. { 'name': 'THC',
  254. 'searchUrl': 'http://horrorcharnel.kicks-ass.org/browse.php?title=3&search=%tt%',
  255. 'matchRegex': /<h1>Not logged in!<\/h1>|Nothing found!/},
  256. { 'name': 'HH',
  257. 'searchUrl': 'http://www.horrorhaven.org/search.php?stype=articles&stext=%tt%',
  258. 'matchRegex': /0 Articles found matching search criteria/},
  259. { 'name': 'HDStar',
  260. 'searchUrl': 'http://www.hdstar.org/torrents.php?incldead=1&spstate=0&inclbookmarked=0&search_area=1&search_mode=0&search=%tt%',
  261. 'matchRegex': /Try again with a refined search string|You need cookies enabled to log in or switch language/},
  262. { 'name': 'KASS',
  263. 'searchUrl': 'https://kickass.to/usearch/imdb%3A%nott%',
  264. 'matchRegex': /<h2>Nothing found!<\/h2>/},
  265. { 'name': 'IPT',
  266. 'searchUrl': 'http://www.iptorrents.com/torrents/?q=%tt%',
  267. 'matchRegex': /<h2>Nothing found!<\/h2>|( 0 torrents )/},
  268. { 'name': 'sHD',
  269. 'searchUrl': 'https://scenehd.org/browse.php?options&unpack&incldead&search=%search_string%',
  270. 'matchRegex': /<h2>No torrents found!<\/h2>/},
  271. { 'name': 'HDW',
  272. 'searchUrl': 'http://hdwing.com/browse.php?search=%search_string%',
  273. 'matchRegex': /<h2>没找到任何内容!|对不起<\/h2>/},
  274. ];
  275.  
  276. icon_sites = [
  277. { 'name': 'OpenSubtitles',
  278. 'icon': 'http://www.opensubtitles.org/favicon.ico',
  279. 'searchUrl': "http://www.opensubtitles.org/en/search/imdbid-%tt%"},
  280. { 'name': 'Youtube',
  281. 'icon': 'http://www.youtube.com/favicon.ico',
  282. 'searchUrl': 'http://www.youtube.com/results?search_query="%search_string%"&search=Search'},
  283. { 'name': 'Rotten Tomatoes',
  284. 'icon': "http://www.rottentomatoes.com/favicon.ico",
  285. 'searchUrl': "http://www.rottentomatoes.com/alias?type=imdbid&s=%nott%"},
  286. { 'name': 'Criticker',
  287. 'icon': 'http://www.criticker.com/favicon.ico',
  288. 'searchUrl': 'http://www.criticker.com/?st=movies&h=%search_string%&g=Go'},
  289. { 'name': 'iCheckMovies',
  290. 'icon': 'http://www.icheckmovies.com/favicon.ico',
  291. 'searchUrl': 'http://www.icheckmovies.com/search/movies/?query=%tt%'},
  292. ];
  293.  
  294.  
  295.  
  296. //adds links to field
  297. function add_link(elem,search_url, link_text, strikeout) {
  298. var a = $('<a />').attr('href',search_url).attr('target','_blank');
  299.  
  300. if (strikeout) {
  301. a.append($('<s />').append(link_text));
  302. } else {
  303. a.append(link_text);
  304. }
  305.  
  306. if (onSearchPage == false) {
  307. if (strikeout) {
  308. $('#pirateheader').append(a).append(' ');
  309. } else {
  310. $('#piratefound').append(a).append(' ');
  311. }
  312. } else {
  313. var result_box = $(elem).find('td.result_box');
  314. if (result_box.length > 0) {
  315. $(result_box).append(a);
  316. } else {
  317. $(elem).append($('<td />').append(a).addClass('result_box'));
  318. }
  319. }
  320. }
  321.  
  322. //tests whether to strikeout
  323. function maybe_add_link(elem,link_text, search_url, search_fail_match, success_match) {
  324. if (typeof(success_match) === 'undefined') success_match = false;
  325. GM_xmlhttpRequest({
  326. method: 'GET',
  327. url: search_url,
  328. onload: function (responseDetails) {
  329. if (String(responseDetails.responseText).match(search_fail_match) ? !(success_match) : success_match) {
  330. if (onSearchPage ? GM_config.get('strikeout_links_search') : GM_config.get('strikeout_links_movie')) {
  331. add_link(elem,search_url, link_text, true);
  332. }
  333. // If we're on the search page and it isn't found on PTP
  334. if (onSearchPage && link_text == 'PTP') {
  335. var box = $(elem).find('td.result_box');
  336. if (box.length > 0) {
  337. box.css('background-color','green');
  338. } else {
  339. $(elem).append($('<td />').css('background-color','green').addClass('result_box'));
  340. }
  341. }
  342. } else {
  343. add_link(elem,search_url, link_text, false);
  344. }
  345. }
  346. });
  347. }
  348.  
  349. //run code to create field and display sites
  350. function perform(elem, movie_id, movie_title) {
  351. var tt = 'tt' + movie_id;
  352. var nott = movie_id;
  353. var search_string = movie_title.replace(/ +\(.*/, '').replace(/[^a-zA-Z0-9]/g, ' ').replace(/ +/g, '+');
  354. var isTVPage = Boolean(document.getElementsByTagName("title")[0].innerHTML.match("TV Series"));
  355.  
  356. // Add area for links on movie page
  357. if (onSearchPage == false) {
  358. var p = $('<p />').append(pirate_header_text).attr('id', 'pirateheader').attr('style', 'font-weight:bold; color:black; background-color: lightgray;');
  359. p.append($('<span />').attr('id', 'piratefound'));
  360. $('h1.header:first').parent().append(p);
  361. elem = $('#pirateheader');
  362. }
  363. $.each(sites, function(index, site) {
  364. if (site['show'] == true) {
  365. var isTVSite = Boolean(site['TV'])
  366. if (isTVSite == isTVPage) {
  367. searchUrl = site['searchUrl'].replace('%tt%', 'tt'+movie_id)
  368. .replace('%nott%', movie_id)
  369. .replace('%search_string%', search_string);
  370. maybe_add_link(elem, site['name'], searchUrl, site['matchRegex']);
  371. }
  372. }
  373. });
  374. }
  375.  
  376. //------------------------------------------------------------
  377. // Button Code
  378. //-------------------------------------------------------------
  379.  
  380. function display_button() {
  381. var p = $('<p />').attr('id', 'piratebutton');//.attr('style', 'font-weight:bold; color:black; background-color: lightgray;');
  382. p.append($('<button>Load IMDB Scout</button>').click(function() {
  383. $('#piratebutton').remove();
  384. if (onSearchPage) {
  385. performSearch();
  386. } else {
  387. movie_title = document.title.match(/^(.*?) \(/)[1];
  388. movie_id = document.URL.match(/\/tt([0-9]+)\//)[1].trim('tt');
  389. addIconBar();
  390. perform(null, movie_id, movie_title);
  391. }
  392. }));
  393. if (onSearchPage) {
  394. $('#sidebar').append(p);
  395. } else {
  396. $('h1.header:first').parent().append(p);
  397. }
  398. }
  399.  
  400. //------------------------------------------------------------
  401. // Icons at top bar
  402. //---------------------------------------------------------
  403.  
  404. function addIconBar() {
  405. var iconbar = $('h1.header:first');
  406. iconbar.id = 'iconbar';
  407. $.each(icon_sites, function(index, site) {
  408. var searchUrl = site['searchUrl'].replace('%tt%', 'tt'+movie_id)
  409. .replace('%nott%', movie_id)
  410. .replace('%search_string%', movie_title.replace(/ +\(.*/, '').replace(/[^a-zA-Z0-9]/g, ' ').replace(/ +/g, '+'));
  411. var image = $('<img />').attr({'style': '-moz-opacity: 0.4;',
  412. 'width': '16',
  413. 'border': '0',
  414. 'src': site['icon'],
  415. 'title': site['name']});
  416. var html = $('<span />').append($('<a />').attr('href', searchUrl).addClass('iconbar_icon').append(image));
  417. iconbar.append(html).append(' ');
  418. });
  419. if (GM_openInTab) {
  420. var aopenall = $("<a />").text("Open All")
  421. .attr("href", "javascript:;")
  422. .attr('style', 'font-weight:bold;font-size:10px;font-family: Calibri, Verdana, Arial, Helvetica, sans-serif;');
  423. aopenall.click( function () {
  424. $('.iconbar_icon').each(function () {
  425. GM_openInTab($(this).attr('href'));
  426. });
  427. }, false);
  428.  
  429. iconbar.append(aopenall);
  430. }
  431. }
  432.  
  433. //------------------------------------------------------------
  434. // Genre page code
  435. //---------------------------------------------------------
  436.  
  437. function performSearch(page){
  438. //Perform in search page
  439. var styles = '.result_box {width: 335px} .result_box a { margin-right: 5px; color: #444;} ';
  440. styles += ' .result_box a:visited { color: red;}';
  441. styles += ' #imdb2leech_tuned {position: fixed; bottom: 10px; right: 10px; z-index: 1000;} ';
  442. styles += ' #content-2-wide #main, #content-2-wide .maindetails_center {margin-left: 5px; width: 1001px;} ';
  443. GM_addStyle(styles);
  444. $('div#main table.results tr.detailed').each(function(){
  445. var link = $(this).find('td.image a');
  446. movie_title = link.html();
  447. movie_id = link.attr('href').match(/tt([0-9]*)\/?$/)[1];
  448. $(this).find('span.genre a').each(function(){
  449. if($(this).html() == "Adult") {
  450. $(this).parent().parent().parent().css('background-color','red');
  451. }
  452. });
  453. perform($(this), movie_id, movie_title);
  454. });
  455. }
  456.  
  457. //------------------------------------------------------------
  458. // Code being run (main)
  459. //---------------------------------------------------------
  460.  
  461. // Get everything configured
  462.  
  463. // Create the non-site dictionary for GM_config
  464. var config_fields = {
  465. 'pirate_header_text': {
  466. 'label': 'Header text:',
  467. 'type': 'text',
  468. 'default': 'Pirate this film: '
  469. },
  470. 'load_on_start': {
  471. 'label': 'Load on start?',
  472. 'type': 'checkbox',
  473. 'default': true
  474. },
  475. 'strikeout_links_search': {
  476. 'label': 'Strike out links on search page?',
  477. 'type': 'checkbox',
  478. 'default': true
  479. },
  480. 'strikeout_links_movie': {
  481. 'label': 'Strike out links on movie page?',
  482. 'type': 'checkbox',
  483. 'default': true
  484. },
  485. };
  486.  
  487. sites.sort(function (a, b) {
  488. return a['name'] > b['name'];
  489. });
  490.  
  491. // Add each site GM_config
  492. // The GM_config default for checkboxes is false
  493. $.each(sites, function(index, site) {
  494. config_fields['show_'+site['name']] = {
  495. 'label': 'Show '+site['name']+'?',
  496. 'type': 'checkbox'
  497. }
  498. });
  499.  
  500. // Initialize and register GM_config
  501. GM_config.init({
  502. 'id': 'imbd_scout',
  503. 'title': 'IMDB Scout Preferences',
  504. 'fields': config_fields
  505. });
  506. GM_registerMenuCommand('Preferences for IMDB Scout', function() {GM_config.open()});
  507.  
  508. // Fetch site values from GM_config
  509. $.each(sites, function(index, site) {
  510. site['show'] = GM_config.get('show_'+site['name']);
  511. });
  512.  
  513. // Default preferences are stored above.
  514. var show_strikeout_links = GM_config.get('strikeout_links_movie');
  515. var pirate_header_text = GM_config.get('pirate_header_text')
  516. var perform_on_start = GM_config.get('load_on_start');
  517.  
  518. // Are we on a search page?
  519. var onSearchPage = Boolean(location.href.match('search'));
  520.  
  521.  
  522. //addIconBar();
  523. if (perform_on_start) {
  524. if (!onSearchPage) {
  525. var movie_title = document.title.match(/^(.*?) \(/)[1];
  526. var movie_id = document.URL.match(/\/tt([0-9]+)\//)[1].trim('tt');
  527. perform(null, movie_id, movie_title);
  528. addIconBar();
  529. } else {
  530. performSearch();
  531. }
  532. } else {
  533. display_button();
  534. }