Bilibili-Evolved/registry/dist/components/video/danmaku/expand.js
github-actions[bot] dbbffa1321 CI build
2022-09-17 09:11:50 +00:00

1 line
1.9 KiB
JavaScript

!function(e,n){"object"==typeof exports&&"object"==typeof module?module.exports=n():"function"==typeof define&&define.amd?define([],n):"object"==typeof exports?exports["video/danmaku/expand"]=n():e["video/danmaku/expand"]=n()}(self,(function(){return function(){"use strict";var e={d:function(n,t){for(var o in t)e.o(t,o)&&!e.o(n,o)&&Object.defineProperty(n,o,{enumerable:!0,get:t[o]})},o:function(e,n){return Object.prototype.hasOwnProperty.call(e,n)}},n={};e.d(n,{component:function(){return r}});var t=coreApis.observer,o=coreApis.spinQuery,a=coreApis.utils,i=coreApis.utils.log,s=coreApis.utils.urls;const r={name:"expandDanmakuList",displayName:"展开弹幕列表",entry:async e=>{let{settings:{options:n}}=e;const r=(0,i.useScopedConsole)("展开弹幕列表");(0,t.videoChange)((async()=>{if(s.mediaListUrls.some((e=>(0,a.matchUrlPattern)(e)))&&n.ignoreMediaList)return;const e=await(async()=>{const e=await(0,o.select)(".bilibili-player-video-info-danmaku-number, .bpx-player-video-info-dm"),n=((null==e?void 0:e.textContent)??"").match(/\d+/);if(!n)return null;const t=parseInt(n[0]);return Number.isNaN(t)?null:t})();if(r.log(`当前弹幕量: ${e}`),null!==e&&e>n.maxDanmakuCount)return void r.log(`超过了最大弹幕数量 ${n.maxDanmakuCount}, 跳过展开`);const t=await(0,o.select)(".bui-collapse-wrap");if(t&&t.classList.contains("bui-collapse-wrap-folded")){const e=await(0,o.select)(".bui-collapse-header");null==e||e.click()}}))},tags:[componentsTags.video],description:{"zh-CN":"每次加载视频时自动展开弹幕列表, 如果弹幕装载量超过 `最大弹幕数量`, 则不展开以免对页面造成卡顿."},options:{ignoreMediaList:{defaultValue:!0,displayName:"合集类页面不自动展开"},maxDanmakuCount:{defaultValue:500,displayName:"最大弹幕数量"}},urlInclude:[...s.videoAndBangumiUrls,...s.mediaListUrls],commitHash:"4244557c2d4e7006e134441db6a1a23e0d6e00cf",coreVersion:"2.4.0"};return n=n.component}()}));