Greasy Fork

Greasy Fork is available in English.

Huya Styles

update huya styles

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

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

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

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

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

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

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

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

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

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

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

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

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

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

// ==UserScript==
// @name         Huya Styles
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  update huya styles
// @author       You
// @match        *://www.huya.com/*
// @match        *://huya.com/*
// @icon         https://www.google.com/s2/favicons?sz=64&domain=huya.com
// @grant        none
// @license      MIT
// ==/UserScript==

function repeat(handler, times) {
    let count = 0;

    handler();

    const interval = setInterval(() => {
        handler();
        count++;

        if (count > times) {
           clearInterval(interval);
        }
    }, 60);
}

function deleteElements(selectors) {
    selectors.map(selector => {
        try {
            document.querySelector(selector).style.display = 'none';
        } catch (err) {
            // do noting
        }
    });
}

function setStyles(elements) {
    elements.map(([selector, key, value]) => {
        try {
            document.querySelector(selector).style[key] = value;
        } catch (err) {
            // do noting
        }
    });

}

function init() {
    deleteElements([
        '.mod-sidebar',
        '.hy-nav-item-youliao.hy-nav-item',
        '.wrap-ext.chat-wrap-panel',
        '.diy-comps-wrap',
        '#player-mouse-event-wrap',
        '.J_comp_2.diy-comp',
        '.dot--g92BzaqFUtbPTJytM_job.NavItem--1jr9x80QTPbnrDwqn834hF',
        '#duya-header-logo',
        '.player-gift-wrap',
    ]);

    setStyles([
        ["#main_col", "paddingTop", "32px"],
        ["#J_mainRoom", "minWidth", "0px"],
    ]);
}

(function() {
    'use strict';

    repeat(init, 100);
})();