Bilibili-Evolved/registry/dist/components/utils/comments/copy-link.js
github-actions[bot] ab048b3e66
Some checks are pending
Build / build (push) Waiting to run
CI build
2025-07-22 15:52:11 +00:00

1 line
2.3 KiB
JavaScript

!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["utils/comments/copy-link"]=t():e["utils/comments/copy-link"]=t()}(globalThis,(()=>(()=>{"use strict";var e,t,o={913:e=>{e.exports=coreApis.componentApis.utils.commentApis}},r={};function n(e){var t=r[e];if(void 0!==t)return t.exports;var i=r[e]={exports:{}};return o[e](i,i.exports,n),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,n.t=function(o,r){if(1&r&&(o=this(o)),8&r)return o;if("object"==typeof o&&o){if(4&r&&o.__esModule)return o;if(16&r&&"function"==typeof o.then)return o}var i=Object.create(null);n.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var c=2&r&&o;"object"==typeof c&&!~e.indexOf(c);c=t(c))Object.getOwnPropertyNames(c).forEach((e=>a[e]=()=>o[e]));return a.default=()=>o,n.d(i,a),i},n.d=(e,t)=>{for(var o in t)n.o(t,o)&&!n.o(e,o)&&Object.defineProperty(e,o,{enumerable:!0,get:t[o]})},n.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),n.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};n.d(i,{component:()=>p});const a=coreApis.componentApis.define,c=coreApis.utils,s=coreApis.utils.urls,p=(0,a.defineComponentMetadata)({name:"copyCommentsLink",displayName:"复制评论链接",description:{"zh-CN":"开启后, 可在每条评论的菜单中选择复制链接."},entry:async()=>{const{forEachCommentItem:e,addMenuItem:t}=await Promise.resolve().then(n.t.bind(n,913,23));e({added:e=>{const o=e=>{e.forEach((e=>{t(e,{className:"copy-link",text:"复制链接",action:async()=>{const t=(e=>{if(document.URL.match(/\/\/t\.bilibili\.com\/(\d+)/))return"";if(s.feedsUrls.every((e=>!(0,c.matchUrlPattern)(e))))return"";let t=e;for(;null!==t&&t!==document.body;){if(t.hasAttribute("data-did"))return`https://t.bilibili.com/${t.getAttribute("data-did")}`;t=t.parentElement}return""})(e.element)||document.URL.replace(location.hash,"");await navigator.clipboard.writeText(`${t}#reply${e.id}`)}})}))};o([e,...e.replies]),e.addEventListener("repliesUpdate",(e=>o(e.detail)))}})},tags:[componentsTags.utils],commitHash:"4b3a1a387095ef7eaca46616c451a366366a9869",coreVersion:"2.10.3"});return i=i.component})()));