// ==UserScript== // @name 乐魂_巨量千川助手 // @namespace http://tampermonkey.net/ // @version 0.1 // @description 修改浏览器显示标题为账户名称并屏蔽特定界面元素 // @author Your name // @match *://qianchuan.jinritemai.com/promotion-v2/* // @grant none // @downloadURL none // ==/UserScript== (function() { 'use strict'; // 添加CSS样式来屏蔽元素 function addStyles() { const style = document.createElement('style'); style.textContent = ` /* 顶部警告横幅 - 完整路径 */ #app > div > div.app-content > div:nth-child(4) > div.notice-container > div.oc-banner-tip.oc-banner-tip-warning, /* 导航栏右侧工具第二个元素 */ #navigator-right-tool > div:nth-child(2), /* 品牌推广标题 */ #firstTitle_brand_promotion, /* 右侧浮动栏中的活动入口 */ #app > div > div.app-content > div.float-bar-vmok.effect-entry-wrapper > div > div.float-bar-item.activity-item { display: none !important; } /* 修改浮动栏位置 */ .float-bar-vmok.effect-entry-wrapper { top: 753px !important; } `; document.head.appendChild(style); } // 修改页面标题 function changeTitle() { const accountNameElement = document.querySelector("#navigator-right-account > div > div > span > div > div.account-info-box > div:nth-child(1)"); if (accountNameElement) { const accountName = accountNameElement.textContent.trim(); if (accountName) { document.title = accountName; } } } // 初始化函数 function init() { // 添加样式 addStyles(); // 首次尝试更改标题 changeTitle(); // 设置一个定时器,在页面加载后继续尝试 const titleCheckInterval = setInterval(() => { const accountNameElement = document.querySelector("#navigator-right-account > div > div > span > div > div.account-info-box > div:nth-child(1)"); if (accountNameElement) { changeTitle(); clearInterval(titleCheckInterval); // 设置 MutationObserver 来监听标题变化 const observer = new MutationObserver((mutations) => { const currentAccountName = accountNameElement.textContent.trim(); if (document.title !== currentAccountName) { changeTitle(); } }); // 配置观察器 const config = { subtree: true, childList: true, characterData: true }; // 开始观察 document.head 和账户名称元素 observer.observe(document.head, config); observer.observe(accountNameElement, config); } }, 1000); // 每秒检查一次 // 30秒后停止检查,避免无限循环 setTimeout(() => { clearInterval(titleCheckInterval); }, 30000); } // 启动初始化 init(); })();