IMDb you may know them from

Adds a frame with movies I have already seen

目前为 2023-12-22 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb you may know them from
  3. // @match https://www.imdb.com/name/*
  4. // @description Adds a frame with movies I have already seen
  5. // @grant none
  6. // @version 1.0
  7. // @license MIT
  8. // @namespace https://greasyfork.org/users/1218651
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. var actorId = window.location.href.match(/\/name\/(nm\d+)/)[1];
  13.  
  14. var container = document.createElement('div');
  15. container.style.clear = 'both';
  16.  
  17. var header = document.createElement('h3');
  18. header.innerHTML = 'Movies I have already seen (click to expand)';
  19. header.style.cursor = 'pointer';
  20. header.style.color = '#0E63BE'; // Sets the header color using the hexadecimal value
  21.  
  22. var iframe = document.createElement('iframe');
  23. iframe.src = 'https://www.imdb.com/filmosearch/?role=' + actorId + '&mode=simple&my_ratings=restrict';
  24. iframe.style.width = '100%';
  25. iframe.style.height = '500px';
  26. iframe.style.display = 'none'; // Hides the frame initially
  27.  
  28. // Add an onload event to the iframe to modify links within it
  29. iframe.onload = function() {
  30. var linksInIframe = iframe.contentDocument.querySelectorAll('a');
  31. linksInIframe.forEach(function(link) {
  32. link.setAttribute('target', '_top'); // Sets the target of links in the iframe to "_top"
  33. });
  34. };
  35.  
  36. container.appendChild(header);
  37. container.appendChild(iframe);
  38.  
  39. var expander = document.querySelector('div.sc-6703147-0 button');
  40. expander.parentNode.insertBefore(container, expander.nextSibling);
  41.  
  42. header.addEventListener('click', function() {
  43. if (iframe.style.display === 'none') {
  44. iframe.style.display = 'block'; // Shows the frame when clicking the header
  45. } else {
  46. iframe.style.display = 'none'; // Hides the frame when clicking the header again
  47. }
  48. });
  49. })();