// ==UserScript== // @name 设置大会员弹幕 // @version 1.0.0 // @description 设置大会员弹幕 // @author 错过-Miss & qianxu & monkey // @match https://www.bilibili.com/video/* // @match https://www.bilibili.com/list/* // @match https://www.bilibili.com/bangumi/play/* // @icon https://www.bilibili.com/favicon.ico // @namespace https://space.bilibili.com/266986139 // @grant GM_getValue // @grant GM_setValue // @grant GM_deleteValue // @grant GM_registerMenuCommand // @require https://cdn.jsdelivr.net/npm/vue@3.3.4/dist/vue.global.prod.js // ==/UserScript== ; (function() { 'use strict' // 读取配置_0 const offVipDm = GM_getValue('offVipDm') // 是否彻底屏蔽大会员彩色弹幕 const playerProfile = localStorage.getItem('bpx_player_profile') // 播放器配置 // 读取配置_1 const blockVipDm = GM_getValue('blockVipDm') // 是否彻底屏蔽大会员彩色弹幕 // 读取配置_2 const SetVipDm = GM_getValue('SetVipDm') // 是否彻底屏蔽大会员彩色弹幕 // 注册菜单_0 GM_registerMenuCommand(`${offVipDm ? '✅' : '☑️'} 置其普通大会员彩色弹幕`, () => { if (offVipDm) { GM_deleteValue('offVipDm') } else { GM_setValue('offVipDm', true) GM_deleteValue('blockVipDm') } location.reload() }) // 注册菜单_1 GM_registerMenuCommand(`${blockVipDm ? '✅' : '☑️'} 彻底屏蔽大会员彩色弹幕`, () => { if (blockVipDm) { GM_deleteValue('blockVipDm') } else { GM_setValue('blockVipDm', true) GM_deleteValue('offVipDm') } location.reload() }) // 注册菜单_2 GM_registerMenuCommand(`${SetVipDm ? '✅' : '☑️'} 全部成为大会员彩色弹幕`, () => { if (SetVipDm) { GM_deleteValue('SetVipDm') } else { GM_setValue('SetVipDm', true) } location.reload() }) // 配置样式 let strokeType = 0 // 描边类型,默认为重墨 // 判断是否有播放器配置,有则读取用户设置的描边类型 if (playerProfile) { strokeType = JSON.parse(playerProfile) .dmSetting.fontborder } let textShadow = '' // 文本阴影 // 根据描边类型设置文本阴影 switch (strokeType) { case 1: // 描边 textShadow = '0px 0px 1px #000000, 0 0 1px #000000, 0 0 1px #000000' break case 2: // 45° 投影 textShadow = '1px 1px 2px #000000, 0 0 1px #000000' break default: // 重墨 textShadow = '1px 0 1px #000000, 0 1px 1px #000000, 0 -1px 1px #000000, -1px 0 1px #000000' } // 创建样式元素 const styleElement = document.createElement('style') // 判断是否彻底屏蔽大会员彩色弹幕 if (blockVipDm) { /* 配置样式元素 bili-dm-vip: 屏蔽大会员彩色弹幕 */ styleElement.innerHTML = ` .bili-dm-vip { display: none; } ` } if (offVipDm) { /* 配置样式元素 1. bili-dm: 补上大会员彩色弹幕缺失的描边 2. bili-dm-vip: 移除大会员彩色弹幕的彩色背景图片,并继承父元素的描边 */ styleElement.innerHTML = ` .bili-dm { --textShadow: ${textShadow}; } .bili-dm-vip { background-image: none !important; text-shadow: inherit !important; } ` } // 将样式元素添加到页面中 document.body.appendChild(styleElement) // 判断是否全部成为大会员彩色弹幕 if (SetVipDm) { (e => { const t = document.createElement("style"); t.dataset.source = "vite-plugin-monkey", t.textContent = e, document.head.append(t) })(" .bpx-player-row-dm-wrap .bili-dm{background:url(http://i0.hdslb.com/bfs/dm/b4f545290caf5a90bd9a96c8d4edefd09bca79bc.png);text-shadow:none;background-clip:text;color:#fff;text-fill-color:#FFFFF;text-stroke:4px transparent;-webkit-background-clip:text;-webkit-text-fill-color:#FFFFF;-webkit-text-stroke:2px transparent;-moz-background-clip:text;-moz-text-fill-color:#FFFFF;-moz-text-stroke:4px transparent;-ms-background-clip:text;-ms-text-fill-color:#FFFFF;-ms-text-stroke:4px transparent}.bpx-player-row-dm-wrap .bili-dm *{background:none!important} "); (function(vue) { const _export_sfc = (sfc, props) => { const target = sfc.__vccOpts || sfc; for (const [key, val] of props) { target[key] = val; } return target; }; const _sfc_main = {}; function _sfc_render(_ctx, _cache) { return null; } const App = /* @__PURE__ */ _export_sfc(_sfc_main, [ ["render", _sfc_render] ]); vue.createApp(App) .mount( (() => { const app = document.createElement("div"); document.body.append(app); return app; })() ); })(Vue); } })()