🎉 欢迎访问GreasyFork.Org 镜像站!本镜像站由公众号【爱吃馍】搭建,用于分享脚本。联系邮箱📮

Greasy fork 爱吃馍镜像

Bilibili 评论区隐藏

用于隐藏b站的评论区

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

🚀 安装遇到问题?关注公众号获取帮助

公众号二维码

扫码关注【爱吃馍】

回复【脚本】获取最新教程和防失联地址

// ==UserScript==
// @name         Bilibili 评论区隐藏
// @namespace    https://github.com/Ailzr/bilibili_comment_hide
// @version      0.1.3
// @description  用于隐藏b站的评论区
// @author       Ailzr
// @license      MIT
// @match        https://www.bilibili.com/video/*
// @match        https://www.bilibili.com/list/*
// @match        https://www.bilibili.com/bangumi/play/*
// @match        https://t.bilibili.com/*
// @match        https://www.bilibili.com/opus/*
// @match        https://space.bilibili.com/*
// @match        https://www.bilibili.com/v/topic/detail/*
// @match        https://www.bilibili.com/cheese/play/*
// @match        https://www.bilibili.com/festival/*
// @match        https://www.bilibili.com/blackboard/*
// @match        https://www.bilibili.com/blackroom/ban/*
// @match        https://www.bilibili.com/read/*
// @match        https://manga.bilibili.com/detail/*
// @match        https://www.bilibili.com/v/topic/detail*
// @icon         https://www.bilibili.com/favicon.ico
// @icon         https://www.bilibili.com/favicon.ico
// @grant        GM_setValue
// @grant        GM_getValue
// @grant        GM_addStyle
// ==/UserScript==

//按钮背景颜色,可自行调节
const bgcolor = "rgb(34,35,43)";
//按钮字体颜色,可自行调节
const fontColor = "#fff";

//获取评论区
function getComment(){
    return document.querySelector("div#commentapp");
}

//  显示/隐藏评论区 函数
function displayOrNotComment(){
    let comment = getComment();
    //将其隐藏或显示
    if (comment.style.display != "none"){
        comment.style.display = "none";
    }
    else {
        comment.style.display = "block";
    }
}

//创建 显示/隐藏 评论区按钮
function createButtonDisplayComment(){
    //创建按钮
    let button = document.createElement("button");

    button.innerText = "评";

    //给按钮添加样式
    button.style.position = "fixed";
    button.style.bottom = "20px";
    button.style.right = "0px";
    button.style.padding = "10px 20px";
    button.style.backgroundColor = bgcolor;
    button.style.color = fontColor;
    button.style.border = "none";
    button.style.borderRadius = "5px";
    button.style.cursor = "pointer";
    button.style.zIndex = "99";


    //给按钮添加监听事件
    button.addEventListener("click", displayOrNotComment);

    //将按钮添加到页面中
    document.body.appendChild(button);
}


function CloseCommentOfBilibili(){
    //获取评论区
    let getCmt = getComment();

    //如果成功获取到评论区元素
    if (getCmt){
        //将计时器暂停
        clearInterval(intervalId);
        //默认将评论区隐藏
        displayOrNotComment();
        //创建 显示/隐藏 评论区按钮
        createButtonDisplayComment();
    }
}

// 每隔0.1秒执行一次tryToGetElement函数
let intervalId = setInterval(CloseCommentOfBilibili, 100);