关于这个问题,可以通过插件管理功能实现。
插件代码:
- <div>
- <div>(() => {
- const PLUGIN_NAME = '隐藏-顶部更多入口-UAT';
- const hideNode = (node) => {
- if (!node || node.nodeType !== 1) return;
- node.style.setProperty('display', 'none', 'important');
- node.style.setProperty('pointer-events', 'none', 'important');
- node.setAttribute('data-hidden-by-plugin', PLUGIN_NAME);
- };
- const findClickableWrapper = (node, stopNode) => {
- let cur = node;
- let best = node;
- while (cur && cur !== stopNode && cur.nodeType === 1) {
- const rect = cur.getBoundingClientRect();
- const role = cur.getAttribute('role') || '';
- const cls = String(cur.className?.baseVal || cur.className || '');
- if (
- cur.tagName === 'BUTTON' ||
- role === 'button' ||
- cls.includes('tooltip') ||
- cls.includes('popover') ||
- typeof cur.onclick === 'function' ||
- rect.width <= 80
- ) {
- best = cur;
- }
- if (rect.width > 100 || rect.height > 80) break;
- cur = cur.parentElement;
- }
- return best;
- };
- const hideToolbarMore = () => {
- const toolbar = document.querySelector('[data-open="toolbar"]');
- if (!toolbar) return;
- const candidates = Array.from(toolbar.querySelectorAll('*')).filter((el) => {
- const text = (el.textContent || '').trim();
- const title = el.getAttribute('title') || '';
- const aria = el.getAttribute('aria-label') || '';
- const cls = String(el.className?.baseVal || el.className || '');
- const href = el.getAttribute('href') || el.getAttribute('xlink:href') || '';
- const name = el.getAttribute('name') || '';
- return (
- text === '更多' ||
- title === '更多' ||
- aria === '更多' ||
- name === 'tool' ||
- cls.includes('tool') ||
- href.includes('tool')
- );
- });
- candidates.forEach((el) => hideNode(findClickableWrapper(el, toolbar)));
- };
- const hideByOpenedApprovalPopup = () => {
- const approvalNode = Array.from(document.querySelectorAll('body *')).find((el) => {
- const text = (el.textContent || '').trim();
- return text === '审批中心';
- });
- if (!approvalNode) return;
- const toolbar = document.querySelector('[data-open="toolbar"]');
- if (!toolbar) return;
- const toolbarRect = toolbar.getBoundingClientRect();
- const toolbarItems = Array.from(toolbar.children)
- .filter((el) => {
- const rect = el.getBoundingClientRect();
- return rect.width > 0 && rect.height > 0 && rect.left >= toolbarRect.left;
- })
- .sort((a, b) => b.getBoundingClientRect().left - a.getBoundingClientRect().left);
- const likelyMore = toolbarItems.find((el) => {
- const text = el.textContent || '';
- const cls = String(el.className?.baseVal || el.className || '');
- return !text.includes('管理中心') && !cls.includes('user');
- });
- hideNode(likelyMore);
- };
- const apply = () => {
- hideToolbarMore();
- hideByOpenedApprovalPopup();
- console.log(`[${PLUGIN_NAME}] applied`);
- };
- const schedule = () => {
- apply();
- setTimeout(apply, 100);
- setTimeout(apply, 500);
- setTimeout(apply, 1500);
- setTimeout(apply, 3000);
- };
- if (document.readyState === 'loading') {
- document.addEventListener('DOMContentLoaded', schedule, { once: true });
- } else {
- schedule();
- }
- window.addEventListener('load', schedule);
- window.addEventListener('hashchange', schedule);
- window.addEventListener('popstate', schedule);
- document.addEventListener('mouseover', schedule, true);
- document.addEventListener('click', schedule, true);
- new MutationObserver(schedule).observe(document.documentElement, {
- childList: true,
- subtree: true,
- });
- })();</div>
- </div>
复制代码
插件管理介绍:https://docs.guandata.com/product/bi/575594549863251968
|