!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["utils/subscribe-time-show"]=t():e["utils/subscribe-time-show"]=t()}(globalThis,(()=>(()=>{var e,t,o={733:(e,t,o)=>{var n=o(955)((function(e){return e[1]}));n.push([e.id,".space-head-follow.b-follow {\n  position: relative;\n}\n.space-head-follow.b-follow .subscribe-time-text {\n  position: absolute;\n  top: -20px;\n  left: 50%;\n  transform: translateX(-50%);\n  font-size: 12px;\n  color: #fff;\n  line-height: 16px;\n  -webkit-user-select: none;\n          user-select: none;\n  pointer-events: none;\n  white-space: nowrap;\n  font-weight: 500;\n  text-shadow: 0 0 3px rgba(0, 0, 0, 0.7);\n}\n\n.relation-card-info__time {\n  color: #888;\n  font-size: 12px;\n  margin-bottom: 4px;\n  -webkit-user-select: none;\n          user-select: none;\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 c=[].concat(e[s]);n&&i[c[0]]||(o&&(c[2]?c[2]="".concat(o," and ").concat(c[2]):c[2]=o),t.push(c))}},t}},595:(e,t,o)=>{var n=o(733);n&&n.__esModule&&(n=n.default),e.exports="string"==typeof n?n:n.toString()},479:e=>{"use strict";if("undefined"==typeof coreApis){var t=new Error("Cannot find module 'coreApis.style'");throw t.code="MODULE_NOT_FOUND",t}e.exports=coreApis.style}},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:()=>w});const e=coreApis.componentApis.define,t=coreApis.utils.log,o=coreApis.ajax,n=coreApis.spinQuery,a=coreApis.observer,s=coreApis.userInfo,c=(0,t.useScopedConsole)("关注时间显示"),l=".space-head-follow.b-follow",f="subscribe-time-text",p=".relation-card-info__uname",u=".relation-card-info",d="relation-card-info__time",m=".relation-card-info__sign",b={},h=(e,t,o)=>{const n=dq(`${p}[href*="/${e}"]`),i=n?.closest(u);if(!i||i.querySelector(`.${d}`))return;const r=document.createElement("div");r.className=d,r.textContent=`${o}：${t}`,r.dataset.mid=e.toString();const a=i.querySelector(m);a?.parentNode&&a.parentNode.insertBefore(r,a.nextSibling)},y=(()=>{let e=!1;return()=>{e||(e=!0,requestAnimationFrame((()=>{e=!1,dqa(p).forEach((e=>{const t=e.href.match(/\/(\d+)/);if(!t)return;const o=Number(t[1]);if(Number.isNaN(o))return;const n=b[o];if(n){const e=new Date(1e3*n.mtime).toLocaleString();h(o,e,n.label)}}))})))}})();if(!unsafeWindow.subscribeTimeHooked){unsafeWindow.subscribeTimeHooked=!0;const e=unsafeWindow.fetch;unsafeWindow.fetch=new Proxy(e,{apply(e,t,o){const n="string"==typeof o[0]?o[0]:o[0].url,i=new URL(n,location.origin);return"api.bilibili.com"===i.hostname&&(i.pathname.includes("/x/relation/fans")||i.pathname.includes("/x/relation/followings"))?e.apply(t,o).then((e=>(e.clone().json().then((e=>{const t=e?.data?.list;Array.isArray(t)?t.forEach((e=>{if("number"==typeof e.mid&&"number"==typeof e.mtime){const t=n.includes("/fans")?"Ta 关注你的时间":"你关注 Ta 的时间";b[e.mid]={mtime:e.mtime,label:t};const o=new Date(1e3*e.mtime).toLocaleString();h(e.mid,o,t)}})):c.warn("接口数据结构异常:",e)})).catch((e=>{c.warn("JSON 解析失败:",e)})),e))).catch((e=>{throw c.warn("fetch 请求失败:",e),e})):e.apply(t,o)}})}const w=(0,e.defineComponentMetadata)({name:"subscribeTimeShow",displayName:"关注时间显示",author:{name:"CNOCM",link:"https://github.com/CNOCM"},tags:[componentsTags.utils],urlInclude:[/^https:\/\/space\.bilibili\.com\/\d+\/(relation|fans)\/(fans|follow)/,/https:\/\/space\.bilibili\.com\/\d+/],entry:async()=>{try{const{addImportantStyle:e}=await Promise.resolve().then(i.t.bind(i,479,23)),{default:t}=await Promise.resolve().then(i.t.bind(i,595,23));e(t,"subscribe-time-style")}catch(e){c.error("样式加载失败:",e)}(0,a.allMutations)(y);const e=(await(0,s.getUserInfo)()).mid,t=location.href.match(/space\.bilibili\.com\/(\d+)/);if(!t)return;const r=Number(t[1]);if(r===e)return void c.log("当前为本人空间，跳过关注时间显示");const p=await(0,o.bilibiliApi)((0,o.getJsonWithCredentials)(`https://api.bilibili.com/x/web-interface/relation?mid=${r}`)),u=p?.relation?.mtime;u&&(await(0,n.select)(l),(e=>{const t=dq(l);if(!t||t.querySelector(`.${f}`))return;"static"===getComputedStyle(t).position&&(t.style.position="relative");const o=document.createElement("div");o.className=f,o.textContent=`关注于 ${e}`,t.appendChild(o)})(new Date(1e3*u).toLocaleString()))},description:{"zh-CN":"在粉丝/关注列表及用户主页显示关注的具体时间。"},commitHash:"f8d9b5665fc198fe5b2eb39c57dab6d686e5ed74",coreVersion:"2.10.4"})})(),r=r.component})()));