IMDb fullscreen imageviewer

Fix the new layout to make it look more like the old design. Display old & new layout fullscreen.

当前为 2020-07-17 提交的版本,查看 最新版本

  1. // ==UserScript==
  2. // @name IMDb fullscreen imageviewer
  3. // @namespace https://github.com/Procyon-b
  4. // @version 0.2
  5. // @description Fix the new layout to make it look more like the old design. Display old & new layout fullscreen.
  6. // @author Achernar
  7. // @match https://www.imdb.com/*/mediaviewer/*
  8. // @run-at document-start
  9. // @grant none
  10. // ==/UserScript==
  11.  
  12. (function() {
  13. "use strict";
  14.  
  15. var st=document.createElement("style");
  16. st.textContent='.mediaviewer__head-banner:not(.media-viewer__action-bar) {height: 0;} .mediaviewer__head-banner + div > div {height: calc(100% + 65px) !important;} nav, footer, button[aria-label="Open"] {display: none !important;} div[data-testid="media-viewer"] {height: 100vh !important;} .media-viewer__action-bar {position: absolute; left: 0; z-index: 10; background:rgba(20, 20, 20, 0.85); border-bottom: 1px solid rgba(255,255,255,0.2);}';
  17. document.head.appendChild(st);
  18.  
  19. function init(){
  20. window.dispatchEvent(new MouseEvent('resize'));
  21. var ms=document.querySelector('[data-testid="media-sheet"]'),
  22. ab=document.querySelector('[data-testid="action-bar"]');
  23. if (!ms || !ab) return;
  24. var obs=new MutationObserver(function(muts){
  25. for (let mut of muts) {
  26. if (mut.attributeName!='aria-hidden') continue;
  27. let t=mut.target;
  28. if (!t || !(t.tagName=='DIV' && t.className.includes('MediaPanel')) ) continue;
  29. ab.style.display= t.style.visibility=='hidden' ? 'none' : '';
  30. }
  31. });
  32.  
  33. obs.observe(ms.closest('[data-testid="media-viewer"]'),
  34. {attributes: true, childList: false, subtree: true});
  35. }
  36. if (document.readyState != 'loading') init();
  37. else document.addEventListener('DOMContentLoaded', init);
  38.  
  39. })();