mirror of
https://github.com/bolucat/Archive.git
synced 2026-04-23 00:17:16 +08:00
12 lines
8.2 KiB
JavaScript
12 lines
8.2 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/subscribe-time-show"]=t():e["utils/subscribe-time-show"]=t()}(globalThis,(()=>(()=>{var e,t,n={267:(e,t,n)=>{var o=n(904),r=n(955)(o);r.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}","",{version:3,sources:["webpack://./registry/lib/components/utils/subscribe-time-show/subscribe-time.scss"],names:[],mappings:"AAAA;EACE,kBAAkB;AACpB;AACA;EACE,kBAAkB;EAClB,UAAU;EACV,SAAS;EACT,2BAA2B;EAC3B,eAAe;EACf,WAAW;EACX,iBAAiB;EACjB,yBAAiB;UAAjB,iBAAiB;EACjB,oBAAoB;EACpB,mBAAmB;EACnB,gBAAgB;EAChB,uCAAuC;AACzC;;AAEA;EACE,WAAW;EACX,eAAe;EACf,kBAAkB;EAClB,yBAAiB;UAAjB,iBAAiB;AACnB",sourcesContent:[".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 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 user-select: none;\n}"],sourceRoot:""}]),e.exports=r},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 n=e(t);return t[2]?"@media ".concat(t[2]," {").concat(n,"}"):n})).join("")},
|
||
// eslint-disable-next-line func-names
|
||
t.i=function(e,n,o){"string"==typeof e&&(
|
||
// eslint-disable-next-line no-param-reassign
|
||
e=[[null,e,""]]);var r={};if(o)for(var i=0;i<this.length;i++){
|
||
// eslint-disable-next-line prefer-destructuring
|
||
var a=this[i][0];null!=a&&(r[a]=!0)}for(var s=0;s<e.length;s++){var c=[].concat(e[s]);o&&r[c[0]]||(n&&(c[2]?c[2]="".concat(n," and ").concat(c[2]):c[2]=n),t.push(c))}},t}},904:e=>{"use strict";function t(e,t){return function(e){if(Array.isArray(e))return e}(e)||function(e,t){var n=e&&("undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"]);if(null==n)return;var o,r,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(o=n.next()).done)&&(i.push(o.value),!t||i.length!==t);a=!0);}catch(e){s=!0,r=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw r}}return i}(e,t)||function(e,t){if(!e)return;if("string"==typeof e)return n(e,t);var o=Object.prototype.toString.call(e).slice(8,-1);"Object"===o&&e.constructor&&(o=e.constructor.name);if("Map"===o||"Set"===o)return Array.from(e);if("Arguments"===o||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(o))return n(e,t)}(e,t)||function(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function n(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,o=new Array(t);n<t;n++)o[n]=e[n];return o}e.exports=function(e){var n=t(e,4),o=n[1],r=n[3];if(!r)return o;if("function"==typeof btoa){
|
||
// eslint-disable-next-line no-undef
|
||
var i=btoa(unescape(encodeURIComponent(JSON.stringify(r)))),a="sourceMappingURL=data:application/json;charset=utf-8;base64,".concat(i),s="/*# ".concat(a," */"),c=r.sources.map((function(e){return"/*# sourceURL=".concat(r.sourceRoot||"").concat(e," */")}));return[o].concat(c).concat([s]).join("\n")}return[o].join("\n")}},937:(e,t,n)=>{var o=n(267);o&&o.__esModule&&(o=o.default),e.exports="string"==typeof o?o:o.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}},o={};function r(e){var t=o[e];if(void 0!==t)return t.exports;var i=o[e]={id:e,exports:{}};return n[e](i,i.exports,r),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,r.t=function(n,o){if(1&o&&(n=this(n)),8&o)return n;if("object"==typeof n&&n){if(4&o&&n.__esModule)return n;if(16&o&&"function"==typeof n.then)return n}var i=Object.create(null);r.r(i);var a={};e=e||[null,t({}),t([]),t(t)];for(var s=2&o&&n;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>a[e]=()=>n[e]));return a.default=()=>n,r.d(i,a),i},r.d=(e,t)=>{for(var n in t)r.o(t,n)&&!r.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},r.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),r.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var i={};return(()=>{"use strict";r.d(i,{component:()=>y});const e=coreApis.componentApis.define,t=coreApis.utils.log,n=coreApis.ajax,o=coreApis.spinQuery,a=coreApis.observer,s=coreApis.userInfo,c=(0,t.useScopedConsole)("关注时间显示"),l=".space-head-follow.b-follow",u="subscribe-time-text",f=".relation-card-info__uname",p=".relation-card-info",m="relation-card-info__time",d=".relation-card-info__sign",A={},b=(e,t,n)=>{const o=dq(`${f}[href*="/${e}"]`),r=o?.closest(p);if(!r||r.querySelector(`.${m}`))return;const i=document.createElement("div");i.className=m,i.textContent=`${n}:${t}`,i.dataset.mid=e.toString();const a=r.querySelector(d);a?.parentNode&&a.parentNode.insertBefore(i,a.nextSibling)},h=(()=>{let e=!1;return()=>{e||(e=!0,requestAnimationFrame((()=>{e=!1,dqa(f).forEach((e=>{const t=e.href.match(/\/(\d+)/);if(!t)return;const n=Number(t[1]);if(Number.isNaN(n))return;const o=A[n];if(o){const e=new Date(1e3*o.mtime).toLocaleString();b(n,e,o.label)}}))})))}})();if(!unsafeWindow.subscribeTimeHooked){unsafeWindow.subscribeTimeHooked=!0;const e=unsafeWindow.fetch;unsafeWindow.fetch=new Proxy(e,{apply(e,t,n){const o="string"==typeof n[0]?n[0]:n[0].url,r=new URL(o,location.origin);return"api.bilibili.com"===r.hostname&&(r.pathname.includes("/x/relation/fans")||r.pathname.includes("/x/relation/followings"))?e.apply(t,n).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=o.includes("/fans")?"Ta 关注你的时间":"你关注 Ta 的时间";A[e.mid]={mtime:e.mtime,label:t};const n=new Date(1e3*e.mtime).toLocaleString();b(e.mid,n,t)}})):c.warn("接口数据结构异常:",e)})).catch((e=>{c.warn("JSON 解析失败:",e)})),e))).catch((e=>{throw c.warn("fetch 请求失败:",e),e})):e.apply(t,n)}})}const y=(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(r.t.bind(r,479,23)),{default:t}=await Promise.resolve().then(r.t.bind(r,937,23));e(t,"subscribe-time-style")}catch(e){c.error("样式加载失败:",e)}(0,a.allMutations)(h);const e=(await(0,s.getUserInfo)()).mid,t=location.href.match(/space\.bilibili\.com\/(\d+)/);if(!t)return;const i=Number(t[1]);if(i===e)return void c.log("当前为本人空间,跳过关注时间显示");const f=await(0,n.bilibiliApi)((0,n.getJsonWithCredentials)(`https://api.bilibili.com/x/web-interface/relation?mid=${i}`)),p=f?.relation?.mtime;p&&(await(0,o.select)(l),(e=>{const t=dq(l);if(!t||t.querySelector(`.${u}`))return;"static"===getComputedStyle(t).position&&(t.style.position="relative");const n=document.createElement("div");n.className=u,n.textContent=`关注于 ${e}`,t.appendChild(n)})(new Date(1e3*p).toLocaleString()))},description:{"zh-CN":"在粉丝/关注列表及用户主页显示关注的具体时间。"},commitHash:"67168e9c79449a0e28f1488f4bc7a8972097346a",coreVersion:"2.10.7"})})(),i=i.component})()));
|
||
//# sourceMappingURL=https://raw.githubusercontent.com/the1812/Bilibili-Evolved/master/registry/dist/components/utils/subscribe-time-show.js.map
|