IMDb Show Viewer

Adds IMDb Show Viewer functionality

  1. // ==UserScript==
  2. // @name IMDb Show Viewer
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Adds IMDb Show Viewer functionality
  6. // @author You
  7. // @match https://www.imdb.com/*
  8. // @grant none
  9. // @license MIT
  10. // ==/UserScript==
  11.  
  12. (function () {
  13. 'use strict';
  14.  
  15. function extractShowIdFromURL() {
  16. var match = window.location.href.match(/\/title\/(tt\d+)\/.*/);
  17. return match ? match[1] : null;
  18. }
  19.  
  20. function watchShow() {
  21. var showId = extractShowIdFromURL();
  22.  
  23. if (showId) {
  24. window.open(`https://vidsrc.to/embed/tv/${showId}/`);
  25. } else {
  26. alert('Unable to extract IMDb Show ID from the URL.');
  27. }
  28. }
  29.  
  30. function watchMovie() {
  31. var showId = extractShowIdFromURL();
  32.  
  33. if (showId) {
  34. window.open(`https://vidsrc.to/embed/movie/${showId}`);
  35. } else {
  36. alert('Unable to extract IMDb Show ID from the URL.');
  37. }
  38. }
  39.  
  40. // Add UI element to the IMDb webpage
  41. function addIMDbShowViewer() {
  42. var container = document.createElement('div');
  43. container.innerHTML = `
  44. <h1>IMDb Show Viewer</h1>
  45. <button id="watchShowButton">Watch Show</button>
  46. <button id="watchMovieButton">Watch Movie</button>
  47. `;
  48. document.body.prepend(container);
  49.  
  50. document.getElementById('watchShowButton').addEventListener('click', watchShow);
  51. document.getElementById('watchMovieButton').addEventListener('click', watchMovie);
  52. }
  53.  
  54. // Add the IMDb Show Viewer to the IMDb webpage
  55. addIMDbShowViewer();
  56. })();