您需要先安装一个扩展,例如 篡改猴、Greasemonkey 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 暴力猴,之后才能安装此脚本。
您需要先安装一个扩展,例如 篡改猴 或 Userscripts ,之后才能安装此脚本。
您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey,才能安装此脚本。
您需要先安装用户脚本管理器扩展后才能安装此脚本。
Increase max-height by 400px for specific elements on Mintegral pages
// ==UserScript== // @name Mintegral Report Page Height Fix // @namespace http://tampermonkey.net/ // @version 1.4 // @description Increase max-height by 400px for specific elements on Mintegral pages // @author Grok // @match https://adv.mintegral.com/* // @grant none // @license GPL-3.0 License // ==/UserScript== (function() { 'use strict'; // 定义需要修改的选择器数组 const selectors = [ // 用户提供的 /campaigns 页面选择器 // 简化选择器,增加匹配可能性 '#__layout div.el-card.is-always-shadow > div > section.margin-top-4 > div > div.el-table.mtg_table.el-table--fluid-height', '#__layout div.el-card.is-always-shadow > div > section.margin-top-4 > div > div.el-table__body-wrapper', '#__layout div.el-card.is-always-shadow > div > section.margin-top-4 > div > div.el-table__fixed', // 通用选择器 'div.el-table--fluid-height', 'div.el-table.mtg_table', 'div.el-table__body-wrapper', 'div.el-table__fixed', 'div.el-table__fixed-body-wrapper' ]; // 默认高度(当元素无 max-height 时) const DEFAULT_HEIGHT = 900; // 默认设置为 900px // 增加的高度(单位:px) const HEIGHT_INCREMENT = 400; // 注入全局样式,防止样式覆盖 const style = document.createElement('style'); style.textContent = selectors.map(sel => `${sel} { max-height: none !important; height: auto !important; overflow-y: auto !important; }`).join('\n'); document.head.appendChild(style); // 修改高度的函数 function modifyHeight(element, selector) { if (element && !element.dataset.heightModified) { console.log(`Checking ${selector} at ${new Date().toISOString()}`); const computedStyle = window.getComputedStyle(element); let currentMaxHeight = computedStyle.maxHeight; if (currentMaxHeight && currentMaxHeight !== 'none' && currentMaxHeight.includes('px')) { const currentHeight = parseFloat(currentMaxHeight); const newHeight = currentHeight + HEIGHT_INCREMENT; element.style.maxHeight = `${newHeight}px !important`; element.dataset.heightModified = 'true'; console.log(`Modified max-height for ${selector}: ${currentMaxHeight} -> ${newHeight}px`); } else { element.style.maxHeight = `${DEFAULT_HEIGHT}px !important`; element.dataset.heightModified = 'true'; console.log(`Set max-height for ${selector} to ${DEFAULT_HEIGHT}px (no previous max-height)`); } // 确保高度自适应和滚动 element.style.height = 'auto !important'; element.style.overflowY = 'auto !important'; } } // 页面加载完成后执行 window.addEventListener('load', () => { console.log('Initial check at page load'); selectors.forEach(selector => { try { const element = document.querySelector(selector); if (element) { modifyHeight(element, selector); } else { console.warn(`Element not found for selector: ${selector}`); } } catch (error) { console.error(`Error processing selector ${selector}:`, error); } }); }); // 监听动态内容加载 const observer = new MutationObserver(() => { selectors.forEach(selector => { const element = document.querySelector(selector); modifyHeight(element, selector); }); }); observer.observe(document.body, { childList: true, subtree: true }); // 定时检查 setInterval(() => { console.log(`Periodic check at ${new Date().toISOString()}`); selectors.forEach(selector => { const element = document.querySelector(selector); modifyHeight(element, selector); }); }, 500); // 每0.5秒检查 // 延迟初始化,处理晚加载的元素 setTimeout(() => { console.log('Delayed check after 5 seconds'); selectors.forEach(selector => { const element = document.querySelector(selector); modifyHeight(element, selector); }); }, 5000); // 5秒后检查 // 额外延迟检查,处理超晚加载 setTimeout(() => { console.log('Delayed check after 10 seconds'); selectors.forEach(selector => { const element = document.querySelector(selector); modifyHeight(element, selector); }); }, 10000); // 10秒后检查 })();