LibLib图例宽屏化

Force adjust modal width on liblib.art

  1. // ==UserScript==
  2. // @name LibLib图例宽屏化
  3. // @namespace http://tampermonkey.net/
  4. // @version 1.1
  5. // @description Force adjust modal width on liblib.art
  6. // @author 云浩同学
  7. // @match https://www.liblib.art/*
  8. // @license MIT
  9. // ==/UserScript==
  10.  
  11. (function () {
  12. 'use strict';
  13.  
  14.  
  15. document.addEventListener('mouseup', function (e) {
  16. if (e.button === 1) {
  17. let target = e.target;
  18.  
  19. while (target && target.getAttribute('role') !== 'gridcell') {
  20. target = target.parentElement;
  21. }
  22.  
  23. if (target) {
  24. e.preventDefault();
  25. const link = target.querySelector('a');
  26. if (link && link.href) {
  27. window.open(link.href, '_blank');
  28. }
  29. }
  30. }
  31. }, true);
  32.  
  33.  
  34. document.addEventListener('mousedown', function (e) {
  35. if (e.button === 1) {
  36. let target = e.target;
  37.  
  38. while (target && target.getAttribute('role') !== 'gridcell') {
  39. target = target.parentElement;
  40. }
  41.  
  42. if (target) {
  43. e.preventDefault();
  44. return false;
  45. }
  46. }
  47. }, true);
  48.  
  49.  
  50. function forceAdjustModalWidth() {
  51. // 最外层弹窗容器
  52. const modalSection = document.querySelector('.mantine-Paper-root.mantine-Modal-content');
  53. if (modalSection) {
  54. modalSection.style.setProperty('min-width', '90%', 'important');
  55. modalSection.style.setProperty('max-width', '1400px', 'important');
  56. modalSection.style.setProperty('margin', '0 auto', 'important');
  57.  
  58. // 中间主容器
  59. const middleContainer = document.querySelector('.w-\\[820px\\].bg-background.mantine-Modal-body');
  60. if (middleContainer) {
  61. middleContainer.style.setProperty('width', '100%', 'important');
  62. middleContainer.classList.remove('w-[820px]');
  63. }
  64.  
  65. // 左侧整体容器
  66. const leftMainContainer = document.querySelector('.w-80.inline-block');
  67. if (leftMainContainer) {
  68. leftMainContainer.style.setProperty('width', '50%', 'important');
  69. leftMainContainer.classList.remove('w-80');
  70. }
  71.  
  72. // 左侧图片外层容器
  73. const leftImageWrapper = document.querySelector('.group.relative.overflow-hidden.w-\\[328px\\]');
  74. if (leftImageWrapper) {
  75. leftImageWrapper.style.setProperty('width', '100%', 'important');
  76. leftImageWrapper.classList.remove('w-[328px]');
  77. }
  78.  
  79. // 图片显示容器 -选择器
  80. const imageContainer = document.querySelector('.flex.items-center.justify-center[style*="width: 320px"]');
  81. if (imageContainer) {
  82. const currentStyle = imageContainer.getAttribute('style');
  83. const newStyle = currentStyle.replace('width: 320px', 'width: 100%');
  84. imageContainer.setAttribute('style', newStyle);
  85. }
  86.  
  87.  
  88. const leftButton = document.querySelector('.flex.items-center.justify-center.absolute.z-10.top-\\[17px\\].left-\\[245px\\]');
  89. const rightButton = document.querySelector('.flex.items-center.justify-center.absolute.z-10.top-\\[17px\\].right-3');
  90.  
  91. if (leftButton && rightButton) {
  92.  
  93. rightButton.style.cssText += `
  94. right: 10px !important;
  95. left: auto !important;
  96. top: 17px !important;
  97. position: absolute !important;
  98. `;
  99.  
  100.  
  101. leftButton.style.cssText += `
  102. right: 58px !important;
  103. left: auto !important;
  104. top: 17px !important;
  105. position: absolute !important;
  106. `;
  107. }
  108.  
  109.  
  110. // 右侧容器
  111. const rightContainer = document.querySelector('.align-top.ml-\\[18px\\].inline-block.w-\\[434px\\]');
  112. if (rightContainer) {
  113. rightContainer.style.setProperty('width', '50%', 'important');
  114. rightContainer.style.setProperty('margin-left', '0', 'important');
  115. rightContainer.classList.remove('w-[434px]');
  116. }
  117. }
  118. }
  119.  
  120. let timeoutId;
  121. const observer = new MutationObserver(() => {
  122. clearTimeout(timeoutId);
  123. timeoutId = setTimeout(forceAdjustModalWidth, 100);
  124. });
  125.  
  126. observer.observe(document.body, {
  127. childList: true,
  128. subtree: true,
  129. attributes: true,
  130. attributeFilter: ['style', 'class']
  131. });
  132.  
  133. forceAdjustModalWidth();
  134. })();

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址