Bilibili-Evolved/registry/dist/components/video/player/show-upload-time.js
github-actions[bot] 9ce5fa256b
Some checks failed
Build / build (push) Has been cancelled
CI build
2025-07-23 12:16:39 +00:00

9 lines
8.7 KiB
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["video/player/show-upload-time"]=t():e["video/player/show-upload-time"]=t()}(globalThis,(()=>(()=>{var e,t,o={524:(e,t,o)=>{var n=o(955)((function(e){return e[1]}));n.push([e.id,".video-page-card .card-box .info .count.up {\n white-space: pre !important;\n display: flex !important;\n height: auto !important;\n}\n\n.video-page-card-small .card-box .info .upname {\n height: auto !important;\n}\n.video-page-card-small .card-box .info .upname a .name {\n -webkit-line-clamp: unset !important;\n white-space: pre !important;\n}\n\n.video-page-operator-card-small .card-box .info .upname {\n height: auto !important;\n}\n.video-page-operator-card-small .card-box .info .upname a .name {\n -webkit-line-clamp: unset !important;\n white-space: pre !important;\n}\n\n.recommend-video-card .card-box .info .upname {\n height: auto !important;\n}\n.recommend-video-card .card-box .info .upname .name {\n -webkit-line-clamp: unset !important;\n white-space: pre !important;\n}",""]),e.exports=n},955:e=>{"use strict";
// eslint-disable-next-line func-names
e.exports=function(e){var t=[];return t.toString=function(){return this.map((function(t){var o=e(t);return t[2]?"@media ".concat(t[2]," {").concat(o,"}"):o})).join("")},
// eslint-disable-next-line func-names
t.i=function(e,o,n){"string"==typeof e&&(
// eslint-disable-next-line no-param-reassign
e=[[null,e,""]]);var i={};if(n)for(var r=0;r<this.length;r++){
// eslint-disable-next-line prefer-destructuring
var a=this[r][0];null!=a&&(i[a]=!0)}for(var s=0;s<e.length;s++){var l=[].concat(e[s]);n&&i[l[0]]||(o&&(l[2]?l[2]="".concat(o," and ").concat(l[2]):l[2]=o),t.push(l))}},t}},674:(e,t,o)=>{var n=o(524);n&&n.__esModule&&(n=n.default),e.exports="string"==typeof n?n:n.toString()}},n={};function i(e){var t=n[e];if(void 0!==t)return t.exports;var r=n[e]={id:e,exports:{}};return o[e](r,r.exports,i),r.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,i.t=function(o,n){if(1&n&&(o=this(o)),8&n)return o;if("object"==typeof o&&o){if(4&n&&o.__esModule)return o;if(16&n&&"function"==typeof o.then)return o}var r=Object.create(null);i.r(r);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&n&&o;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>a[e]=()=>o[e]));return a.default=()=>o,i.d(r,a),r},i.d=(e,t)=>{for(var o in t)i.o(t,o)&&!i.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var r={};return(()=>{"use strict";i.d(r,{component:()=>g});const e=coreApis.componentApis.define,t=coreApis.observer,o=coreApis.utils,n=coreApis.utils.urls,a=coreApis.utils.log,s=coreApis.settings,l=(e,t,o)=>{const n={"M+":e.getMonth()+1,"d+":e.getDate(),"h+":e.getHours(),"m+":e.getMinutes(),"s+":e.getSeconds(),"q+":Math.floor((e.getMonth()+3)/3)},i={up:o,"\\\\r":"\r","\\\\n":"\n","\\\\t":"\t"};let r=t.match(/(y+)/);null!==r&&(t=t.replace(r[0],`${e.getFullYear()}`.substring(4-r[0].length)));for(const e in n)e&&(r=t.match(new RegExp(`(${e})`)),null!==r&&(t=t.replace(r[0],1===r[0].length?n[e]:`00${n[e]}`.substring(`${n[e]}`.length))));for(const e in i)e&&(r=t.match(new RegExp(`(${e})`)),null!==r&&(t=t.replace(r[0],i[e])));return t},c=coreApis.componentApis.video.videoInfo;function d(e,t,o){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class m{constructor(e){var t=this;d(this,"console",void 0),d(this,"metadata",void 0),d(this,"videoClasses",["video-page-operator-card-small","video-page-card-small"]),d(this,"showUploadTime",(function(e){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!n){const{options:e}=(0,s.getComponentSettings)(t.metadata.name);n=e.formatString?.toString()}e.forEach((async e=>{let t=e.name;if(o||!e.item.owner.mark){if(e.item.owner.mark=!0,o||!e.mark){if(e.mark=!0,!e.item.pubdate){const t=new c.VideoInfo(e.item.aid);await t.fetchInfo(),e.item.pubdate=t.pubdate}const o=new Date(1e3*e.item.pubdate);e.oldname||(e.oldname=e.name),t=l(o,n,e.oldname),e.name=t}e.item.owner.name=t}}))})),d(this,"getRecoList",(()=>{let e=dq("#reco_list");null==e&&(e=dq(".recommend-list-v1"));let t=(0,o.getVue2Data)(e);return void 0===t.isOpen&&(t=t.$children[0],void 0===t.isOpen&&(this.console.log("结构获取失败"),this.console.log(document.URL),this.console.log(t))),t})),this.console=e}settingChange(e,t){this.metadata=e;const o=this.getRecoList().$children.filter((e=>this.videoClasses.includes(e.$el.className)));this.showUploadTime(o,!0,t)}urlChange(e){this.metadata=e;const t=this.getRecoList();this.console.debug("urlChange recoList.mark",t.mark),t.mark||(t.mark=!0,t.$watch("recListItems",(()=>{this.console.debug("recoListItems changed, now url is",document.URL);const e=t.$children.filter((e=>this.videoClasses.includes(e.$el.className)));this.showUploadTime(e)}),{deep:!0,immediate:!0}))}}function u(e,t,o){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var o=e[Symbol.toPrimitive];if(void 0!==o){var n=o.call(e,t||"default");if("object"!=typeof n)return n;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:o,enumerable:!0,configurable:!0,writable:!0}):e[t]=o,e}class p{constructor(e){var t=this;u(this,"console",void 0),u(this,"metadata",void 0),u(this,"videoClasses",["recommend-video-card video-card"]),u(this,"showUploadTime",(function(e){let o=arguments.length>1&&void 0!==arguments[1]&&arguments[1],n=arguments.length>2&&void 0!==arguments[2]?arguments[2]:"";if(!n){const{options:e}=(0,s.getComponentSettings)(t.metadata.name);n=e.formatString?.toString()}e.forEach((async e=>{let t=e.info.owner.name;if(o||!e.info.owner.mark){if(e.info.owner.mark=!0,o||!e.mark){if(e.mark=!0,!e.info.pubdate){const t=new c.VideoInfo(e.info.aid);await t.fetchInfo(),e.info.pubdate=t.pubdate}const o=new Date(1e3*e.info.pubdate);e.info.owner.oldname||(e.info.owner.oldname=e.info.owner.name),t=l(o,n,e.info.owner.oldname)}e.info.owner.name=t}}))})),u(this,"getRecoList",(()=>{const e=dq(".recommend-list-container"),t=(0,o.getVue2Data)(e);return void 0===t.isFolded&&(this.console.log("结构获取失败"),this.console.log(document.URL),this.console.log(t)),t})),this.console=e}settingChange(e,t){this.metadata=e;const o=this.getRecoList().$children.filter((e=>this.videoClasses.includes(e.$el.className)));this.showUploadTime(o,!0,t)}urlChange(e){this.metadata=e;const t=this.getRecoList();this.console.debug("urlChange recoList.mark",t.mark),t.mark||(t.mark=!0,t.$watch("visibleRelated",(()=>{this.console.debug("visibleRelated changed, now url is",document.URL);const e=t.$children.filter((e=>this.videoClasses.includes(e.$el.className)));this.showUploadTime(e)}),{deep:!0,immediate:!0}))}}const f="显示视频投稿时间",h=(0,a.useScopedConsole)(f),g=(0,e.defineComponentMetadata)({author:{name:"wisokey",link:"https://github.com/wisokey"},name:"showUploadTime",displayName:f,description:"为视频播放页面的推荐列表中的视频添加显示视频投稿时间.\n\n`时间格式` 替换up名的文本格式 (默认为'up · yyyy-MM-dd'):\n - y: 年\n - M: 月\n - d: 日\n - h: 时\n - m: 分\n - s: 秒\n - q: 季度\n - up: up名\n - \\r: 回车符\n - \\n换行符\n - \\t制表符",tags:[componentsTags.video],urlInclude:n.videoUrls,options:{formatString:{displayName:"文本格式",defaultValue:"up · yyyy-MM-dd",validator:(e,t)=>e?.trim()?e:t}},instantStyles:[{name:"showUploadTime",style:()=>Promise.resolve().then(i.t.bind(i,674,23))}],entry:async e=>{let{metadata:i}=e;const r=new m(h),a=[{TestPattern:n.videoUrls.slice(0,1),video:r},{TestPattern:n.mediaListUrls,video:new p(h)}],l=()=>{for(const e of a)for(const t of e.TestPattern)if((0,o.matchUrlPattern)(t))return e.video;return r};(0,s.addComponentListener)(`${i.name}.formatString`,((e,t)=>{const o=l();o&&o.settingChange(i,e,t)}),!1),(0,t.urlChange)((async()=>{h.debug("urlChange now url is",document.URL),await(0,o.playerReady)();const e=l();e&&e.urlChange(i)}))},commitHash:"0d7fac9836cde941056fab4203613aa50f5fed8e",coreVersion:"2.10.3"})})(),r=r.component})()));