!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports["utils/url-params-clean"]=t():e["utils/url-params-clean"]=t()}(globalThis,(()=>(()=>{var e,t,r={620:e=>{function t(e){var t=new Error("Cannot find module '"+e+"'");throw t.code="MODULE_NOT_FOUND",t}t.keys=()=>[],t.resolve=t,t.id=620,e.exports=t},95:e=>{"use strict";e.exports="自动删除网址中的多余跟踪参数。请注意这会导致浏览器历史记录出现重复的标题(分别是转换前后的网址),并可能导致后退要多退几次。\n\n- `清理页面中的 A 标签`: 清理视频简介、推荐列表、标签、评论中的链接。\n"},576:e=>{"use strict";e.exports=coreApis.lifeCycle},104:e=>{"use strict";e.exports=coreApis.observer}},a={};function o(e){var t=a[e];if(void 0!==t)return t.exports;var i=a[e]={exports:{}};return r[e](i,i.exports,o),i.exports}t=Object.getPrototypeOf?e=>Object.getPrototypeOf(e):e=>e.__proto__,o.t=function(r,a){if(1&a&&(r=this(r)),8&a)return r;if("object"==typeof r&&r){if(4&a&&r.__esModule)return r;if(16&a&&"function"==typeof r.then)return r}var i=Object.create(null);o.r(i);var n={};e=e||[null,t({}),t([]),t(t)];for(var s=2&a&&r;"object"==typeof s&&!~e.indexOf(s);s=t(s))Object.getOwnPropertyNames(s).forEach((e=>n[e]=()=>r[e]));return n.default=()=>r,o.d(i,n),i},o.d=(e,t)=>{for(var r in t)o.o(t,r)&&!o.o(e,r)&&Object.defineProperty(e,r,{enumerable:!0,get:t[r]})},o.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),o.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";o.d(i,{component:()=>b,k:()=>f});const e=coreApis.componentApis.define,t=coreApis.settings,r=coreApis.utils,a=coreApis.utils.log,n=coreApis.pluginApis.data,s=coreApis.componentApis.utils.commentApis;var c=o(576);const l=coreApis.shadowRoot,d=async(e,t,r)=>{if(e){new MutationObserver(((e,t)=>e.forEach((e=>r(e,t))))).observe(e,t)}},m={attributes:!0,attributeFilter:["href"],childList:!0,subtree:!0,characterData:!1},u="网址参数清理",p="urlParamsClean",f=(0,a.useScopedConsole)(u),h=(0,e.defineOptionsMetadata)({cleanAnchors:{defaultValue:!0,displayName:"清理页面中的 A 标签"}}),b=(0,e.defineComponentMetadata)({name:p,displayName:u,entry:async()=>{if((0,r.isNotHtml)()||(0,r.isIframe)())return; /* spell-checker: disable */const[e]=(0,n.registerAndGetData)("urlParamsClean.noClean",["videocard_series"]),[a]=(0,n.registerAndGetData)("urlParamsClean.params",["spm_id_from","from_source","from_spmid","from","seid","share_source","share_medium","share_plat","share_tag","share_session_id","share_from","bbid","ts","timestamp","unique_k","rt","tdsourcetag","accept_quality","broadcast_type","current_qn","current_quality","playurl_h264","playurl_h265","quality_description","network","network_status","platform_network_status","p2p_type","referfrom","visit_id","bsource","spm","hotRank","-Arouter","vd_source","is_story_h5","buvid","plat_id","goFrom","jumpLinkType","hasBack","noTitleBar","msource","live_from","plat_id","extra_jump_from","subarea_rank","popular_rank","launch_id","spmid","trackid","from_avid","from_comid"]),[i]=(0,n.registerAndGetData)("urlParamsClean.siteSpecifiedParams",[{match:/\/\/www\.bilibili\.com\/audio\/(au[\d]+|mycollection)/,param:"type"},{match:/\/\/live\.bilibili\.com\//,param:"session_id"},{match:/\/\/live\.bilibili\.com\//,param:"is_room_feed"},{match:/\/\/www\.bilibili\.com\/bangumi\//,param:"theme"},{match:/\/\/www\.bilibili\.com\/video\//,param:"mid"},{match:/\/\/www\.bilibili\.com\/video\//,param:"up_id"},{match:/\/\/mall\.bilibili\.com\//,param:"noReffer"}]),[u]=(0,n.registerAndGetData)("urlParamsClean.tailingSlash",[]),h=t=>{const o=new URL(t,location.origin),n=[...new URLSearchParams(o.search).entries()].map((e=>{let[t,r]=e;return`${t}=${encodeURIComponent(r)}`}));if(n.some((t=>e.some((e=>t.includes(e))))))return t;const s=n.filter((e=>!a.some((t=>e.startsWith(`${t}=`)))&&!i.some((t=>{let{match:r,param:a}=t;return document.URL.match(r)&&e.startsWith(`${a}=`)})))).join("&");u.forEach((e=>{let{match:t}=e;const a=o.pathname;(0,r.matchPattern)(a,t)&&a.endsWith("/")&&(o.pathname=a.slice(0,a.length-1))}));const c=s?`?${s}`:"";return o.search=c,o.toString()},b=e=>function(t,r,a){for(var o=arguments.length,i=new Array(o>3?o-3:0),n=3;n{try{return new URL(a,location.origin+location.pathname).toString()}catch(e){return f.warn("History API URL",`解析失败: ${a}`),a}})(),c=h(s);return c!==a?(f.log("History API 拦截",s,c),e.call(this,t,r,c,...i)):e.call(this,t,r,a,...i)},y=unsafeWindow.history.pushState;unsafeWindow.history.pushState=b(y);const _=unsafeWindow.history.replaceState;unsafeWindow.history.replaceState=b(_);(0,t.getComponentSettings)(p).options.cleanAnchors&&(async e=>{const t=t=>{if("A"!==t.nodeName||!t.href)return;const r=e(t.href);t.href!==r&&(f.info("清理A标签",t,t.href,r),t.href=r)},r=e=>{Array.from(e).forEach(t)},a=e=>{"href"===e.attributeName?t(e.target):e.addedNodes[0]&&e.addedNodes[0]instanceof HTMLElement&&r(e.addedNodes[0].querySelectorAll("a"))};(0,c.contentLoaded)((()=>{r(dqa(".tag-panel .tag-link")),d(dq(".tag-panel"),m,a),d(dq("#v_desc"),{childList:!0,subtree:!0,characterData:!1},(e=>{e.addedNodes.length>0&&e.target instanceof HTMLElement&&r(e.target.querySelectorAll("a"))})),r(dqa(".recommend-list-container a")),d(dq(".rcmd-tab,.recommend-list-container"),m,a),(0,s.forEachCommentArea)((async e=>{e instanceof s.CommentAreaV3&&e.commentAreaEntry.addEventListener(l.ShadowRootEvents.Updated,(e=>e.detail.forEach((e=>{e.addedNodes.forEach((e=>t(e)))}))))}))}))})(h);const{fullyLoaded:g}=await Promise.resolve().then(o.t.bind(o,576,23)),{urlChange:v}=await Promise.resolve().then(o.t.bind(o,104,23));g((()=>{v((()=>(()=>{const e=h(document.URL);e!==document.URL&&(f.log("直接清理",document.URL,e),window.history.replaceState(history.state,"",e))})()))}))},options:h,tags:[componentsTags.utils], /* spell-checker: disable */ urlExclude:[/game\.bilibili\.com\/fgo/,/live\.bilibili\.com\/p\/html\/live-app-hotrank\//],commitHash:"b24c3a5c1c778fcfbf52755dd350299a1907ab2b",coreVersion:"2.10.6",description:(()=>{const e=o(620);return{...Object.fromEntries(e.keys().map((t=>[t.match(/index\.(.+)\.md$/)[1],e(t)]))),"zh-CN":()=>Promise.resolve().then(o.t.bind(o,95,17)).then((e=>e.default))}})()})})(),i=i.component})()));