// ==UserScript== // @name 虎牙页面优化 // @namespace http://tampermonkey.net/ // @version 2024-04-22 // @description 虎牙精简版,移除首页直播页面,移除直播业礼物特效等不必要元素,还你纯粹的直播体验 // @author You // @match https://www.huya.com/* // @icon https://www.google.com/s2/favicons?sz=64&domain=huya.com // @grant none // @license MIT // @downloadURL none // ==/UserScript== (function () { 'use strict'; main(); })(); function main() { /// 首页 (function () { if (location.href !== 'https://www.huya.com/') return; // 侧边广告栏 document.querySelector('.helper-download--2aVciFs8labxRcCYbQbecp')?.remove(); setTimeout(() => { document.querySelector('.helper-nav--1yz7uIycIDu_3rI5oz1pJr') ?.querySelector('.nav-item--XUUXqbSUAscPL7VU5EnMq')?.remove(); }, 2000); // 顶部导航与直播推荐 document.querySelector('#duya-header').style.backgroundColor = 'rgb(167 167 167)'; const banner = document.querySelector('#banner'); banner.innerHTML = ''; $(banner).css({ 'position': 'inherit', 'height': '60px', 'background-image': 'url()', 'background-color': '#ffffff' }); // 暂停直播 document.querySelector('#player-btn').click(); // 移除直播 document.querySelector('.mod-index-main')?.remove(); })(); // 直播页 (function () { if (location.href === 'https://www.huya.com/') return; $(document.querySelector('#J_mainWrap')).css({ 'padding-left': '0px', 'display': 'flex', 'justify-content': 'center', 'align-items': 'center' }); document.querySelector('.mod-sidebar')?.remove(); const main = document.querySelector('#main_col'); // const videoBox = main.querySelector('.room-core-l'); const videoBox = main.querySelector('#J_mainRoom'); // 净化直播容器 const core = videoBox.querySelector('.room-core'); videoBox.replaceChildren(core); // 移除右侧弹幕 core.replaceChildren(core.querySelector('.room-core-l')); // 净化主容器 main.replaceChildren(videoBox); videoBox.style.margin = 0; const a = document.querySelector('.host-control.J_roomHdCtrl'); a.replaceChildren(a.querySelector('.subscribe-entrance')); })(); }