IMDb Full Summary

Automatically show the full plot summary on IMDb

当前为 2023-11-12 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb Full Summary
  3. // @description Automatically show the full plot summary on IMDb
  4. // @author chocolateboy
  5. // @copyright chocolateboy
  6. // @version 3.0.3
  7. // @namespace https://github.com/chocolateboy/userscripts
  8. // @license GPL
  9. // @include https://www.imdb.com/title/tt*
  10. // @run-at document-start
  11. // @grant none
  12. // ==/UserScript==
  13.  
  14. // NOTE This file is generated from src/imdb-full-summary.user.ts and should not be edited directly.
  15.  
  16. "use strict";
  17. (() => {
  18. // src/imdb-full-summary.user.ts
  19. // @license GPL
  20. var $ = document;
  21. var init = { childList: true };
  22. var run = () => {
  23. let summary = "";
  24. try {
  25. const { textContent: metadata } = $.getElementById("__NEXT_DATA__");
  26. summary = JSON.parse(metadata).props.pageProps.aboveTheFoldData.plot.plotText.plainText;
  27. } catch (e) {
  28. console.warn("Can't extract summary from JSON metadata:", e.message);
  29. }
  30. if (!summary) {
  31. return;
  32. }
  33. for (const target of $.querySelectorAll('[data-testid="plot"] [data-testid^="plot-"]')) {
  34. const callback = () => {
  35. observer.disconnect();
  36. target.textContent = summary;
  37. observer.observe(target, init);
  38. };
  39. const observer = new MutationObserver(callback);
  40. callback();
  41. }
  42. };
  43. $.addEventListener("readystatechange", run, { once: true });
  44. })();