IMDb you may know them from

Adds a frame with movies I have already seen

当前为 2024-01-05 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 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.4
// @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 = 'You may know them from (click to expand/collapse)';
  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 = '120%';
  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 targetElement = document.querySelector('div.ipc-chip-list--base');

//var targetElement = document.querySelector('div.ipc-chip-list__scroller');
  // Check if the target element exists before inserting the iframe
  if (targetElement) {
    targetElement.parentNode.insertBefore(container, targetElement);

    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
      }
    });
  } else {
    // If the expected element doesn't exist, you can choose an alternative way to insert the iframe or handle the case accordingly.
    console.log('The expected element does not exist on this page.');
  }
})();