MovieChat.org Message Boards on TMDb

Adds MovieChat message boards on TMDb.

  1. // ==UserScript==
  2. // @name MovieChat.org Message Boards on TMDb
  3. // @namespace https://greasyfork.org/en/users/105361-randomusername404
  4. // @version 1.00
  5. // @description Adds MovieChat message boards on TMDb.
  6. // @run-at document-start
  7. // @include *://*.themoviedb.org/movie/*
  8. // @include *://*.themoviedb.org/person/*
  9. // @include *://*.themoviedb.org/tv/*
  10. // @require https://code.jquery.com/jquery-3.3.1.min.js
  11. // @author RandomUsername404
  12. // @grant none
  13. // @icon https://www.themoviedb.org/favicon.ico
  14. // ==/UserScript==
  15.  
  16. $(window).on("load", function() {
  17. var pathname = window.location.pathname;
  18.  
  19. // Set MovieChat link
  20. var pageTitle = $('title').text();
  21. pageTitle = pageTitle.split(" —").shift();
  22. var DDG_URL;
  23. if (pathname.includes('movie') || pathname.includes('tv')) {
  24. DDG_URL = "https://duckduckgo.com/?q=!ducky+" + pageTitle.replace(/ /g, "+") + "+site:moviechat.org";
  25. } else {
  26. DDG_URL = "https://duckduckgo.com/?q=!ducky+" + pageTitle.replace(/ /g, "+") + "+site:moviechat.org/nm";
  27. }
  28. var MC_URL = "https://moviechat.org/search?name=" + pageTitle.replace("TV Series ", "").replace(/ /g, "+");
  29.  
  30. // Add link to the MovieChat boards in the 'Discussions' menu
  31. $('#sub_menu_discussions > ul').append('<li><a target="OpenBlank" href="' + DDG_URL + '">MovieChat Boards</a></li>');
  32.  
  33. // On a 'movie' or 'tv' page
  34. if (pathname.includes('movie') || pathname.includes('tv')) {
  35.  
  36. // Create a submenu to put the boards into
  37. var MC_menu = document.createElement("li");
  38. $(MC_menu).attr("class", "");
  39. $(MC_menu).attr("dir", "auto");
  40. $(MC_menu).html('<a id="moviechat" class="media_panel" href="#">MovieChat Boards</a>');
  41. $(".menu > ul:first").append(MC_menu);
  42.  
  43. // Define dimensions of the iframe
  44. var height = $(window).innerHeight() * 0.82;
  45. var width = $(".panel").width();
  46.  
  47. // If submenu is clicked
  48. $(document).on("click", "#moviechat", function(event) {
  49. event.preventDefault();
  50.  
  51. $("section.panel.media_panel.social_panel > section > div.menu > ul > li").each(function() {
  52. $(this).removeClass('active');
  53. console.log(this);
  54. });
  55.  
  56. $(MC_menu).addClass('active');
  57.  
  58. // Put the iframe in the submenu
  59. $('.review > .content').empty();
  60. var movieChat = document.createElement("iframe");
  61. $(movieChat).attr({ "src": MC_URL, "allowtransparency": "false", "sandbox": "allow-same-origin allow-scripts" });
  62. $(movieChat).css({ "height": height + "px", "width": width + "px", "border": "none" });
  63. $('.review > .content').append(movieChat);
  64.  
  65. // Add message under the iframe inviting people to visite MovieChat.org
  66. var externalLink = document.createElement("div");
  67. $(externalLink).html('<hr/><span>Discuss <i>' + pageTitle + '</i> on the <a style="color:#01cf75;" target="OpenBlank" href="' + DDG_URL + '"><b>MovieChat message boards</b></a></span>');
  68. $('.review > .content').append(externalLink);
  69.  
  70. });
  71.  
  72. }
  73. // On an actor page
  74. else {
  75. // Create the area to put the boards into
  76. var MC_menu = document.createElement("div");
  77. $(MC_menu).html('<h3 class="zero">MovieChat Boards</h3>');
  78. $(MC_menu).css('margin-top', '50px');
  79. $(MC_menu).insertAfter('.credits_list');
  80.  
  81. // Define dimensions of the iframe
  82. var height = $(window).innerHeight() * 0.84;
  83. var width = $(".credits_list").width();
  84.  
  85. // Put the iframe in the area
  86. var movieChat = document.createElement("iframe");
  87. $(movieChat).attr({ "src": MC_URL, "allowtransparency": "false", "sandbox": "allow-same-origin allow-scripts" });
  88. $(movieChat).css({ "height": height + "px", "width": width + "px", "border": "none" });
  89. $(MC_menu).append(movieChat);
  90.  
  91. // Add message under the iframe inviting people to visite MovieChat.org
  92. var externalLink = document.createElement("div");
  93. $(externalLink).html('<hr/><span>Discuss <i>' + pageTitle + '</i> on the <a style="color:#01cf75;" target="OpenBlank" href="' + DDG_URL + '"><b>MovieChat message boards</b></a></span>');
  94. $(MC_menu).append(externalLink);
  95.  
  96. }
  97.  
  98. });