IMDb you may know them from

Adds a frame with movies I have already seen

目前為 2023-12-22 提交的版本,檢視 最新版本

您需要先安裝使用者腳本管理器擴展,如 TampermonkeyGreasemonkeyViolentmonkey 之後才能安裝該腳本。

You will need to install an extension such as Tampermonkey to install this script.

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyViolentmonkey 後才能安裝該腳本。

您需要先安裝使用者腳本管理器擴充功能,如 TampermonkeyUserscripts 後才能安裝該腳本。

你需要先安裝一款使用者腳本管理器擴展,比如 Tampermonkey,才能安裝此腳本

您需要先安裝使用者腳本管理器擴充功能後才能安裝該腳本。

(我已經安裝了使用者腳本管理器,讓我安裝!)

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展,比如 Stylus,才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

你需要先安裝一款使用者樣式管理器擴展後才能安裝此樣式

(我已經安裝了使用者樣式管理器,讓我安裝!)

// ==UserScript==
// @name         IMDb you may know them from
// @match        https://www.imdb.com/name/*
// @description  Adds a frame with movies I have already seen
// @grant        none
// @version      1.0
// @license      MIT
// @namespace https://greasyfork.org/users/1218651
// ==/UserScript==

(function() {
  var actorId = window.location.href.match(/\/name\/(nm\d+)/)[1];

  var container = document.createElement('div');
  container.style.clear = 'both';

  var header = document.createElement('h3');
  header.innerHTML = 'Movies I have already seen (click to expand)';
  header.style.cursor = 'pointer';
  header.style.color = '#0E63BE'; // Sets the header color using the hexadecimal value

  var iframe = document.createElement('iframe');
  iframe.src = 'https://www.imdb.com/filmosearch/?role=' + actorId + '&mode=simple&my_ratings=restrict';
  iframe.style.width = '100%';
  iframe.style.height = '500px';
  iframe.style.display = 'none'; // Hides the frame initially

  // Add an onload event to the iframe to modify links within it
  iframe.onload = function() {
    var linksInIframe = iframe.contentDocument.querySelectorAll('a');
    linksInIframe.forEach(function(link) {
      link.setAttribute('target', '_top'); // Sets the target of links in the iframe to "_top"
    });
  };

  container.appendChild(header);
  container.appendChild(iframe);

  var expander = document.querySelector('div.sc-6703147-0 button');
  expander.parentNode.insertBefore(container, expander.nextSibling);

  header.addEventListener('click', function() {
    if (iframe.style.display === 'none') {
      iframe.style.display = 'block'; // Shows the frame when clicking the header
    } else {
      iframe.style.display = 'none'; // Hides the frame when clicking the header again
    }
  });
})();