// ==UserScript== // @name bilibili直播净化 // @namespace https://github.com/lzghzr/GreasemonkeyJS // @version 3.0.2 // @author lzghzr // @description 屏蔽聊天室礼物以及关键字, 净化聊天室环境 // @supportURL https://github.com/lzghzr/GreasemonkeyJS/issues // @include /^https?:\/\/live\.bilibili\.com\/(neptune\/)?\d.*$/ // @license MIT // @grant GM_getValue // @grant GM_setValue // @run-at document-end // @downloadURL none // ==/UserScript== "use strict"; var BiLiveNoVIP = (function () { function BiLiveNoVIP() { this._counter = 0; this._defaultConfig = { version: 1509943778469, menu: { noKanBanMusume: { name: '看 板 娘', enable: false }, noGuardIcon: { name: '舰队标识', enable: false }, noHDIcon: { name: '活动标识', enable: false }, noVIPIcon: { name: '老爷标识', enable: false }, noMedalIcon: { name: '粉丝勋章', enable: false }, noUserLevelIcon: { name: '用户等级', enable: false }, noLiveTitleIcon: { name: '成就头衔', enable: false }, noSystemMsg: { name: '系统公告', enable: false }, noGiftMsg: { name: '礼物信息', enable: false } } }; var config = JSON.parse(GM_getValue('blnvConfig') || '{}'); var defaultConfig = this._defaultConfig; if (config.version === undefined || config.version < defaultConfig.version) { for (var x in defaultConfig.menu) { try { defaultConfig.menu[x].enable = config.menu[x].enable; } catch (error) { console.error(error); } } this._config = defaultConfig; } else { this._config = config; } } BiLiveNoVIP.prototype.Start = function () { var _this = this; this._AddCSS(); this._ChangeCSS(); var elmDivAside = document.querySelector('.aside-area'); if (elmDivAside != null) { var asideObserver_1 = new MutationObserver(function (mutations) { mutations.forEach(function (mutation) { if (mutation.type === 'childList' && mutation.addedNodes != null) { for (var i = 0; i < mutation.addedNodes.length; i++) { var elm = mutation.addedNodes[i]; if (elm.nodeName === 'LI' && elm.innerText === '七日榜') { _this._counter += 1; elm.click(); } if (elm.nodeName === 'DIV' && elm.id === 'chat-control-panel-vm') { _this._counter += 1; _this._AddUI(); } } } }); if (_this._counter >= 2) asideObserver_1.disconnect(); }); asideObserver_1.observe(elmDivAside, { childList: true, subtree: true }); } var bodyObserver = new MutationObserver(function () { var elmDivRand = document.querySelector('#rank-list-vm'), elmDivChat = document.querySelector('.chat-history-panel'); if (document.body.classList.contains('player-full-win')) { elmDivRand.style.cssText = 'display: none'; elmDivChat.style.cssText = 'height: calc(100% - 135px)'; } else { elmDivRand.style.cssText = ''; elmDivChat.style.cssText = ''; } }); bodyObserver.observe(document.body, { attributes: true, attributeFilter: ['class'] }); }; BiLiveNoVIP.prototype._ChangeCSS = function () { var elmStyle = document.querySelector('#gunCSS'); if (elmStyle === null) { elmStyle = document.createElement('style'); elmStyle.id = 'gunCSS'; document.body.appendChild(elmStyle); } var cssText = ''; if (this._config.menu.noKanBanMusume.enable) cssText += "\n.haruna-sekai-de-ichiban-kawaii {\n display: none !important;\n}"; if (this._config.menu.noGuardIcon.enable) cssText += "\n.chat-history-list .guard-buy,\n.chat-history-list .guard-icon,\n.chat-history-list .welcome-guard,\n.chat-history-list .danmaku-item.guard-level-1:after,\n.chat-history-list .danmaku-item.guard-level-2:after,\n.chat-history-list .danmaku-item.guard-level-1:before,\n.chat-history-list .danmaku-item.guard-level-2:before {\n display: none !important;\n}\n.chat-history-list .danmaku-item.guard-danmaku .vip-icon {\n margin-right: 5px !important;\n}\n.chat-history-list .danmaku-item.guard-danmaku .admin-icon,\n.chat-history-list .danmaku-item.guard-danmaku .title-label,\n.chat-history-list .danmaku-item.guard-danmaku .anchor-icon,\n.chat-history-list .danmaku-item.guard-danmaku .user-level-icon,\n.chat-history-list .danmaku-item.guard-danmaku .fans-medal-item-ctnr {\n margin-right: 5px !important;\n}\n.chat-history-list .danmaku-item.guard-level-1,\n.chat-history-list .danmaku-item.guard-level-2 {\n padding: 4px 5px !important;\n margin: 0 !important;\n}\n.chat-history-list .danmaku-item.guard-danmaku .user-name {\n color: #23ade5 !important;\n}\n.chat-history-list .danmaku-item.guard-danmaku .danmaku-content {\n color: #646c7a !important;\n}"; if (this._config.menu.noHDIcon.enable) cssText += "\n.chat-history-list a[href^=\"/hd/\"],\n#santa-hint-ctnr {\n display: none !important;\n}"; if (this._config.menu.noVIPIcon.enable) cssText += "\n.chat-history-list .vip-icon,\n.chat-history-list .welcome-msg {\n display: none !important;\n}"; if (this._config.menu.noMedalIcon.enable) cssText += "\n.chat-history-list .fans-medal-item-ctnr {\n display: none !important;\n}"; if (this._config.menu.noUserLevelIcon.enable) cssText += "\n.chat-history-list .user-level-icon {\n display: none !important;\n}"; if (this._config.menu.noLiveTitleIcon.enable) cssText += "\n.chat-history-list .title-label {\n display: none !important;\n}"; if (this._config.menu.noSystemMsg.enable) cssText += "\n.bilibili-live-player-video-gift,\n.chat-history-list .system-msg {\n display: none !important;\n}"; if (this._config.menu.noGiftMsg.enable) cssText += "\n.chat-history-list .gift-item,\n.bilibili-live-player-danmaku-gift,\n.chat-history-panel .penury-gift-msg,\n.haruna-sekai-de-ichiban-kawaii .super-gift-bubbles {\n display: none !important;\n}\n.chat-history-list.with-penury-gift {\n height: 100% !important;\n}"; elmStyle.innerHTML = cssText; }; BiLiveNoVIP.prototype._AddUI = function () { var _this = this; var elmDivBtns = document.querySelector('.btns, .icon-left-part'), elmDivGun = document.createElement('div'), elmDivMenu = document.createElement('div'), html = ''; elmDivGun.id = 'gunBut'; elmDivMenu.id = 'gunMenu'; elmDivMenu.className = 'gunHide'; for (var x in this._config.menu) { html += "\n