Greasy Fork

Greasy Fork is available in English.

极简虎牙界面

极简虎牙界面,自动切换到最高清晰度画质,移除各种广告弹窗

当前为 2022-08-12 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         极简虎牙界面
// @namespace    http://tampermonkey.net/
// @version      1.0.0
// @description  极简虎牙界面,自动切换到最高清晰度画质,移除各种广告弹窗
// @author       You
// @match        https://www.huya.com/*
// @icon         https://www.google.com/s2/favicons?domain=huya.com
// @grant        none
// @license MIT
// ==/UserScript==
  // player-videotype-list
  // player-box-stat3
(function() {
  'use strict';

  // 移除广告弹窗
  const removeAds = () => {
    const removeNodes = []
    if (document.querySelectorAll('.room-gg-chat')[0]) {
      removeNodes.push(document.querySelectorAll('.room-gg-chat')[0])
    }
    if (document.querySelectorAll('.room-mod-ggTop')[0]) {
      removeNodes.push(document.querySelectorAll('.room-mod-ggTop')[0])
    }
    // 移除所有的iframe
    document.querySelectorAll('iframe').forEach(iframe => iframe.remove())
    for(const node of removeNodes) {
      node.remove()
    }
  }

  setInterval(() => {
    removeAds()
  }, 1000);

  // 移除不必要的页面元素
  const removeNodesFunc = (nodes) => {
    nodes.forEach(node => {
      document.querySelector(node)?.remove()
    })
  }

  setTimeout(() => {
    const ul = document.querySelector('.player-videotype-list')
    const unuseTool = [
      '.player-gift-right',
      '#player-face',
      '#week-star-btn',
      '#diy-pet-icon',
      '.room-footer',
      '.mod-sidebar',
      '#diy-activity-icon-13889',
      '#front-4a0mhq51_web_video_com',
      '#diy-activity-icon-9557',
      '.player-arrow-down',
    ]
    if (ul) {
      const firstLi = ul.firstElementChild
      // 切换到最高清画质
      firstLi.click()
      setTimeout(() => {
        document.querySelector('.more-attivity-panel').setAttribute('style', 'left: -64px !important; width: 240px !important;')
        removeNodesFunc(unuseTool)
      }, 1000);
    }
  }, 1000);

})();