// ==UserScript==
// @name bilibili 移动端
// @namespace https://github.com/jk278/bilibili-mobile
// @version 5.1.7.5
// @author jk278
// @description Safari打开电脑模式,其它浏览器关闭电脑模式修改网站UA,获取舒适的移动端体验。
// @license MIT
// @icon https://www.bilibili.com/favicon.ico
// @match https://*.bilibili.com/*
// @exclude https://message.bilibili.com/pages/nav/*
// @exclude https://www.bilibili.com/blackboard/comment-detail.html?*
// @require https://unpkg.com/js-md5@latest/src/md5.js
// @grant GM_addStyle
// @grant GM_getValue
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant unsafeWindow
// @run-at document-start
// @downloadURL https://update.greasyfork.icu/scripts/490548/bilibili%20%E7%A7%BB%E5%8A%A8%E7%AB%AF.user.js
// @updateURL https://update.greasyfork.icu/scripts/490548/bilibili%20%E7%A7%BB%E5%8A%A8%E7%AB%AF.meta.js
// ==/UserScript==
(t=>{if(typeof GM_addStyle=="function"){GM_addStyle(t);return}const i=document.createElement("style");i.textContent=t,document.head.append(i)})(' body{--actionbar-height: 40px;--overlay-time: .4s;--actionbar-time: .5s}#actionbar{position:fixed;bottom:0;width:100vw;height:var(--actionbar-height);z-index:2;display:flex;justify-content:space-evenly;align-items:center;background-color:#fff9;transition:var(--actionbar-time) transform ease-in;opacity:0;animation:actionbarFadeIn .4s ease-in forwards;-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px)}@keyframes actionbarFadeIn{to{opacity:1}}[scroll-hidden] #actionbar{transform:translateY(100%)}#actionbar>*{padding:8px}#full-now,#sidebar-fab,#refresh-fab,#show-more-fab{display:none}#actionbar.home #refresh-fab,#actionbar.video #full-now,#actionbar.list #full-now{display:block}#actionbar.message #menu-fab{display:none}#actionbar.video #sidebar-fab,#actionbar.list #sidebar-fab,#actionbar.message #sidebar-fab{display:block}#actionbar.video #my-top,#actionbar.list #my-top,#actionbar.message #my-top{display:none}#actionbar.search #show-more-fab,#actionbar.space #show-more-fab{display:block}#menu-fab{position:relative}#search-fab,#menu-fab{z-index:0;transition:z-index var(--overlay-time) ease-in}#search-fab.active,#menu-fab.active{z-index:10}#show-more-fab{transition:transform .4s ease-in}#show-more-fab.reverse{transform:rotate(180deg)}#search-fab{display:flex;padding:4px 8px;max-width:40%;align-items:center}#search-fab svg{flex:0 0 24px}#search-fab-text{overflow:hidden;text-overflow:ellipsis;white-space:nowrap}#header-in-menu{position:absolute!important;top:100vh;left:calc((200vw + 20px) / 3);background-color:#fff;padding:5px 0;white-space:nowrap;box-shadow:0 0 3px #00000080;border-radius:5px;font-size:16px;transform:translate(-50%);transition:transform var(--overlay-time) ease-in}#header-in-menu li{list-style-type:none;padding:5px 30px;line-height:20px!important}body #header-in-menu li{position:relative;padding:5px 30px!important;line-height:20px!important}#header-in-menu.show{transform:translate(-50%,calc(-100% - var(--actionbar-height) - 5px))}.badge{position:absolute;top:6px;left:63px;display:inline-flex;align-items:center;justify-content:center;height:16px;padding:0 4.5px 1px;border-radius:8px;background-color:red;color:#fff;font-size:12px;visibility:hidden}#menu-overlay,#search-overlay,#sidebar-overlay,#ai-conclusion-overlay{position:fixed;bottom:0;height:100vh;left:0;right:0;pointer-events:none;background-color:#0000004d;opacity:0;transition:opacity var(--overlay-time) ease-in}#menu-overlay.show,#search-overlay.show,#sidebar-overlay.show,#ai-conclusion-overlay.show{pointer-events:auto;opacity:1}#toast{position:fixed;left:0;bottom:var(--actionbar-height);transform:translate(calc(50vw - 50%),100%);z-index:1;font-size:14px;line-height:20px;padding:5px 12px;margin-bottom:5px;background-color:#fff;border:1px solid var(--line_regular);border-radius:16px;opacity:0;transition:.3s ease-in;display:none}#toast[show]{transform:translate(calc(50vw - 50%));opacity:1}.bpx-player-container #toast{color:var(--text4);background-color:#00000080}.floor-single-card:has(.skeleton,.skeleton-item){display:none}.setting-panel{position:fixed;top:50%;left:50%;background:#fff;z-index:1002;border:1px solid var(--line_regular);flex-direction:column;padding:10px 5px;border-radius:10px;font-size:16px;max-height:calc(100vh - var(--actionbar-height) - 10px);width:260px;max-width:calc(100% - 20px);box-shadow:0 0 3px #0000004d;opacity:0;transform:translate(-50%,-50%) scale(.9);transition:.4s ease-in;display:none}.setting-panel[show]{opacity:1;transform:translate(-50%,-50%)}.setting-panel.mini{opacity:1;transform:translate(-50%,-50%);display:flex;width:150px}.mini .setting-checkboxes label{height:16px}.setting-title{margin:0 5px 5px;padding-bottom:5px;border-bottom:1px solid var(--line_regular);text-align:center;color:var(--Ga7)}.setting-checkboxes{display:flex;flex-direction:column;overflow:auto}.setting-checkboxes label{margin:5px;display:flex;align-items:center}.setting-checkboxes span,.setting-checkboxes details{flex-grow:1;text-align:center}.setting-checkboxes input[type=checkbox]{width:16px;height:26px}.setting-checkboxes input[type=number]{width:40px;-webkit-appearance:textfield;-moz-appearance:textfield;appearance:textfield;height:22px}input[type=number]::-webkit-inner-spin-button,input[type=number]::-webkit-outer-spin-button{-webkit-appearance:none}.setting-conform{margin:8px 5px 3px;height:28px;border-radius:14px;border:1px solid var(--line_regular);background-color:var(--graph_bg_thin)!important}label:has([data-key=menu-dialog-move-down])+label{display:none}label:has([data-key=menu-dialog-move-down]:checked)+label{display:flex}.setting-content{font-size:14px}.setting-content a{text-decoration:underline}#follow-list-dialog{z-index:2}#follow-list-dialog .list-item{border-bottom:1px solid #eee;padding:10px 0 8px}ul.follow-list-content{height:480px;overflow-y:auto;padding:10px}#follow-list-dialog .cover-container{position:static;width:60px;height:60px;float:left}#follow-list-dialog .content{margin:10px 0 8px 75px}.list-item a.title{font-size:16px;line-height:20px;height:20px;margin-bottom:6px;display:inline-block}.list-item .auth-description{display:-webkit-box;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2;overflow:hidden;font-size:13px;line-height:15px;height:30px;line-break:anywhere}.follow-list-content .list-item .fans-action{position:absolute;right:0;top:unset;transform:translateY(-58px);z-index:1}.list-item .be-dropdown{display:inline-block}.list-item .fans-action-btn{padding:4px 9px 4px 7px;margin-right:4px;background-color:#e5e9ef;border-radius:4px;color:#6d757a;float:left;line-height:16px;font-size:0}.fans-action-btn .video-commonmenu{vertical-align:middle;margin-right:2px}div.fans-action-btn.follow{line-height:16px;height:24px;border:none;width:70px;box-sizing:border-box;text-align:center}.fans-action-text{line-height:16px;font-size:12px;vertical-align:middle}.follow-list-content ul.be-dropdown-menu{top:30px;border:1px solid #e5e9ef;border-radius:8px;box-shadow:0 2px 4px #00000024}.follow-list-content li.be-dropdown-item{height:28px;line-height:28px;padding:0}.follow-list-content .be-dropdown-trigger+.be-dropdown-menu{right:0;padding:3px 10px}#progress-info{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);background-color:#000000b3;color:#fff;padding:10px;border-radius:5px;z-index:1000;display:none}#biliMainHeader,#bili-header-container,#home_nav{position:fixed;width:100%;z-index:62;top:-64px!important}#bili-header-container{background:unset!important}.large-header .bili-header__bar{top:-64px!important;position:fixed!important}.fixed-header .bili-header__bar{position:absolute!important}div.mini-header{box-shadow:unset}.center-search-container{position:absolute!important;width:100%;left:0;top:64px;padding:10px 20px 5px!important;z-index:3;margin:0!important;opacity:0;transform:scale(.9);transition:.4s ease-in;display:none}.center-search-container[show]{opacity:1;transform:none}.center-search-container #nav-searchform{border-radius:8px 8px 0 0!important;border-bottom:none!important;background:#fff!important;opacity:1!important}.center-search-container #nav-searchform .nav-search-content{background-color:var(--graph_bg_thick)!important}.nav-search-input{width:100%}.center-search-container .search-panel{display:block!important}.history-item .close{display:none}.animated-banner,#bili-header-banner-img,.biliheader__banner,.adblock-tips{display:none!important}div.bili-header .v-popover{position:fixed;margin:0!important;max-width:100%;padding:0 5px!important;left:50%;opacity:0;transition:.4s ease-in;display:none;top:50vh!important;transform:translate(-50%,-50%) scale(.9)}div.bili-header .v-popover[display]{display:block!important}div.bili-header .v-popover[show]{opacity:1;transform:translate(-50%,-50%)!important}.bili-header.false-header{min-height:0;pointer-events:none}.bili-header.false-header:has(>[show]){pointer-events:auto}#copy-category-dialog.v-popover{display:none;z-index:2;width:80%;max-width:300px}div.bili-header-channel-panel{display:flex;flex-direction:row;padding:5px}.channel-panel__column{flex:1;display:flex;flex-direction:column;align-items:center}.channel-panel__column a{padding:7.5px 5px;text-align:center}.dynamic-panel-popover,.favorite-panel-popover,.history-panel-popover{max-width:100%;padding:0 5px!important}.message-entry-popover .message-inner-list__item{padding-left:43px!important}.dynamic-video-item{margin-right:0!important}.header-dynamic-list-item{padding:0!important;margin:10px 0!important}.header-dynamic__box--center{max-width:60%}.header-dynamic__box--right{top:0!important;margin-bottom:0!important;width:unset!important;flex:1}.header-dynamic__box--right .cover{width:unset!important;height:unset!important}.wnd_bottom{max-width:calc(100% - 40px);display:none}.favorite-panel-popover__nav{max-width:25%}.header-fav-card__image{max-width:40%}.header-fav-card__image picture{max-width:100%;height:100%!important}.favorite-panel-popover__nav .tab-item{padding:0 6px!important}.header-fav-card{padding:6px!important}.favorite-panel-popover__nav{margin-top:6px!important}.header-history-video{padding:5px 10px!important}a.view-all-history-btn{display:none!important}.header-tabs-panel__content #nav-searchform{display:flex;align-items:center;padding:6px 48px 0 15px;position:relative;height:40px;background-color:#fff;transition:background-color .3s}.header-tabs-panel__content .nav-search-btn{position:absolute;top:9px;right:7px;display:flex;align-items:center;justify-content:center;width:32px;height:32px}.header-tabs-panel__content .nav-search-content{display:flex;align-items:center;justify-content:space-between;padding:0 8px;width:100%;height:32px;border-radius:6px;background-color:var(--graph_bg_thick)!important}.header-tabs-panel__content input.nav-search-input{flex:1;margin-right:8px;border:none;background-color:transparent;box-shadow:none;color:var(--text2);font-size:14px;line-height:32px}.header-tabs-panel__content .nav-search-clean{width:16px;height:16px;cursor:pointer}.header-entry-avatar{display:none!important}.header-entry-mini{animation:unset!important}.left-entry>li:not(:nth-of-type(1)),.vip-wrap,.right-entry-item:has(>.vip-wrap),.right-entry-item:nth-of-type(6),.right-entry-item--upload,.header-channel,.bili-header__channel,.recommended-swipe,.feed-roll-btn{display:none!important}.header-banner__inner{display:none!important}.login-panel-popover{max-width:100%}body{background:#fff!important}.recommended-container_floor-aside .container{grid-template-columns:repeat(2,1fr)!important;padding:8px;grid-gap:8px!important;background-color:#f1f2f3}.bili-header__banner{background-color:#f1f2f3!important;height:50vw!important}.container>.feed-card{display:block!important}body,.bili-header,.bili-header__banner{min-width:0!important}.bili-feed4-layout{width:100%!important}.container>*:has(.bili-video-card__info--ad),.container>*:has(.bili-video-card__info--creative-ad),.floor-single-card{display:none!important}.feed-card:not(:has(.bili-video-card__wrap)),.bili-video-card.is-rcmd:not(:has(.bili-video-card__wrap)){display:none!important}.desktop-download-tip,.lt-row,.vip-entry-containter{display:none!important}.bili-video-card *:before,.bili-video-card *:after{width:100%;white-space:wrap!important;word-break:break-all}.container>*{margin-top:0!important}.bili-video-card__wrap,.bili-live-card__wrap{border-radius:5px}.bili-live-card__wrap{height:100%}.bili-video-card.is-rcmd,.bili-live-card.is-rcmd{--cover-radio: 66.67% !important}.v-img.bili-video-card__cover,.v-img.bili-live-card__cover{border-radius:5px 5px 0 0!important}.bili-video-card__stats,.bili-live-card__stats{border-radius:0!important;--icon-size: 16px;--subtitle-font-size: 11px;white-space:nowrap}.bili-video-card__info,.bili-live-card__info{--title-padding-right: 22px;--title-line-height: 20px;--title-font-size: 13px;--no-interest-entry-size: 22px;--info-margin-top: 7px;padding-bottom:5px;text-align:justify}.bili-video-card__info--right,.bili-live-card__info--text{padding:0 5px}.bili-video-card__info--bottom,.bili-live-card__info--uname{--subtitle-font-size: 12px}.bili-video-card__info--icon-text{padding:0 5px!important}.bili-video-card__info--owner{flex:1}.bili-video-card__info--date{margin-left:auto!important}.bili-video-card__info--icon-text{--follow-icon-font-size: 11px;--follow-icon-line-height: 15px}div.bili-live-card .bili-live-card__info--living{font-size:11px}div.bili-video-card .bili-video-card__info--no-interest,div.bili-live-card .bili-live-card__info--no-interest{display:flex!important;top:calc((var(--title-line-height) * 2 - var(--no-interest-entry-size)) / 2);right:2px;opacity:0;transition:opacity .2s ease-in}.bili-video-card .bili-video-card__info--no-interest:has(svg path),.bili-live-card .bili-live-card__info--no-interest:has(svg path){opacity:1}div.bili-video-card[data-has-ai=true] .bili-video-card__info--no-interest:after{content:"";position:absolute;top:0;right:3px;width:3px;height:3px;background-color:#00aeec;border-radius:50%}.bili-video-card__no-interest{--no-interest-module-gap: 5px;--no-interest-btn-horizontal-padding: var(--no-interest-btn-vertical-padding)}.bili-video-card__no-interest .revert-btn{flex-direction:column}.bili-watch-later.bili-watch-later--pip span{display:none}.bili-video-card__image--wrap:has(>.mouse-in)+.bili-video-card__mask{visibility:hidden;opacity:0}.inline-progress-bar{position:absolute;bottom:0;height:4px;left:0;width:100%;z-index:2;background-color:#ddd;display:none}.v-inline-player.mouse-in+.inline-progress-bar{display:block}.inline-progress-bar-filled{position:absolute;top:0;left:0;bottom:0;background-color:#007bff}.inline-progress-bar-thumb{position:absolute;top:-4px;left:0;width:12px;height:12px;transform:translate(-2px);background-color:#fff;border:1px solid #ccc;border-radius:50%;cursor:pointer;touch-action:none;pointer-events:auto}#ai-conclusion-overlay{z-index:2}.ai-conclusion-card{position:fixed;max-height:530px;width:400px;z-index:99;color:#000;filter:drop-shadow(rgba(0,0,0,.5) 0px 0px 15px);padding-bottom:1.25rem;overflow:auto;border-radius:.5rem;border-width:1px;background:#fff}.ai-conclusion-card .ai-conclusion-card-header{font-weight:700;padding:1.25rem;background:linear-gradient(to bottom,#c8e1ff,#fff)}.ai-conclusion-card .ai-conclusion-card-header .ai-conclusion-card-header-left{display:flex;align-items:center}.ai-conclusion-card .ai-conclusion-card-summary{margin-bottom:1.25rem;font-weight:700;padding:0px 1.25rem}.ai-conclusion-card .ai-conclusion-card-selection{margin-bottom:1.25rem;padding:0px 1.25rem}.ai-conclusion-card .ai-conclusion-card-selection .ai-conclusion-card-selection-title{display:flex;font-weight:700;cursor:pointer;margin-bottom:1rem}.palette-button-outer{display:none}.primary-btn,span.btn-text-inner,.storage-box,.login-scan-wp,.bili-mini-line{display:none!important}.bili-mini-content-wp{padding:52px 0 29px!important}.bili-mini-login-right-wp,.bili-mini-login-right-wp *{max-width:80vw}#i_cecream{min-width:0!important;min-height:calc(100vh - var(--actionbar-height))!important}button.vui_button{min-width:0}div.i_wrapper{padding:0 5px}.search-tabs.i_wrapper{padding-top:10px!important}.vui_tabs--nav-link{padding:0 1px!important;flex-direction:column}ul.vui_tabs--nav>*{flex:1}.vui_tabs--nav-item:nth-child(1) .vui_tabs--nav-text{padding-bottom:17px}.vui_tabs--nav-item:nth-child(2){order:-1}.vui_tabs--nav-item:nth-child(3){order:-2}.vui_tabs--nav-item:nth-child(4){order:-3}.vui_tabs--nav-item:nth-child(5){order:3}.vui_tabs--nav-item:nth-child(6){order:2}.vui_tabs--nav-item:nth-child(7){order:1}.activity-game-list{display:none}.search-conditions{position:fixed;bottom:0;z-index:2;background:#fff;padding:5px!important;opacity:0;transition:var(--actionbar-time) ease-in;pointer-events:none}.search-conditions.show{bottom:var(--actionbar-height);opacity:1;pointer-events:auto}[scroll-hidden] div.search-conditions{bottom:0}.search-condition-row>.vui_button{width:33.3%;margin:0!important}.search-condition-row{width:100%}.conditions-order{position:relative}.conditions-order .i_button_more{position:absolute;bottom:0;left:66.6%;padding-left:23px!important;border:0;width:33.3%}.search-input{display:none}.video-list>div{flex:0 0 50%;max-width:50%;padding:0 4px!important;margin-bottom:10px}.search-content{padding:0 5px!important}.search-page-wrapper .search-page{margin-top:8px!important;padding-bottom:0!important}div.search-page.search-page-all{--list_padding: 10px}.i_wrapper.p_relative:has(.watch-more){margin-bottom:var(--list_padding)}.search-page-all div.i_wrapper.search-all-list{padding-top:12px}.search-page .bili-video-card h3.bili-video-card__info--tit{padding-right:0}.search-page .flex_center{margin:5px 0 10px!important}.vui_pagenation{width:100%}div.vui_pagenation--btns{display:flex;flex-wrap:wrap;justify-content:space-between;width:100%;--calc-margin: calc((100% - 34px * 7) / 14);position:relative;margin-bottom:34px}.vui_pagenation--btns>*{max-width:34px;margin:0 var(--calc-margin) 10px!important}.vui_pagenation--btn-side{overflow:hidden;position:absolute;top:0}.vui_pagenation--btn-side:before{color:var(--v_text1);background-color:inherit;position:absolute;top:0;left:0;width:34px;font-size:20px}.vui_pagenation--btn-side:first-child:before{content:"<";padding:6.5px 9px 7.5px 5px}.vui_pagenation--btn-side:last-child:before{content:">";padding:5.5px 7px 8.5px}button.vui_pagenation--btn-side:first-child{margin:44px var(--calc-margin) 0!important}button.vui_pagenation--btn-num:nth-child(2){position:absolute;top:0;margin:44px 0 0 calc(var(--calc-margin) * 3 + 34px)!important}button.vui_pagenation--btn-num:nth-last-child(2){position:absolute;top:0;right:0;margin:44px calc(var(--calc-margin) * 3 + 34px) 0 0!important}button.vui_pagenation--btn-side:last-child{right:0;margin:44px var(--calc-margin) 0 0!important}.link-box{flex-direction:column;margin:0 10px!important}.bili-footer{min-width:0!important;padding:5px 0 var(--actionbar-height)!important}.b-footer-wrap{min-width:0!important;margin:0 5px!important}.link-box{flex-direction:column}.link-box>*{max-width:100%}.link-item__right,.other-link,.footer-icons{display:none!important}.media-item-col{max-width:100%!important;flex:none!important;margin-bottom:10px!important;padding:0!important}.media-list .col_6,.live-user-cards .col_6{max-width:100%!important;flex:none!important;--avatar-scale: 56px}.media-list .col_6{margin-bottom:10px!important}div.b-user-info-card{align-items:start}.col_6 .bili-avatar{height:var(--avatar-scale)!important;width:var(--avatar-scale)!important}.search-user-avatar{width:var(--avatar-scale)!important;min-width:var(--avatar-scale)!important}.avatar-wrap{height:var(--avatar-scale)!important}div.user-content,div.live-content{width:100%!important;padding-right:0!important}div.user-content{height:85px}.i_card_title{height:20px}h2.i_card_title>a{font-size:16px}.user-content span{position:absolute;left:calc(var(--avatar-scale) + 20px);top:50px;white-space:wrap!important;display:-webkit-box;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2;margin-right:10px}.user-actions,.live-actions{position:absolute;right:10px;top:20px}.user-actions button,.live-actions button{height:26px!important;width:70px!important;min-width:70px;border-radius:13px!important}.live-user-card{margin-bottom:10px!important}.live-tags{position:absolute;left:calc(var(--avatar-scale) + 15px);top:50px;max-width:calc(100% - var(--avatar-scale) - 30px)!important}div.live-content{height:65px}.search-user-avatar .live-tab{bottom:-16px!important}.show-more-text{margin:10px 0 20px!important;z-index:1!important}.media-item{padding:0!important}.media-card{--image-width: 103px !important;--image-height: 139px !important;--image-mg-r: 10px !important;margin-right:10px!important;--content-head-title-size: 14px !important;--content-title-mg-b: 0 !important;--content-text-mg-b: 0 !important}.media-card-content-footer-btns{--pgc_btn_size: 13px !important;--pgc_btn_w: 70px !important;--pgc_btn_h: 28px !important}.media-card-content-head-text{line-height:15px!important}.info-card.flex_start{width:100%}.search-logo.p_center_y{display:none}div.wrapper,.content{max-width:100%}div.header.space-search-tip{justify-content:center}.space-search-tip+div{display:none}#navigator-fixed{display:none}#navigator.sticky{position:fixed;top:0;z-index:2;width:100%}#navigator .search-container{display:none}#app:has(>.sticky)>.s-space{padding-top:49px}.n .n-inner{height:auto!important;padding:0!important}.n .n-tab-links{display:flex!important;justify-content:space-evenly}#app .n .n-btn{line-height:unset;margin:0;display:flex;flex-direction:column;align-items:center}#app .n .n-btn .iconfont{margin-right:0}#app .n .n-btn .n-text{line-height:15px;width:26px;white-space:nowrap;overflow:hidden}#app .n .n-btn .n-num{line-height:14px;margin-left:0;text-align:center}.n .n-video.n-audio.n-article.n-album{order:-2}.n .n-dynamic{order:-1}.n .n-channel{order:1}.n .n-favlist{order:2}.n .n-pugv{order:3}.col-1 span.length,.col-2 .elec .elec-hito:nth-child(4),.col-2 .elec .elec-status{z-index:1}#app .h{z-index:1}#app .h .h-action{position:fixed;background-color:#f1f2f3;left:0;bottom:0!important;display:flex;justify-content:space-evenly;align-items:center;opacity:0;transition:calc(var(--actionbar-time)*1.44) ease-in}#app .h .h-action.show{bottom:var(--actionbar-height)!important;opacity:1}[scroll-hidden] #app .h .h-action{transform:translateY(calc(100% + var(--actionbar-height)))}.h .h-action .h-f-btn{margin:10px}.be-dropdown.h-add-to-black{background:#00000073;box-shadow:0 0 0 2px #ffffff4d;border-radius:4px}.h .h-gradient{height:120%!important;background-size:auto 100%}#app .h .h-inner{padding-top:20px}#app .h .h-info{margin:0 10px;padding-bottom:52px}#app .h .h-sign{width:100%;word-break:break-all;height:fit-content;line-height:18px}.n .n-statistics{position:absolute;top:0;transform:translateY(-100%);z-index:10;width:calc(100% - 20px);height:auto!important;display:flex;justify-content:space-evenly;padding:4px 0 5px;margin:0 10px;border-top:1px solid var(--line_regular)}.n .n-statistics .n-data{padding:0 5px;height:auto}.n .n-statistics .n-data-k{color:#fff!important}.n .n-statistics .n-data-v{color:#fffc!important;margin-top:0!important}#page-index .col-1{max-width:calc(100% - 20px);padding:0 10px!important;border:none!important;margin-bottom:10px}.channel-video{white-space:wrap!important}.i-pin-c.cover-big{padding-bottom:5px}.i-pin-c .i-pin-cover{width:100%!important;height:fit-content!important}.i-pin-title{white-space:wrap!important}.i-pin-info{margin-left:0!important;height:auto!important}.i-pin-desc{max-height:unset!important}.section-title{padding:0 5px 33px!important}#page-index .video .be-tab{position:absolute;left:0;transform:translate(calc(50vw - 50%));margin:33px 0 0!important}.be-tab-item{margin:0 5px!important}.section .more,.section-title .play-all-channel{margin-right:5px}#page-index .video .content{max-height:unset!important}#i-masterpiece .i-mp-multi,#i-masterpiece .i-mp-multi .small-item{height:unset}.small-item{width:calc(50% - 10px)!important;padding:5px!important}.small-item .cover{width:100%!important;height:auto!important}.small-item .title{text-align:justify;line-break:anywhere;display:-webkit-box;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2;text-overflow:ellipsis;padding:0 3px}#page-index .channel .channel-item .channel-title{padding:0 5px 34px}#page-index .channel .section-right-options{position:absolute;right:0;bottom:5px}#page-index .col-1 .section.empty:after{left:100px!important}#i-masterpiece{margin-left:0!important}#page-index .fav-item{margin:0 10px!important}#page-fav .fav-main{width:100%!important}.favInfo-details{max-width:60%;margin-left:5px!important}.fav-options>*{margin:0!important}.favList-info{padding:0!important;margin:0 10px!important}#app .to-top{display:none!important}.article-item .clearfix{display:flex}.article-content{min-width:0;padding-right:10px;overflow:hidden}.article-img{flex-shrink:0}.article-content .article-con a{height:54px;line-height:18px;white-space:normal;display:-webkit-box!important;-webkit-box-orient:vertical;line-clamp:3;-webkit-line-clamp:3}h2.article-title{max-height:unset;font-size:17px;line-height:20px}.article-title a{display:-webkit-box!important;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2}.article-content .meta-col{display:flex;justify-content:space-evenly;width:100vw}.article-content .meta-col span{margin-right:0}#page-dynamic .col-1{max-width:100%}div.bili-dyn-item{min-width:0}div.bili-dyn-item__main{padding:0 15px 0 60px}div.bili-dyn-item__avatar{width:60px;height:77px}.bili-dyn-item__body{position:relative;left:-45px;width:calc(100% + 45px)}a.bili-dyn-card-video{border:1px solid var(--line_regular);border-radius:0 6px 6px 0}div.bili-dyn-card-video__header{width:40%;height:fit-content;align-self:center}div.bili-dyn-card-video__body{border:none;min-height:85px;padding:10px 12px 8px}div.bili-dyn-card-video__title{font-size:14px}.bili-album__preview__picture{width:100%!important;height:100%!important}div.bili-album__preview.grid6,div.bili-dyn-action{width:unset}div.bili-dyn-item__footer{position:relative;left:-45px;width:calc(100% + 45px);padding-right:0;justify-content:space-around}div.contribution-sidenav{width:100%}div.contribution-sidenav .contribution-list-container{margin-bottom:10px}.contribution-list{display:flex;justify-content:space-evenly}.contribution-sidenav li.contribution-item{padding-left:0;flex-grow:1;display:flex;justify-content:center;align-items:center}.contribution-sidenav a.text{width:auto}.contribution-sidenav .num{position:absolute;left:calc(50% + 28px);transform:translate(-50%)}.contribution-sidenav~div.main-content{max-width:100%;padding:10px}div.page-head{padding-bottom:33px}#page-video .page-head .be-tab{position:absolute;left:0;transform:translate(calc(50vw - 10px - 50%));margin:33px 0 0}#page-video .cube-list{max-width:100%}#page-video div#submit-video-list{margin-left:0}#page-video div#submit-video-type-filter a{margin-right:0;flex:25%}#submit-video .list .title{white-space:pre-wrap;height:auto;margin:5px 0}#page-video .list-item .cover div.b-img{width:100%;height:auto}#page-video .list-item div.c{margin:0}#page-video .list-item div.desc{margin-bottom:5px}#page-video .list-item div.desc:not(:has(>*)){display:none}#page-video #submit-video-type-filter a{flex-direction:column;line-height:20px;padding:2px 0}#page-video #submit-video-type-filter a span.count{margin-left:0}ul.be-pager{display:flex;flex-wrap:wrap;align-items:center;margin-bottom:var(--actionbar-height)}.be-pager li{width:34px;height:34px;line-height:34px;padding:0}.be-pager>*{margin-bottom:5px}.be-pager li.be-pager-prev,.be-pager li.be-pager-next{overflow:hidden;position:relative}.be-pager li.be-pager-prev:before,.be-pager li.be-pager-next:before{color:#18191c;background-color:inherit;position:absolute;left:0;top:0;font-size:20px;width:34px}.be-pager li.be-pager-prev:before{content:"<"}.be-pager li.be-pager-next:before{content:">"}#page-channel .series-item .video-list{flex-flow:wrap}#page-channel .series-item .video-list li{flex:50%}.video-list div.video-card{width:calc(100% - 10px);padding:5px}div.video-card.card-item .cover{width:100%;height:fit-content}#page-channel .series-item .header .btn{font-size:12px}#page-series-index .channel-list div.channel-item{width:calc(50% - 10px);margin:5px!important}.series-item .btn.play-btn{min-width:60px}.series-item .btn.more-btn{min-width:40px}.s-space .search-page{flex-direction:column;max-width:100%}.s-space .search-page .search-nav{display:flex}div.s-space .search-nav-item{padding-left:0;flex:50%;display:flex;justify-content:center;align-items:center}div.s-space .search-nav-item .text{width:unset}.s-space .search-page .feed-dynamic{max-width:100%;padding:0 12px}div.feed-dynamic .feed-card,div.feed-card .card{min-width:0}div.feed-card .card .main-content{width:calc(100% - 60px);margin-left:60px}div.feed-card .card .user-head{left:0}div.main-content .card-content{position:relative;left:-60px;width:calc(100% + 60px)}div.card-content .imagesbox{max-width:100%}div.card-content .video-container{max-width:100%;height:unset}.video-container .video-wrap{display:flex}div.card-content .video-container .image-area{flex:40%;height:fit-content;align-self:center}div.card-content .video-container .text-area{width:unset;margin:0 8px 0 12px;flex:60%}div.card-content .video-container .text-area .content{margin-top:5px;line-height:16px;height:unset}div.feed-dynamic-content .div-load-more .no-more{margin-bottom:var(--actionbar-height)}div.feed-dynamic-content .div-load-more .no-more .end-img{position:absolute;width:calc(100% + 24px);left:-12px;bottom:0}.h .h-basic{max-width:calc(100% - 82px)}.h #h-sign,.large-item{max-width:100%}div.sec-empty-hint{left:104px;top:3px}#page-follows div.follow-main{max-width:100%;border:none}#page-follows .list-item{padding:10px 0 8px}#page-follows .list-item div.content{padding-right:0;margin-left:75px}#page-follows .list-item .fans-action{top:0}#page-follows .follow-main .list-item p{display:-webkit-box;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2;white-space:unset;font-size:13px;line-height:16px;height:32px;line-break:anywhere;padding:3px 20px 0 0;width:calc(100% - 20px)}div.follow-dialog-wrap .follow-dialog-window{max-width:100%;margin-left:0;transform:translate(-50%,-50%)}div.follow-dialog-wrap .follow-dialog-window .content{padding:0 10px}div.col-full{padding:10px}.content div.pgc-space-follow-page{padding:0 0 var(--actionbar-height)}li.pgc-space-follow-item{width:100%;padding-right:0}div.bangumi-pagelistbox{white-space:pre-wrap;height:auto}.bangumi-pagelistbox>*:not(.custom-right){margin-bottom:5px}.bangumi-pagelistbox a.p{height:34px;line-height:34px;padding:0 8.5px}div.bangumi-pagelistbox strong{height:34px;line-height:34px;width:34px}.bangumi-pagelistbox a.p.prev-page,.bangumi-pagelistbox a.p.next-page{width:34px;padding:0;overflow:hidden;position:relative}.bangumi-pagelistbox a.p.prev-page:before,.bangumi-pagelistbox a.p.next-page:before{color:#18191c;background-color:inherit;position:absolute;left:0;top:0;font-size:20px;width:34px}.bangumi-pagelistbox a.p.prev-page:before{content:"<";padding:1px 14px 13px 0}.bangumi-pagelistbox a.p.next-page:before{content:">";padding:0 12px 14px 2px}div.bangumi-pagelistbox:before{content:""}.section .pugv-container a.pugv-item{width:100%}.section .pugv-container .pugv-item .item-infos p.sub-title{width:100%;white-space:pre-wrap;height:40px;margin-bottom:4px}#page-index div.col-2{width:100%;margin-bottom:var(--actionbar-height)}#page-index .col-2 .section.user-info{margin-bottom:0}#internationalHeader{top:-64px!important;min-width:0!important;position:fixed}#message-navbar{display:none}body>.container{margin-top:0}.space-right{padding-top:calc(32px - var(--actionbar-height)/2)}.container{width:100%!important}div.international-header .nav-search-box{position:absolute;width:100%;left:0;top:64px;padding:10px 20px 5px;z-index:3;margin:0;opacity:0;transform:scale(.9);transition:.4s ease-in;display:none}div.international-header .nav-search-box[show]{opacity:1;transform:none}.space-right-top,.send-box,.count-2 .avatar:first-child{z-index:0!important}.space-left{position:fixed;height:100%;z-index:3;left:-140px;transition:transform .4s ease-in}body>.container[sidebar] .space-left{transform:translate(100%)}.space-left .side-bar{position:absolute;top:50%;transform:translateY(-50%)}.bili-im .left{width:70px!important;transition:width .4s ease-in}.bili-im .left .title{padding-left:10px!important}.bili-im .left .list-item{padding:15px}.bili-im .left .list-item .avatar{margin-right:15px}.bili-im .left .list-container{height:calc(100% - 72px)!important}#unfold-btn{padding-left:22px;line-height:35px;height:36px;border-top:1px solid #e9eaec;-webkit-user-select:none;user-select:none}.list-item .close{width:18px!important}.msg-notify{width:100%!important}.message-list{padding:5px;width:calc(100vw - 90px)}.dynamic-link i{vertical-align:bottom}.msg-item div.message{margin:0}.notify-wrapper{min-height:32px!important}body:has(>#samantha-toast-container){overflow:unset}.bili-im .menu-list{left:unset!important;right:0}.notification-warp{width:100%!important;overflow:auto}body{--shadow-transform: none;--commentbox-display: block}body[scroll-hidden]{--shadow-transform: translateY(calc(100% + var(--actionbar-height)))}#app{--sidebar-time: .6s}#app #mirror-vdcon{min-width:0;padding:0;margin-top:56.25vw}#app,#mirror-vdcon{height:100%}.left-container,.playlist-container--left{--video-min-height: 56.25vw ;--dm-row-height: 40px}.left-container,.playlist-container--left{box-sizing:border-box;width:100%!important;padding:calc(var(--dm-row-height) + 5px) 10px 10px;background:#fff}.left-container:after,.playlist-container--left:after{content:"";position:fixed;top:0;left:0;width:100%;height:100%;pointer-events:none;background-color:#0000004d;opacity:0;transition:opacity var(--sidebar-time) ease-in}.playlist-container--left{z-index:1}#mirror-vdcon[sidebar] .left-container:after #mirror-vdcon[sidebar] .playlist-container--left:after{pointer-events:auto;opacity:1}.right-container,.playlist-container--right{position:fixed!important;width:100%!important;left:100%;padding:10px 10px calc(var(--actionbar-height) + 10px)!important;margin:0!important;z-index:1;background:#fff;transition:transform var(--sidebar-time) ease-in;height:calc(100% - 56.25vw);overflow-y:auto;overscroll-behavior:contain;box-sizing:border-box}#mirror-vdcon[sidebar] .right-container,#mirror-vdcon[sidebar] .playlist-container--right{transform:translate(-100%)}.right-container-inner{padding:0!important}.upinfo-btn-panel .default-btn{font-size:12px!important}.new-charge-btn{max-width:35%}.follow-btn{max-width:150px!important}div.multi-page-v1 .cur-list{overflow-y:auto}.cur-list ul.list-box li{width:100%!important}.cur-list ul.module-box.clearfix{margin:5px 10px}.cur-list ul.module-box li{width:23%!important;margin:2% 1%!important}#reco_list .card-box .pic-box{max-width:50%}.rec-footer{display:none}.base-video-sections-v1 a.first-line-title{white-space:wrap!important;display:-webkit-box!important;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2}#activity_vote,#bannerAd,.reply-notice,.ad-report,.pop-live-small-mode,#slide_ad,.video-page-game-card-small{display:none!important}#playerWrap{position:fixed;z-index:61;top:0;left:0;height:56.25vw!important}#bilibili-player{width:100vw!important;height:56.25vw!important}#bilibili-player.mode-webscreen{width:100%!important;height:100%!important}.bpx-player-container,#bilibili-player-placeholder{box-shadow:none!important}#app .bpx-player-video-perch{max-height:0}.bpx-player-top-wrap,.bpx-player-state-wrap{display:none!important}.bpx-player-toast-wrap{display:block!important;bottom:65px!important}.bpx-player-ending-wrap[hidden]{display:block!important}div.bpx-player-container[data-screen=web] .bpx-player-ending-content{margin-left:-268px;width:536px}.bpx-player-ending-functions-follow{width:auto!important;padding:0 15px!important}.bpx-player-ending-functions-btn[data-action=restart]{padding-right:15px!important}.bpx-player-ending-functions-pagecallback{margin-left:5px!important}.bpx-player-ending-functions-pagecallback .bpx-player-ending-functions-btn{margin-left:10px!important}@media screen and (orientation: landscape){.bpx-player-ending-functions-btn[data-action=restart]{padding-right:42px!important}.bpx-player-ending-functions-pagecallback{margin-left:14px!important}.bpx-player-ending-functions-pagecallback .bpx-player-ending-functions-btn{margin-left:28px!important}}.bpx-player-ending-related-item-countdown{margin-top:34px!important;width:48px!important}.bpx-player-ending-functions-upinfo{height:56px!important;margin-top:0!important}.bui-swiper~.bpx-player-ending-related{height:109px!important}.bpx-player-sending-area{position:absolute!important;bottom:0;width:100%;transform:translateY(100%);transition:.5s transform ease-in;display:block!important;z-index:0}[scroll-hidden] .bpx-player-sending-area{transform:none}.bpx-player-video-area{z-index:1}.bpx-player-container[data-screen=mini]{overflow:unset!important}.bpx-player-sending-bar-left,.bpx-player-sending-bar-right,#bilibili-player-placeholder-bottom{display:none!important}div.bpx-player-sending-bar{height:var(--dm-row-height)}.bpx-player-sending-area .bpx-player-sending-bar{-webkit-backdrop-filter:blur(3px);backdrop-filter:blur(3px);background-color:#fff9!important}.bpx-player-dm-input{height:26px!important}.bpx-player-video-inputbar{height:26px!important;border-radius:13px!important;min-width:0!important}.bpx-player-video-inputbar-wrap{width:100%!important}.bpx-player-dm-btn-send{display:none!important}.bpx-player-video-inputbar-wrap:has(>input:focus)+.bpx-player-dm-btn-send{display:flex!important}.bpx-player-dm-btn-send{border-radius:0 13px 13px 0!important;height:26px!important;min-width:50px!important;width:50px!important}.bui-button-blue{min-width:50px!important}.bpx-player-video-info{margin-right:6px!important}.bpx-player-video-info-divide,.bpx-player-video-info-dm,.bpx-player-dm-hint{display:none!important}.video-info-container{height:auto!important;padding-top:0!important}.video-title,.video-title-href{font-size:18px!important;white-space:wrap!important;display:-webkit-box!important;-webkit-box-orient:vertical;line-clamp:2;-webkit-line-clamp:2;margin-right:0!important}.show-more{top:unset!important;transform:none!important;bottom:4px;right:4px!important}.video-desc-container{margin:10px 0!important}.video-info-detail-list .item{margin-right:4px!important}.pubdate-ip{display:inline-flex!important}.video-info-detail-list:has(.honor.item){margin-top:24px}.video-info-detail-list:has(.video-argue.item){margin-bottom:20px}div:not(.overflow-panel)>div>.honor.item{position:absolute;align-self:start!important;top:0}.video-argue.item{position:absolute;align-self:start!important;bottom:0;display:block!important}.overflow-panel .video-argue.item{max-width:calc(100% - 32px)}.video-toolbar-container{padding:10px 0 8px!important}.video-toolbar-left,.video-toolbar-left-main{min-width:0}.toolbar-left-item-wrap{flex:1;min-width:0}.video-toolbar-container *{margin:0!important}.toolbar-left-item-wrap span{padding-left:2px}.video-share-info{width:40px!important}.video-share-popover,.video-ai-assistant-badge{display:none!important}.video-toolbar-right div.video-ai-assistant.disabled:after{left:180%;transform:translate(-100%)}div.resizable-component.resizable-component{width:100%!important;left:0!important;height:fit-content!important;max-height:100vw;top:50%!important;transform:translateY(-50%);border-radius:12px!important}div.ai-summary-popup{max-height:inherit;border-radius:12px}#v_desc .toggle-btn{text-align:right;margin-right:7px}.basic-desc-info[style="height: 84px;"]{height:70px!important}.video-tag-container{margin:6px 0 0!important;padding-bottom:1px!important}.tag-panel .tag{margin-bottom:6px!important}.bili-user-profile,body>.usercard-wrap{display:none!important}.back-to-top{border-radius:0 25% 25% 0!important;border-left:0!important;margin-bottom:0!important;width:42px!important;border-color:var(--line_regular)!important;visibility:visible!important;transform:translate(-100%);transition:transform .5s ease-in-out,background-color .3s!important}.back-to-top[show]{transform:none}#app .fixed-sidenav-storage .fixed-sidenav-storage-item:hover{background-color:var(--bg1_float);color:var(--text1);fill:var(--text1)}div#app .fixed-sidenav-storage .fixed-sidenav-storage-item[touch-active]{background:var(--graph_bg_thick)}.fixed-sidenav-storage{left:0;right:unset!important;bottom:90px!important;z-index:1!important;opacity:1;transition:opacity var(--sidebar-time) ease-in}#mirror-vdcon[sidebar] .fixed-sidenav-storage{opacity:0}.mini-player-window{position:fixed;z-index:-10;visibility:hidden}.customer-service,.bpx-player-ctrl-pip,.bpx-player-ctrl-wide,.bpx-player-ctrl-time,.bpx-player-ctrl-eplist{display:none!important}@media screen and (orientation: landscape){.bpx-player-ctrl-time{display:block!important}}@media screen and (min-width: 750px){.bpx-player-container[data-screen=full] .bpx-player-ctrl-quality-result{font-size:16px!important;height:unset!important}}@media screen and (min-width: 750px){.bpx-player-container[data-screen=full] .bpx-player-control-wrap{height:43px!important}.bpx-player-container[data-screen=full] .bpx-player-control-top{bottom:43px!important}}div.bpx-player-control-bottom{height:29px!important;margin-top:7px!important;padding:0 7px!important}div.bpx-player-control-top{bottom:36px;transition:none}.bpx-player-pbp .bpx-player-pbp-pin-tip{display:none!important}.bpx-player-control-bottom-left,.bpx-player-control-bottom-right{flex:unset!important}.bpx-player-container .bpx-player-control-bottom-left,.bpx-player-container .bpx-player-control-bottom-right{min-width:0!important}.bpx-player-ctrl-quality{margin-right:0!important;min-width:0;flex:auto!important}.bpx-player-ctrl-quality-result,.bpx-player-ctrl-playbackrate{font-size:12px!important}.bpx-player-ctrl-quality-result{height:22px;overflow:hidden}.bpx-player-ctrl-playbackrate{text-wrap:nowrap}.bpx-player-progress-wrap{height:7px!important;padding-bottom:3px!important}.bpx-player-control-mask{background:linear-gradient(to bottom,#0000,#00000080)!important}.bpx-player-ctrl-quality-menu-wrap{bottom:22px!important}.bpx-player-ctrl-quality-menu-item{height:7.7vw!important;max-height:36px;max-width:95px;padding:0 8px 0 12px!important}.bpx-player-ctrl-quality-badge-bigvip{background-color:#f25d8e;color:#fff;width:16px;overflow:hidden;right:8px!important}.bpx-player-ctrl-quality-badge-bigvip:before{background-color:#f25d8e;color:#fff;content:"V";padding:0 4px;position:absolute;left:0}.bpx-player-ctrl-playbackrate-menu{bottom:22px!important}.bpx-player-ctrl-playbackrate-menu-item{height:7.7vw!important;max-height:36px;display:flex;justify-content:center;align-items:center}div.bpx-player-ctrl-subtitle-box{bottom:0;right:0;transform:scale(.8)}.bpx-player-ctrl-setting-box{right:0!important;bottom:0!important}.bpx-player-ctrl-setting-menu-right{padding:5px!important}.bpx-player-ctrl-setting-menu-right>div{height:10vw!important;max-height:40px;display:flex;justify-content:center;align-items:center}.bpx-player-ctrl-setting-menu-right .bui-radio{margin:0 0 8px 7px;width:77%}.bpx-player-ctrl-setting-others-content{width:77%!important;margin-left:7px}.bpx-player-ctrl-setting-highenergy .bui-checkbox-name{white-space:nowrap;width:48px;overflow:hidden}.bpx-player-dm-setting-wrap{bottom:unset!important;top:0;position:fixed!important;left:50%;transform:translate(-50%)}.bpx-player-control-bottom-center .bpx-player-sending-bar{padding-right:6px!important;height:24px!important}.bpx-player-ctrl-viewpoint{margin:0!important;min-width:0!important;width:45px!important;flex-shrink:1!important}.bpx-player-ctrl-viewpoint-text{width:24px!important;text-overflow:unset!important;font-size:12px;flex:none}.bpx-player-control-wrap:not(.new){display:none}.bpx-player-control-entity,.bpx-player-control-mask{display:block!important}.bpx-player-container[data-ctrl-hidden=true] .bpx-player-control-bottom{display:none}.bpx-player-container[ctrl-shown=false] .bpx-player-control-wrap .bpx-player-control-mask{opacity:0;transition:opacity .2s ease-in}.bpx-player-container[ctrl-shown=true] .bpx-player-control-wrap .bpx-player-control-mask{opacity:1}.bpx-player-container[ctrl-shown=true] .bpx-player-control-entity .bpx-player-control-bottom{opacity:1;display:flex}.bpx-player-container[ctrl-shown=false] .bpx-player-control-entity .bpx-player-control-bottom{display:none}.bpx-player-container[ctrl-shown=true] .bpx-player-control-entity .bpx-player-control-top,.bpx-player-container[ctrl-shown=false] .bpx-player-control-entity .bpx-player-shadow-progress-area{opacity:1;visibility:visible}.bpx-player-container[ctrl-shown=false] .bpx-player-control-entity .bpx-player-control-top,.bpx-player-container[ctrl-shown=true] .bpx-player-control-entity .bpx-player-shadow-progress-area{opacity:0;visibility:hidden}.bpx-player-container[ctrl-shown=true] .bpx-player-control-entity .bpx-player-pbp{bottom:calc(100% + 6px);left:0;opacity:1;width:100%}div.bpx-player-control-entity .bpx-player-pbp{bottom:1px;opacity:0;left:-12px;width:calc(100% + 24px)}div.bpx-player-control-entity .bpx-player-pbp.pin{opacity:1}.bpx-player-pbp-pin{opacity:1!important;display:none}.bpx-player-container[ctrl-shown=true] .bpx-player-control-entity .bpx-player-pbp-pin{display:block}.article-detail,.article-breadcrumb,.article-up-info{max-width:100%}div.article-container{padding:10px}.title-container{padding:0!important}#article-content{max-width:100%;padding:0}figure.img-box{min-width:0!important;min-height:0!important}img.normal-img{height:auto!important} ');
(function () {
'use strict';
var _GM_getValue = /* @__PURE__ */ (() => typeof GM_getValue != "undefined" ? GM_getValue : void 0)();
var _GM_registerMenuCommand = /* @__PURE__ */ (() => typeof GM_registerMenuCommand != "undefined" ? GM_registerMenuCommand : void 0)();
var _GM_setValue = /* @__PURE__ */ (() => typeof GM_setValue != "undefined" ? GM_setValue : void 0)();
var _unsafeWindow = /* @__PURE__ */ (() => typeof unsafeWindow != "undefined" ? unsafeWindow : void 0)();
const handleTransitionEndOnce = (element, propertyName, callback) => {
const handleTransitionEnd = (event) => {
if (event.propertyName === propertyName) {
callback();
element.removeEventListener("transitionend", handleTransitionEnd);
}
};
element.addEventListener("transitionend", handleTransitionEnd);
};
function setupSlide(container, touchXThreshold, onSlideLeft, onSlideRight, removeListener) {
let startX = 0;
let startY = 0;
const handleTouchStart = (event) => {
startX = event.changedTouches[0].clientX;
startY = event.changedTouches[0].clientY;
};
const handleTouchEnd = (event) => {
const offsetX = event.changedTouches[0].clientX - startX;
const offsetY = event.changedTouches[0].clientY - startY;
if (Math.abs(offsetX) > touchXThreshold && Math.abs(offsetY / offsetX) < 1 / 2) {
if (offsetX > 0) {
onSlideRight();
} else {
onSlideLeft();
}
}
};
{
container.addEventListener("touchstart", handleTouchStart);
container.addEventListener("touchend", handleTouchEnd);
}
}
function preventBeforeUnload() {
const originalAddEventListener = window.addEventListener;
window.addEventListener = (type, listener, options) => type === "beforeunload" || originalAddEventListener.call(window, type, listener, options);
}
function increaseVideoLoadSize() {
const _unsafeWindow$1 = typeof _unsafeWindow !== "undefined" ? _unsafeWindow : window;
const originalFetch = _unsafeWindow$1.fetch;
_unsafeWindow$1.fetch = (input, init) => {
if (typeof input === "string" && input.startsWith("https://api.bilibili.com") && input.includes("feed/rcmd")) {
input = input.replace("&ps=12&", "&ps=30&");
}
return originalFetch(input, init);
};
}
function countViewTime() {
window.onload = function() {
let storedTime = _GM_getValue("view-time", 0);
const storedTimestamp = _GM_getValue("timestamp", Date.now());
const diff = Math.floor((Date.now() - storedTimestamp) / 1e3 / 60);
storedTime = diff < 3 ? storedTime + diff : 0;
function renewTime() {
_GM_setValue("view-time", storedTime);
_GM_setValue("timestamp", Date.now());
}
renewTime();
setInterval(function() {
storedTime++;
renewTime();
if (storedTime % 120 === 0) {
const fullscreenElem = document.fullscreenElement;
if (fullscreenElem && !fullscreenElem.querySelector(":scope>#toast")) {
fullscreenElem.appendChild(
document.querySelector("#toast").cloneNode()
);
}
const toasts = document.querySelectorAll(
"#toast"
);
toasts.forEach((toast) => {
toast.textContent = `您已连续浏览 ${storedTime / 60} 小时,请注意休息`;
toast.style.display = "block";
setTimeout(() => {
toast.setAttribute("show", "");
}, 10);
setTimeout(() => {
toast.removeAttribute("show");
handleTransitionEndOnce(toast, "opacity", () => {
toast.style.cssText = "";
});
}, 5e3);
});
}
}, 6e4);
};
}
function handleScroll(type) {
scrollToHidden(type);
switch (type) {
case "search":
slideSearchSort();
break;
case "video":
case "list":
slideVideoSidebar();
break;
case "message":
slideMessageSidebar();
break;
case "space":
handleSpaceSwipe();
break;
}
}
function scrollToHidden(type) {
let lastScrollY = 0;
const scrollThreshold = 75;
const backup = document.getElementsByClassName(
"back-to-top"
)[0];
const videoMap = {
video: ".left-container",
list: ".playlist-container--left"
};
let elem;
if (["video", "list"].includes(type)) {
const container = document.querySelector(
videoMap[type]
);
if (container) elem = container;
}
window.addEventListener("scroll", () => {
const currentScrollY = window.scrollY;
const offsetY = currentScrollY - lastScrollY;
if (currentScrollY < scrollThreshold) {
document.body.removeAttribute("scroll-hidden");
}
if (Math.abs(offsetY) > scrollThreshold) {
if (offsetY > 0) {
document.body.setAttribute("scroll-hidden", "");
} else {
document.body.removeAttribute("scroll-hidden");
}
lastScrollY = currentScrollY;
}
if (["video", "list"].includes(type)) {
if (currentScrollY > elem.clientHeight) {
backup == null ? void 0 : backup.setAttribute("show", "");
} else {
backup == null ? void 0 : backup.removeAttribute("show");
}
}
});
if (["video", "list"].includes(type)) {
backup.addEventListener("click", () => {
elem.scrollTo({ top: 0, behavior: "smooth" });
backup.setAttribute("touch-active", "");
handleTransitionEndOnce(
backup,
"transform",
() => backup.removeAttribute("touch-active")
);
});
}
}
function slideVideoSidebar() {
const videoContainer = document.querySelector("#mirror-vdcon");
setupSlide(
videoContainer,
55,
() => {
if (!videoContainer.hasAttribute("sidebar")) {
videoContainer.setAttribute("sidebar", "");
}
},
() => {
if (videoContainer.hasAttribute("sidebar")) {
videoContainer.removeAttribute("sidebar");
}
}
);
}
function slideSearchSort() {
let clickIndex = 3;
const navItems = [4, 3, 2, 1, 7, 6, 5];
const container = document.querySelector("#i_cecream");
function clickSortTab() {
document.querySelector(
`.vui_tabs--nav-item:nth-child(${navItems[clickIndex]})`
).click();
}
setupSlide(
container,
55,
() => {
clickIndex++;
clickSortTab();
},
() => {
clickIndex--;
clickSortTab();
}
);
}
function slideMessageSidebar() {
const messageContainer = document.querySelector(
"body>.container"
);
const sidebarOverlay = document.querySelector(
"#sidebar-overlay"
);
const sidebarFab = document.querySelector("#sidebar-fab");
function show() {
messageContainer.setAttribute("sidebar", "");
sidebarOverlay.classList.add("show");
sidebarFab.classList.add("active");
}
function hide() {
messageContainer.removeAttribute("sidebar");
sidebarOverlay.classList.remove("show");
sidebarFab.classList.remove("active");
}
function slideLeft() {
const isSidebarRight = _GM_getValue("message-sidebar-change-right", false);
if (isSidebarRight && !messageContainer.hasAttribute("sidebar")) show();
if (!isSidebarRight && messageContainer.hasAttribute("sidebar")) hide();
}
function slideRight() {
const isSidebarRight = _GM_getValue("message-sidebar-change-right", false);
if (isSidebarRight && messageContainer.hasAttribute("sidebar")) hide();
if (!isSidebarRight && !messageContainer.hasAttribute("sidebar")) show();
}
setupSlide(messageContainer, 55, slideLeft, slideRight);
setupSlide(sidebarOverlay, 55, slideLeft, slideRight);
}
function handleSpaceSwipe() {
const observer = new MutationObserver((mutationsList) => {
mutationsList.forEach((mutation) => {
mutation.addedNodes.forEach((addedNode) => {
if (addedNode.nodeType === Node.ELEMENT_NODE && addedNode.id === "app") {
setTimeout(scrollToStick, 50);
slideSpaceNavigator();
observer.disconnect();
}
});
});
});
observer.observe(document.body, { childList: true });
function scrollToStick() {
const navigator = document.querySelector("#navigator");
const threshold = navigator.getBoundingClientRect().top;
let isStuck = false;
window.addEventListener("scroll", () => {
if (isStuck !== window.scrollY > threshold) {
navigator.classList.toggle("sticky");
isStuck = !isStuck;
}
});
}
function slideSpaceNavigator() {
const current = document.querySelector("#navigator .active");
const siblings = Array.from(
document.querySelectorAll("#navigator .n-btn")
).sort((a, b) => {
return parseInt(getComputedStyle(a).order) - parseInt(getComputedStyle(b).order);
});
let index = siblings.findIndex((el) => el === current);
const container = document.querySelector("#app");
setupSlide(
container,
55,
() => {
index++;
siblings[index].click();
},
() => {
index--;
siblings[index].click();
}
);
}
}
const waitDOMContentLoaded = (callback) => {
if (document.readyState === "loading")
document.addEventListener("DOMContentLoaded", callback);
else callback();
};
function appendStyle(id, textContent) {
const style = Object.assign(document.createElement("style"), {
id,
textContent
});
document.head.appendChild(style);
}
function homeSingleColumn() {
appendStyle(
"home-single-column",
`
div.recommended-container_floor-aside .container {
grid-template-columns: repeat(1, 1fr) !important;
}
div.bili-video-card.is-rcmd,
div.bili-live-card.is-rcmd {
--cover-radio: 56.25% !important;
}
.bili-live-card__skeleton--right {
height: 70px;
}
div.recommended-container_floor-aside .container {
padding: 15px 0;
grid-gap: 15px !important;
background-color: white;
}
picture.v-img.bili-video-card__cover, picture.v-img.bili-live-card__cover {
border-radius: 0 !important;
}
div.bili-video-card__wrap, div.bili-live-card__wrap {
border-radius: 0;
}
div.bili-video-card__info,
div.bili-live-card__info {
--title-padding-right: 30px;
--no-interest-entry-size: 30px;
}
`
);
}
function foldDescTag$1() {
appendStyle(
"fold-desc-tag",
`
#v_desc,#v_tag{
max-height: 0;
overflow: hidden;
margin: 0 !important;
padding: 0 !important;
}
.left-container-under-player[unfold] #v_desc,
.left-container-under-player[unfold] #v_tag{
max-height: unset;
padding: 5px 0 !important;
}
#fold-desc-btn {
height: 24px;
transform: rotate(180deg);
transition: transform .4s ease-in;
position: absolute;
right: 10px;
margin-top: 5px;
background-color: rgba(255,255,255,0.6);
border: 1px solid var(--line_regular);
border-radius: 50%;
padding: 2px;
}
.left-container-under-player[unfold] #fold-desc-btn{
transform: none;
}
`
);
}
function handleScriptPreSetting() {
const defaultValue = Array(11).fill(false);
const css = {
css1: `
.bpx-player-sending-area.bpx-player-sending-area {display:none !important;}
.left-container.left-container {padding:5px 10px 10px;}
html body {--commentbox-display: none;}
`,
css2: ".video-tag-container {display:none !important;}",
css3: `
.video-info-meta div.copyright.item {display: none;}
.video-info-meta a.honor.item {display: none;}
.video-info-meta .video-info-detail-list:has(.honor.item) {margin-top: 0;}
.video-info-meta .video-argue.item {display: none !important;}
.video-info-meta .video-info-detail-list:has(.video-argue.item) {margin-bottom: 0;}
`,
css4: ".trending {display:none;}",
css5: ".bpx-player-ctrl-volume, .bpx-player-ctrl-full, .bpx-player-ctrl-web {display: none;}",
css6: `
.bili-footer {display: none;}
.vui_pagenation {padding-bottom: var(--actionbar-height);}
`,
css7: ".fixed-sidenav-storage, div.float-nav-exp {display: none !important;}",
css8: ".bili-live-card {display: none !important;}",
css9: ".bangumi-pgc-list {display: none;}",
css10: "#danmukuBox {display: none;}",
css11: "div.bpx-player-toast-wrap {display: none !important;}"
};
readScriptSetting();
if (_GM_getValue("home-single-column", false)) {
homeSingleColumn();
}
if (_GM_getValue("fold-desc-tag", false)) {
foldDescTag$1();
}
waitDOMContentLoaded(() => {
createSettingPanel();
_GM_registerMenuCommand("元素隐藏设置", () => {
const settingPanel = document.getElementById(
"setting-panel-style"
);
settingPanel.style.display = "flex";
setTimeout(() => {
settingPanel.setAttribute("show", "");
}, 10);
});
});
function readScriptSetting(diference = void 0) {
var _a;
const settingShowHidden = _GM_getValue(
"settingShowHidden",
defaultValue
);
const values = Object.values(css);
if (diference) {
for (const [index, value] of diference.entries()) {
if (value) {
if (settingShowHidden[index]) {
appendStyle(`script-pre-style-${index}`, values[index]);
} else {
(_a = document.getElementById(`script-pre-style-${index}`)) == null ? void 0 : _a.remove();
}
}
}
} else {
for (const [index, value] of values.entries()) {
if (settingShowHidden[index]) {
appendStyle(`script-pre-style-${index}`, value);
}
}
}
}
function createSettingPanel() {
const settingPanel = Object.assign(document.createElement("div"), {
id: "setting-panel-style",
className: "setting-panel",
innerHTML: `
隐藏元素
`
});
document.body.appendChild(settingPanel);
const checkboxElements = settingPanel.querySelectorAll(
'.setting-checkboxes input[type="checkbox"]'
);
const oldValues = _GM_getValue(
"settingShowHidden",
defaultValue
);
for (const [index, element] of Array.from(checkboxElements).entries()) {
element.checked = oldValues[index];
}
settingPanel.querySelector("#setting-conform-1").addEventListener("click", () => {
const oldValues2 = _GM_getValue(
"settingShowHidden",
defaultValue
);
const selectedValues = Array.from(checkboxElements).map(
(checkbox) => checkbox.checked
);
_GM_setValue("settingShowHidden", selectedValues);
const difference = selectedValues.map(
(value, index) => value !== oldValues2[index]
);
readScriptSetting(difference);
settingPanel.removeAttribute("show");
settingPanel.addEventListener(
"transitionend",
() => {
settingPanel.style.cssText = "";
},
{ once: true }
);
});
}
}
function handleScriptSetting() {
const keyValues = {
"ban-video-click-play": "禁用点击视频播放/暂停",
"allow-video-slid": "视频滑动调整进度",
"fold-desc-tag": "折叠简介和标签",
"video-click-unmute": "视频页点击空白解除静音",
"ban-actionbar-hidden": "禁止底栏滚动时隐藏",
"message-sidebar-change-right": "消息页侧边栏靠右",
"cover-context-menu": "覆盖消息页长按弹窗",
"home-single-column": "首页单列推荐",
"menu-dialog-move-down": "菜单弹窗(收藏、历史等)靠下"
};
const customKeyValues = {
"menu-dialog-move-down-value": "20",
"video-longpress-speed": "2",
"header-image-source": "unsplash"
// 与 home.js 保持一致
};
const customKeyNames = {
"menu-dialog-move-down-value": "自定义菜单弹窗底边距",
"video-longpress-speed": "自定义视频长按倍速",
"header-image-source": "主页头图换源"
};
const menuOptions = {
key: "modify-menu-options",
value: [true, true, ...Array(6).fill(false)],
names: ["热门", "分类", "消息", "动态", "收藏", "历史", "主页", "关注"]
// 菜单选项排序
};
initSettings();
createSettingPanel();
_GM_registerMenuCommand("操作偏好设置", () => {
const settingPanel = document.getElementById(
"setting-panel-preference"
);
settingPanel.style.display = "flex";
setTimeout(() => {
settingPanel.setAttribute("show", "");
}, 10);
});
function initSettings() {
if (_GM_getValue("ban-actionbar-hidden", false)) {
banActionbarHidden();
}
if (_GM_getValue("message-sidebar-change-right", false)) {
messageSidebarRight();
}
if (_GM_getValue("menu-dialog-move-down", false)) {
menuDialogMoveDown();
}
if (!_GM_getValue(menuOptions.key, menuOptions.value).every(
(item) => item === false
)) {
modifyMenuOptions();
}
}
function banActionbarHidden() {
appendStyle(
"ban-actionbar-hidden",
`
[scroll-hidden] #actionbar,
[scroll-hidden] .flexible-roll-btn-inner, /* 刷新、回顶 */
[scroll-hidden] .top-btn {
transform: none !important;
}
`
);
}
function messageSidebarRight() {
appendStyle(
"message-sidebar-change-right",
`
.space-left.space-left { left: 100%; }
body>.container[sidebar] .space-left.space-left { transform: translateX(-100%); }
`
);
}
function menuDialogMoveDown() {
const downValue = _GM_getValue("menu-dialog-move-down-value", "20");
appendStyle(
"menu-dialog-move-down-value",
`
div.bili-header .v-popover.v-popover {
top: unset !important;
bottom: var(--actionbar-height);
transform: translate(-50%, -${downValue}px) scale(.9);
}
div.bili-header .v-popover.v-popover[show] {
transform: translate(-50%, -${downValue}px) !important;
}
`
);
}
function modifyMenuOptions() {
const options = _GM_getValue(menuOptions.key, menuOptions.value);
let selector = "";
options.forEach((value, index) => {
if (value) {
selector += `#header-in-menu ul li:nth-of-type(${index + 1}), `;
}
});
appendStyle(
"modify-menu-options",
`${selector.slice(0, -2)} { display: none; }`
);
}
function createSettingPanel() {
const settingPanel = Object.assign(document.createElement("div"), {
id: "setting-panel-preference",
className: "setting-panel",
innerHTML: `
操作偏好
${Object.entries(keyValues).map(
([key, value]) => `
`
).join("")}
${Object.entries(customKeyValues).filter(([key]) => key !== "header-image-source").map(
([key, value]) => `
`
).join("")}
`
});
document.body.appendChild(settingPanel);
const checkboxElements = settingPanel.querySelectorAll(
'.setting-checkboxes input[type="checkbox"]'
);
const customElements = settingPanel.querySelectorAll(
'.setting-checkboxes input[type="number"], .setting-checkboxes select'
);
checkboxElements.forEach((checkbox, index) => {
checkbox.checked = _GM_getValue(
Object.keys(keyValues)[index],
false
);
});
customElements.forEach((elem, index) => {
elem.value = _GM_getValue(
Object.keys(customKeyValues)[index],
Object.values(customKeyValues)[index]
);
});
settingPanel.querySelector("#setting-conform-2").addEventListener("click", () => {
const selectedValues = Array.from(checkboxElements).map(
(checkbox) => checkbox.checked
);
const writenValues = Array.from(customElements).map(
(elem) => elem.value
);
selectedValues.forEach((value, index) => {
var _a, _b, _c, _d;
const key = Object.keys(keyValues)[index];
if (value !== _GM_getValue(key, false)) {
_GM_setValue(key, value);
switch (key) {
case "ban-actionbar-hidden":
if (value) banActionbarHidden();
else (_a = document.getElementById(key)) == null ? void 0 : _a.remove();
break;
case "message-sidebar-change-right":
if (value) messageSidebarRight();
else (_b = document.getElementById(key)) == null ? void 0 : _b.remove();
break;
case "menu-dialog-move-down":
if (value) menuDialogMoveDown();
else (_c = document.getElementById(`${key}-value`)) == null ? void 0 : _c.remove();
break;
case "home-single-column":
if (value) homeSingleColumn();
else (_d = document.getElementById(key)) == null ? void 0 : _d.remove();
break;
}
}
});
writenValues.forEach((value, index) => {
var _a;
const key = Object.keys(customKeyValues)[index];
if (value !== _GM_getValue(key, Object.values(customKeyValues)[index])) {
_GM_setValue(key, value);
if (key === "menu-dialog-move-down-value") {
(_a = document.getElementById(key)) == null ? void 0 : _a.remove();
menuDialogMoveDown();
} else if (key === "header-image-source" && value !== "local") {
window.dispatchEvent(
new CustomEvent("variableChanged", {
detail: { key, newValue: value }
})
);
}
}
});
settingPanel.removeAttribute("show");
settingPanel.addEventListener(
"transitionend",
() => {
settingPanel.style.cssText = "";
},
{ once: true }
);
});
settingPanel.querySelector(".header-image-source").addEventListener("change", (event) => {
if (event.target.value === "local") {
const input = document.createElement("input");
input.type = "file";
input.accept = "image/*";
input.addEventListener("change", () => {
const file = input.files[0];
const reader = new FileReader();
reader.readAsDataURL(file);
reader.onload = () => {
const base64Data = reader.result;
localStorage.setItem("header-image", base64Data.toString());
};
});
input.click();
}
});
settingPanel.querySelector(".modify-menu-options").addEventListener("click", () => {
const settingPanel2 = Object.assign(document.createElement("div"), {
id: "setting-panel-modify-menu-options",
className: "setting-panel mini",
innerHTML: `
隐藏选项
${menuOptions.names.map(
(name, index) => `
`
).join("")}
`
});
document.body.appendChild(settingPanel2);
const checkboxElements2 = settingPanel2.querySelectorAll(
'.setting-checkboxes input[type="checkbox"]'
);
const oldValues = _GM_getValue(
menuOptions.key,
menuOptions.value
);
checkboxElements2.forEach((element, index) => {
element.checked = oldValues[index];
});
settingPanel2.querySelector("#setting-conform-3").addEventListener("click", () => {
var _a;
const selectedValues = Array.from(checkboxElements2).map(
(checkbox) => checkbox.checked
);
if (selectedValues !== oldValues) {
_GM_setValue(menuOptions.key, selectedValues);
(_a = document.head.querySelector("#modify-menu-options")) == null ? void 0 : _a.remove();
modifyMenuOptions();
}
settingPanel2.remove();
});
});
}
}
function setScriptHelp() {
createSettingPanel();
_GM_registerMenuCommand("脚本说明", () => {
const settingPanel = document.getElementById(
"setting-panel-help"
);
settingPanel.style.display = "flex";
setTimeout(() => {
settingPanel.setAttribute("show", "");
}, 10);
});
function createSettingPanel() {
const settingPanel = Object.assign(document.createElement("div"), {
id: "setting-panel-help",
className: "setting-panel",
innerHTML: `
脚本说明
视频页:双击全屏按钮竖屏播放,左右滑动切换侧边栏
搜索页:双击搜索按钮清空输入框,左右滑动切换分类
个人空间:双击搜索按钮全局搜索,左右滑动切换分类
作者持续改进和处理反馈,Github 仓库、电报吹水群
Firefox 推荐扩展:User Agent Switcher
更多自定义功能,请查看脚本设置
`
});
document.body.appendChild(settingPanel);
settingPanel.querySelector("#setting-conform-3").addEventListener("click", () => {
settingPanel.removeAttribute("show");
settingPanel.addEventListener(
"transitionend",
() => {
settingPanel.style.cssText = "";
},
{ once: true }
);
});
if (_GM_getValue("is-first-use", true)) {
settingPanel.style.display = "flex";
setTimeout(() => {
settingPanel.setAttribute("show", "");
}, 10);
_GM_setValue("is-first-use", false);
}
}
}
function setSearchBtn(type) {
const searchFab = document.getElementById("search-fab");
const svg = searchFab.querySelector("svg");
const searchOverlay = document.createElement("div");
searchOverlay.id = "search-overlay";
searchFab.appendChild(searchOverlay);
const searchContainerSelector = ".center-search-container";
let clickTimer = 0;
function handleClick(input2) {
const searchContainer = document.querySelector(
`${searchContainerSelector}`
);
searchContainer.style.cssText = "display: block !important";
setTimeout(() => {
searchContainer.setAttribute("show", "");
}, 10);
input2.focus();
searchOverlay.classList.add("show");
searchFab.classList.add("active");
}
let input;
if (type !== "search" && type !== "space") {
searchFab.addEventListener("click", () => {
const inputElem = document.querySelector(
`${searchContainerSelector} input`
);
if (inputElem) {
input = inputElem;
} else return;
handleClick(input);
});
}
if (type === "search") {
const typeInput = document.querySelector(
".search-input input"
);
const searchFabText = Object.assign(document.createElement("div"), {
id: "search-fab-text",
textContent: typeInput.value
});
searchFab.appendChild(searchFabText);
searchFab.style.cssText = "background-color: var(--graph_bg_thick); border-radius: 16px;";
svg.style.flex = "0 0 20px";
const handleInput = () => {
if (input) {
searchFabText.textContent = input.value;
if (input.value === "") {
searchFab.style.cssText = "";
svg.style.flex = "";
} else {
searchFab.style.cssText = "background-color: var(--graph_bg_thick); border-radius: 16px;";
svg.style.flex = "0 0 20px";
}
}
};
searchFab.addEventListener("click", () => {
const inputElem = document.querySelector(
`${searchContainerSelector} input`
);
if (inputElem) {
input = inputElem;
} else return;
clearTimeout(clickTimer);
clickTimer = setTimeout(() => {
handleClick(input);
input.removeEventListener("input", handleInput);
input.value = searchFabText.textContent;
input.dispatchEvent(new Event("input", { bubbles: true }));
handleInput();
input.addEventListener("input", handleInput);
}, 300);
});
searchFab.addEventListener("dblclick", () => {
if (!input) {
return;
}
clearTimeout(clickTimer);
handleClick(input);
input.value = "";
input.dispatchEvent(new Event("input", { bubbles: true }));
searchFabText.textContent = input.value;
searchFab.style.cssText = "";
svg.style.flex = "";
handleInput();
input.removeEventListener("input", handleInput);
input.addEventListener("input", handleInput);
});
}
if (type === "space") {
const spaceHandleInput = (event) => {
if (event.key === "Enter") {
const spaceInput = document.querySelector(
"#navigator .space_input"
);
const spaceSearchBtn = document.querySelector(
"#navigator .search-btn"
);
event.preventDefault();
spaceInput.value = input.value;
spaceInput.dispatchEvent(new Event("input", { bubbles: true }));
spaceSearchBtn.click();
searchOverlay.click();
}
};
searchFab.addEventListener("click", () => {
const inputElem = document.querySelector(
`${searchContainerSelector} input`
);
if (inputElem) {
input = inputElem;
} else return;
clearTimeout(clickTimer);
clickTimer = setTimeout(() => {
handleClick(input);
input.removeEventListener("keydown", spaceHandleInput);
input.addEventListener("keydown", spaceHandleInput);
const searchPanel = document.querySelector(
".search-panel"
);
const firstChild = searchPanel.firstChild;
if (firstChild.nodeType === Node.COMMENT_NODE || !firstChild.classList.contains("space-search-tip")) {
const spaceSearchTip = Object.assign(document.createElement("div"), {
className: "header space-search-tip",
innerHTML: '搜索 up 的视频、动态
'
});
searchPanel.insertBefore(spaceSearchTip, firstChild);
}
}, 300);
});
searchFab.addEventListener("dblclick", () => {
var _a;
if (!input) {
return;
}
clearTimeout(clickTimer);
handleClick(input);
input.removeEventListener("keydown", spaceHandleInput);
(_a = document.querySelector(".space-search-tip")) == null ? void 0 : _a.remove();
});
}
searchOverlay.addEventListener("click", (event) => {
event.stopPropagation();
const searchContainer = document.querySelector(
`${searchContainerSelector}`
);
searchContainer.removeAttribute("show");
searchContainer.addEventListener(
"transitionend",
() => {
searchContainer.style.cssText = "";
},
{ once: true }
);
searchOverlay.classList.remove("show");
searchFab.classList.remove("active");
});
function handleTouchMove() {
searchOverlay.click();
}
searchOverlay.addEventListener(
"touchstart",
() => searchOverlay.addEventListener("touchmove", handleTouchMove, {
once: true
})
);
searchOverlay.addEventListener(
"touchend",
() => searchOverlay.removeEventListener("touchmove", handleTouchMove)
);
}
const BILIBILI_API = "https://api.bilibili.com";
const aiData = {};
const mixinKeyEncTab = [
46,
47,
18,
2,
53,
8,
23,
32,
15,
50,
10,
31,
58,
3,
45,
35,
27,
43,
5,
49,
33,
9,
42,
19,
29,
28,
14,
39,
12,
38,
41,
13,
37,
48,
7,
16,
24,
55,
40,
61,
26,
17,
0,
1,
60,
51,
30,
4,
22,
25,
54,
21,
56,
59,
6,
63,
57,
62,
11,
36,
20,
34,
44,
52
];
const mixinKeyCache = /* @__PURE__ */ new Map();
const getMixinKey = (orig) => {
if (mixinKeyCache.has(orig)) {
return mixinKeyCache.get(orig);
}
const mixinKey = mixinKeyEncTab.map((n) => orig[n]).join("").slice(0, 32);
mixinKeyCache.set(orig, mixinKey);
return mixinKey;
};
function encWbi(params, imgKey, subKey) {
const mixinKey = getMixinKey(imgKey + subKey);
const currTime = Math.round(Date.now() / 1e3);
const chrFilter = /[!'()*]/g;
Object.assign(params, { wts: currTime });
const query = Object.keys(params).sort().map((key) => {
const value = params[key].toString().replace(chrFilter, "");
return `${encodeURIComponent(key)}=${encodeURIComponent(value)}`;
}).join("&");
const wbiSign = md5(query + mixinKey);
return `${query}&w_rid=${wbiSign}`;
}
async function getWbiKeys() {
const {
wbi_img: { img_url: imgUrl, sub_url: subUrl }
} = await getNavUserInfo();
return {
imgKey: imgUrl.slice(imgUrl.lastIndexOf("/") + 1, imgUrl.lastIndexOf(".")),
subKey: subUrl.slice(subUrl.lastIndexOf("/") + 1, subUrl.lastIndexOf("."))
};
}
async function getwts(params) {
const webKeys = await getWbiKeys();
const imgKey = webKeys.imgKey;
const subKey = webKeys.subKey;
const query = encWbi(params, imgKey, subKey);
return query;
}
async function fetchAPI(url, options = {}) {
try {
const response = await fetch(url, options);
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
const jsonData = await response.json();
return jsonData.data;
} catch (error) {
console.error("Error fetching data:", error);
throw error;
}
}
async function getNavUserInfo() {
return fetchAPI(`${BILIBILI_API}/x/web-interface/nav`, {
credentials: "include"
});
}
async function getVideoInfo(bvid) {
return fetchAPI(`${BILIBILI_API}/x/web-interface/view?bvid=${bvid}`);
}
async function getJudgeAI(params) {
const query = await getwts(params);
return fetchAPI(
`${BILIBILI_API}/x/web-interface/view/conclusion/judge?${query}`
);
}
async function getAIConclusion(params) {
const query = await getwts(params);
return fetchAPI(
`${BILIBILI_API}/x/web-interface/view/conclusion/get?${query}`
);
}
function getUserID() {
const cookies = document.cookie;
const cookieArray = cookies.split("; ");
for (let i = 0; i < cookieArray.length; i++) {
const cookie = cookieArray[i].split("=");
if (cookie[0] === "DedeUserID") {
return cookie[1];
}
}
return null;
}
function getCSRF() {
const cookies = document.cookie;
const cookieArray = cookies.split("; ");
for (let i = 0; i < cookieArray.length; i++) {
const cookie = cookieArray[i].split("=");
if (cookie[0] === "bili_jct") {
return cookie[1];
}
}
return null;
}
async function getFollowList(pageNumber, pageSize, orderType) {
const vmid = getUserID();
const query = await getwts({});
return fetchAPI(
`${BILIBILI_API}/x/relation/followings?vmid=${vmid}&pn=${pageNumber}&ps=${pageSize}&order=desc&order_type=${orderType === 1 ? "attention" : ""}&gaia_source=main_web&web_location=333.999&${query}`,
{ credentials: "include" }
);
}
async function getDynamicList(offset) {
return fetchAPI(
`${BILIBILI_API}/x/polymer/web-dynamic/v1/feed/nav?offset=${offset}`,
{ credentials: "include" }
);
}
async function getHistoryList(cursor) {
const url = `${BILIBILI_API}/x/web-interface/history/cursor?max=${cursor.max}&view_at=${cursor.view_at}&business=archive`;
const options = { credentials: "include" };
return fetchAPI(url, options);
}
async function getHistorySearchList(key, pn) {
return fetchAPI(
`${BILIBILI_API}/x/web-interface/history/search?pn=${pn}&keyword=${key}&business=all`,
{ credentials: "include" }
);
}
async function getUnreadNums() {
const options = { credentials: "include" };
const messageNumObj = await fetchAPI(
"https://api.vc.bilibili.com/session_svr/v1/session_svr/single_unread?build=0&mobi_app=web&unread_type=0",
options
);
const dynamicNumObj = await fetchAPI(
`${BILIBILI_API}/x/web-interface/dynamic/entrance?alltype_offset=&video_offset=0&article_offset=0`,
options
);
const messageNum = Object.values(messageNumObj).reduce(
// 数组方法:所有元素累积成一个值
(acc, value) => acc + value,
// 回调:累加器 + 当前值
0
// 初始值
);
const dynamicNum = dynamicNumObj.update_info.item.count;
return { messageNum, dynamicNum };
}
async function followUser(mid, isFollow) {
const response = await fetch("https://api.bilibili.com/x/relation/modify", {
method: "POST",
headers: { "Content-Type": "application/x-www-form-urlencoded" },
body: new URLSearchParams({
fid: mid,
act: isFollow ? "1" : "2",
re_src: "11",
csrf: getCSRF()
}).toString(),
credentials: "include"
});
if (!response.ok) {
throw new Error(`HTTP error! status: ${response.status}`);
}
return response.json();
}
async function loadFollowList(orderType) {
const content = document.querySelector(
"#follow-list-dialog .follow-list-content"
);
let pageNumber = 1;
let pageSize = 20;
const data = await getFollowList(pageNumber, pageSize, orderType);
const list = data.list;
list.forEach(addElementByItem);
const total = data.total;
async function onScroll() {
const { scrollTop, scrollHeight, clientHeight } = content;
if (Math.abs(scrollTop + clientHeight - scrollHeight) > 1) {
return;
}
content.removeEventListener("scroll", onScroll);
const remainingData = total - pageNumber * pageSize;
if (remainingData <= pageSize) {
pageSize = remainingData;
} else {
setTimeout(() => {
content.addEventListener("scroll", onScroll);
}, 2e3);
console.log("Scroll to bottom");
}
const data2 = await getFollowList(++pageNumber, pageSize, 1);
const list2 = data2.list;
list2.forEach(addElementByItem);
}
content.addEventListener("scroll", onScroll);
const tabsPanel = document.querySelector(
"#follow-list-dialog .header-tabs-panel"
);
const firstItem = tabsPanel.firstElementChild;
const secondItem = firstItem.nextElementSibling;
firstItem.addEventListener("click", () => {
if (firstItem.classList.contains("header-tabs-panel__item--active")) {
return;
}
firstItem.classList.add("header-tabs-panel__item--active");
secondItem.classList.remove("header-tabs-panel__item--active");
content.innerHTML = "";
content.removeEventListener("scroll", onScroll);
loadFollowList(1);
});
secondItem.addEventListener("click", () => {
if (secondItem.classList.contains("header-tabs-panel__item--active")) {
return;
}
secondItem.classList.add("header-tabs-panel__item--active");
firstItem.classList.remove("header-tabs-panel__item--active");
content.innerHTML = "";
content.removeEventListener("scroll", onScroll);
loadFollowList(2);
});
function addElementByItem(item) {
const up = Object.assign(document.createElement("li"), {
className: "list-item clearfix",
/* html */
innerHTML: `
${item.uname}
${desc(item)}
`
});
content.appendChild(up);
const fansAction = up.querySelector(".fans-action");
const follow = fansAction.firstElementChild;
const more = follow.nextElementSibling;
follow.addEventListener("click", async () => {
if (!follow.classList.contains("follow")) {
const followRes = await followUser(item.mid, false);
if (followRes.code === 0) {
follow.className = "fans-action-btn follow";
follow.innerHTML = '+ 关注';
follow.style.backgroundColor = "#00a1d6";
follow.style.color = "white";
}
} else {
const followRes = await followUser(item.mid, true);
if (followRes.code === 0) {
follow.className = "be-dropdown fans-action-btn fans-action-follow";
follow.innerHTML = '已关注';
follow.style.backgroundColor = "";
follow.style.color = "";
}
}
});
more.addEventListener("mouseenter", () => {
const dropdownMenu = more.querySelector(
".be-dropdown-menu"
);
dropdownMenu.style.display = "";
fansAction.style.zIndex = `${2}`;
more.style.color = "#00a1d6";
});
more.addEventListener("mouseleave", () => {
const dropdownMenu = more.querySelector(
".be-dropdown-menu"
);
dropdownMenu.style.display = "none";
fansAction.style.zIndex = `${2}`;
more.style.color = "";
});
}
function formatUrl(url) {
return url.slice(url.indexOf(":") + 1);
}
function desc(item) {
return item.official_verify.desc || item.sign;
}
}
async function handleHistoryShowMore() {
let cursor = {
max: 0,
view_at: 0
};
let pn = 0;
let isHistoryItem = true;
let isAddSearchItem = false;
const data = await getHistoryList(cursor);
cursor = data.cursor;
const historyContent = document.querySelector(
".history-panel-popover>.header-tabs-panel__content"
);
const historySearch = Object.assign(document.createElement("form"), {
id: "nav-searchform",
innerHTML: `
`
});
historyContent.insertBefore(historySearch, historyContent.firstChild);
const btn = historySearch.querySelector(".nav-search-btn");
const input = historySearch.querySelector("input");
const clean = historySearch.querySelector(".nav-search-clean");
input.addEventListener("keydown", (event) => {
if (event.key === "Enter") {
event.preventDefault();
btn.click();
}
});
clean.addEventListener("click", () => {
var _a;
const oldElems = historyContent.querySelectorAll(".history-search-item");
oldElems.forEach((elem) => elem.remove());
(_a = historyContent.querySelector("#search-history")) == null ? void 0 : _a.remove();
input.value = "";
input.dispatchEvent(new Event("input", { bubbles: true }));
isAddSearchItem = false;
});
btn.addEventListener("click", async () => {
if (!historyContent.querySelector("#search-history")) {
const style = document.createElement("style");
style.id = "search-history";
style.textContent = `
.header-tabs-panel__content>a:not(.history-search-item) {display: none}
.header-tabs-panel__content>div {display: none}
`;
historyContent.appendChild(style);
}
pn = 1;
const data2 = await getHistorySearchList(input.value, pn);
pn++;
const oldElems = historyContent.querySelectorAll(".history-search-item");
oldElems.forEach((elem) => elem.remove());
isAddSearchItem = true;
data2.list.forEach(addElementByItem);
});
function removeNoFirstStyle() {
var _a;
isHistoryItem = true;
(_a = historyContent.querySelector("#no-first-history-item")) == null ? void 0 : _a.remove();
}
function addNoFirstStyle() {
isHistoryItem = false;
if (!historyContent.querySelector("#no-first-history-item")) {
const style = document.createElement("style");
style.id = "no-first-history-item";
style.textContent = `
.header-tabs-panel__content>a.header-history-card {display: none}
.header-tabs-panel__content>a.view-all-history-btn {display: block !important}
.header-tabs-panel__content>form#nav-searchform {display: none}
div.header-tabs-panel__content>div {display: block}
`;
historyContent.appendChild(style);
}
}
const historyPanel = document.querySelector(
".header-tabs-panel"
);
const observer = new MutationObserver((mutationsList) => {
mutationsList.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.className === "header-tabs-panel__item" && node.textContent === "专栏") {
historyPanel.children[0].addEventListener("click", removeNoFirstStyle);
historyPanel.children[1].addEventListener("click", addNoFirstStyle);
historyPanel.children[2].addEventListener("click", addNoFirstStyle);
observer.disconnect();
}
});
});
});
observer.observe(historyPanel, { childList: true });
async function onScroll() {
if (!isHistoryItem) {
return;
}
const { scrollTop, scrollHeight, clientHeight } = historyContent;
if (Math.abs(scrollTop + clientHeight - scrollHeight) > 1) {
return;
}
historyContent.removeEventListener("scroll", onScroll);
setTimeout(() => {
historyContent.addEventListener("scroll", onScroll);
}, 2e3);
console.log("Scroll to bottom");
const data2 = isAddSearchItem ? await getHistorySearchList(input.value, pn) : await getHistoryList(cursor);
if (isAddSearchItem) {
pn++;
} else {
cursor = data2.cursor;
}
data2.list.forEach(addElementByItem);
}
historyContent.addEventListener("scroll", onScroll);
function addElementByItem(item) {
const record = Object.assign(document.createElement("a"), {
href: `//www.bilibili.com/video/${item.history.bvid}/?`,
className: `header-history-card header-history-video ${isAddSearchItem ? "history-search-item" : ""}`,
target: "_blank",
"data-mod": "top_right_bar_window_history",
"data-idx": "content",
"data-ext": "click",
// /* html */
innerHTML: `
`
});
historyContent.appendChild(record);
}
const formatUrl = (url) => url.slice(url.indexOf(":") + 1);
function formatProgressTime(seconds) {
const hrs = Math.floor(seconds / 3600);
const mins = Math.floor(seconds % 3600 / 60);
const secs = seconds % 60;
return `${hrs ? `${hrs}:` : ""}${mins.toString().padStart(2, "0")}:${secs.toString().padStart(2, "0")}`;
}
function formatViewTime(timestamp) {
const days = Math.floor(timestamp / 86400);
const hrs = Math.floor(timestamp % 86400 / 3600);
const mins = Math.floor(timestamp % 3600 / 60);
const now = Math.floor(Date.now() / 1e3);
const today = Math.floor(now / 86400);
const dayTextMap = {
0: "今天",
1: "昨天",
2: "前天"
};
const dayText = dayTextMap[today - days] || `${today - days}天前`;
return `${dayText} ${hrs.toString().padStart(2, "0")}:${mins.toString().padStart(2, "0")}`;
}
}
function handleDynamicShowMore() {
let offset = "";
let i = 0;
async function getLoadedData() {
const data = await getDynamicList(offset);
offset = data.offset;
if (i < 2) {
getLoadedData();
i++;
}
}
getLoadedData();
const dynamicContent = document.querySelector(
".dynamic-panel-popover>.header-tabs-panel__content"
);
const dynamicAll = dynamicContent.querySelector(".dynamic-all");
let loadedTitle = [];
async function onScroll() {
const { scrollTop, scrollHeight, clientHeight } = dynamicContent;
if (Math.abs(scrollTop + clientHeight - scrollHeight) > 1) {
return;
}
dynamicContent.removeEventListener("scroll", onScroll);
setTimeout(() => {
dynamicContent.addEventListener("scroll", onScroll);
}, 2e3);
console.log("Scroll to bottom");
const data = await getDynamicList(offset);
offset = data.offset;
data.items.forEach(checkIsLoaded);
const dynamics = dynamicAll.querySelectorAll(":scope>a");
loadedTitle = Array.from(dynamics).map((a) => a.title);
}
dynamicContent.addEventListener("scroll", onScroll);
function checkIsLoaded(item) {
if (!loadedTitle.includes(item.title)) {
addElementByItem(item);
}
}
function addElementByItem(item) {
const author = item.author;
const cover = item.cover;
const record = Object.assign(document.createElement("a"), {
href: `${item.jump_url}`,
title: `${item.title}`,
target: "_blank",
"data-mod": "top_right_bar_window_dynamic",
"data-idx": "content",
"data-ext": "click",
// /* html */
innerHTML: `
`
});
dynamicAll == null ? void 0 : dynamicAll.appendChild(record);
}
const formatUrl = (url) => url.slice(url.indexOf(":") + 1);
}
function setMenuBtn() {
let isOldApp;
const preloadeditems1 = [
// 旧APP不用预加载消息
'.v-popover-wrap:has(>.right-entry__outside[href="//t.bilibili.com/"])',
".v-popover-wrap:has(>.right-entry__outside[data-header-fav-entry])",
'.right-entry__outside[href="//www.bilibili.com/account/history"]',
".header-avatar-wrap"
];
const preloadeditems2 = [
".v-popover-wrap:has(>[data-idx=message])",
".v-popover-wrap:has(>[data-idx=dynamic])",
".v-popover-wrap:has(>[data-idx=fav])",
".v-popover-wrap:has(>[data-idx=history])",
".header-avatar-wrap"
];
function preload() {
const preloadeditems = isOldApp ? preloadeditems1 : preloadeditems2;
preloadeditems.forEach((item) => {
var _a;
(_a = document.querySelector(item)) == null ? void 0 : _a.dispatchEvent(new MouseEvent("mouseenter"));
});
setTimeout(handleHistoryShowMore, 70);
setTimeout(handleDynamicShowMore, 60);
}
tryPreload();
function tryPreload() {
if (document.querySelector(preloadeditems1[0]) && // 排除登录、主页
document.querySelector(preloadeditems1[1]) && document.querySelector(preloadeditems1[2])) {
let changeMenu = function() {
if (document.querySelector("#header-in-menu")) {
document.querySelector(
'[data-refer="[data-idx=message]"]'
).dataset.refer = ".right-entry__outside[href='//message.bilibili.com']";
document.querySelector(
'[data-refer="[data-idx=dynamic]"]'
).dataset.refer = ".right-entry__outside[href='//t.bilibili.com/']";
document.querySelector(
'[data-refer="[data-idx=fav]"]'
).dataset.refer = ".right-entry__outside[data-header-fav-entry]";
document.querySelector(
'[data-refer="[data-idx=history]"]'
).dataset.refer = ".right-entry__outside[href='//www.bilibili.com/account/history']";
} else {
setTimeout(changeMenu, 50);
}
};
isOldApp = true;
preload();
changeMenu();
} else if (document.querySelector(preloadeditems2[0]) && // 排除登录、主页
document.querySelector(preloadeditems2[1]) && document.querySelector(preloadeditems2[2]) && document.querySelector(preloadeditems2[3])) {
isOldApp = false;
preload();
} else {
setTimeout(tryPreload, 1e3);
}
}
const menuFab = document.getElementById("menu-fab");
const menuOverlay = Object.assign(document.createElement("div"), {
id: "menu-overlay",
// 顺序要与 setting.js 中的菜单选项排序对应
innerHTML: `
`
});
menuFab.appendChild(menuOverlay);
const menu = menuOverlay.querySelector("#header-in-menu");
menuFab.addEventListener("click", () => {
menu.classList.add("show");
menuOverlay.classList.add("show");
menuFab.classList.add("active");
});
updateBadges();
async function updateBadges() {
function update(id, number) {
const badge = menuOverlay.querySelector(`#${id}`);
if (number > 0) {
badge.textContent = number > 99 ? "99+" : number.toString();
badge.style.visibility = "visible";
} else {
badge.style.visibility = "hidden";
}
}
const { messageNum, dynamicNum } = await getUnreadNums();
update("message-badge", messageNum);
update("dynamic-badge", dynamicNum);
}
let openedDialog = "";
const items = menuOverlay.querySelectorAll("li");
items.forEach(
(item) => item.addEventListener("click", (event) => {
event.stopPropagation();
menu.classList.remove("show");
const refer = item.dataset.refer;
if (!refer) {
menuOverlay.classList.remove("show");
return;
}
const referElement = document.querySelector(`${refer}+.v-popover`);
if (!referElement) {
const toast = document.querySelector("#toast");
toast.textContent = "网页菜单加载中,请稍后重试";
toast.style.display = "block";
setTimeout(() => {
toast.setAttribute("show", "");
}, 10);
menuOverlay.click();
setTimeout(() => {
toast.removeAttribute("show");
toast.addEventListener(
"transitionend",
() => {
toast.style.cssText = "";
},
{ once: true }
);
}, 3e3);
return;
}
openedDialog = refer;
referElement.setAttribute("display", "");
setTimeout(() => {
referElement.setAttribute("show", "");
}, 10);
})
);
menuOverlay.addEventListener("click", (event) => {
event.stopPropagation();
menu.classList.remove("show");
menuOverlay.classList.remove("show");
menuFab.classList.remove("active");
if (openedDialog === "") {
return;
}
const referElement = document.querySelector(
`${openedDialog}+.v-popover`
);
referElement.removeAttribute("show");
handleTransitionEndOnce(referElement, "opacity", () => {
referElement.removeAttribute("display");
});
if (openedDialog === "'.right-entry__outside[href='//message.bilibili.com']" || openedDialog === ".right-entry__outside[href='//t.bilibili.com/']") {
updateBadges();
}
});
function handleTouchMove() {
menuOverlay.click();
}
menuOverlay.addEventListener(
"touchstart",
() => menuOverlay.addEventListener("touchmove", handleTouchMove, { once: true })
);
menuOverlay.addEventListener(
"touchend",
() => menuOverlay.removeEventListener("touchmove", handleTouchMove)
);
createExtraDialog();
function createExtraDialog() {
const falseHeader = Object.assign(document.createElement("div"), {
className: "bili-header false-header",
innerHTML: `
`
});
document.body.appendChild(falseHeader);
const followOutside = document.createElement("div");
followOutside.className = "right-entry__outside follow-list";
followOutside.dataset.idx = "follow";
falseHeader.appendChild(followOutside);
const followDialog = Object.assign(document.createElement("div"), {
className: "v-popover is-bottom",
id: "follow-list-dialog",
// /* html */
innerHTML: `
`
});
falseHeader.appendChild(followDialog);
loadFollowList(1);
}
}
function touchZoomWrap(zoomWrap, photoShadow) {
if (zoomWrap) {
let initialDistance = 0;
let initialScale = 1;
let transformOrigin = { x: 0, y: 0 };
let startX = 0;
let startY = 0;
let initialTransformX = 0;
let initialTransformY = 0;
let lastTouchCount = 0;
const calculateDistance = (touches) => {
const dx = touches[0].clientX - touches[1].clientX;
const dy = touches[0].clientY - touches[1].clientY;
return Math.sqrt(dx * dx + dy * dy);
};
const calculateCenter = (touches) => {
const dx = (touches[0].clientX + touches[1].clientX) / 2;
const dy = (touches[0].clientY - touches[1].clientY) / 2;
return [dx, dy];
};
const calcInitialTranslate = (changedTouches) => {
startX = changedTouches[0].clientX;
startY = changedTouches[0].clientY;
initialTransformX = +zoomWrap.style.transform.match(
/translate\((-?[0-9.]+)px, -?[0-9.]+px\)/
)[1];
initialTransformY = +zoomWrap.style.transform.match(
/translate\(-?[0-9.]+px, (-?[0-9.]+)px\)/
)[1];
};
const handleTouchStart = (event) => {
if (zoomWrap.style.cssText.match(/scale3d\(1, 1, 1\)/)) {
zoomWrap.style.cssText = `transform: scale(1) translate(0px, 0px) !important;
transform-origin: 50% 50%;
`;
}
if (event.touches.length === 2) {
initialDistance = calculateDistance(event.touches);
const center = calculateCenter(event.touches);
transformOrigin = { x: center[0], y: center[1] };
updateTransformOrigin();
} else if (event.touches.length === 1) {
calcInitialTranslate(event.changedTouches);
}
lastTouchCount = event.touches.length;
initialScale = getCurrentScale();
zoomWrap.addEventListener("touchmove", handleTouchMove, {
passive: false
});
};
const handleTouchMove = (event) => {
if (event.touches.length === 2) {
const currentDistance = calculateDistance(event.touches);
const scale = Math.max(
1,
initialScale * (currentDistance / initialDistance)
);
const center = calculateCenter(event.touches);
transformOrigin = { x: center[0], y: center[1] };
updateTransform(scale);
updateTransformOrigin();
event.preventDefault();
} else if (event.touches.length === 1 && lastTouchCount === 2) {
calcInitialTranslate(event.touches);
initialScale = getCurrentScale();
} else if (event.touches.length === 1 && initialScale > 1.05) {
if (initialScale > 1.05) {
const deltaX = (event.changedTouches[0].clientX - startX) / initialScale;
const deltaY = (event.changedTouches[0].clientY - startY) / initialScale;
zoomWrap.style.cssText = zoomWrap.style.cssText.replace(
/translate\(-?[0-9.]+px, -?[0-9.]+px\)/,
`translate(${initialTransformX + deltaX}px, ${initialTransformY + deltaY}px)`
);
}
}
lastTouchCount = event.touches.length;
};
const handleTouchEnd = (event) => {
var _a, _b;
zoomWrap.removeEventListener("touchend", handleTouchMove);
if (event.touches.length === 0) {
if (initialScale < 1.05) {
const offsetX = event.changedTouches[0].clientX - startX;
const offsetY = event.changedTouches[0].clientY - startY;
if (Math.abs(offsetX) > 55 && Math.abs(offsetY / offsetX) < 1 / 2) {
if (offsetX > 0) {
(_a = photoShadow.querySelector("#prev")) == null ? void 0 : _a.click();
} else {
(_b = photoShadow.querySelector("#next")) == null ? void 0 : _b.click();
}
}
}
}
if (event.touches.length === 1) {
calcInitialTranslate(event.changedTouches);
}
};
const getCurrentScale = () => {
const match = zoomWrap.style.transform.match(/scale\(([0-9.]+)\)/);
return match ? parseFloat(match[1]) : 1;
};
const updateTransform = (scale) => {
const currentTransform = zoomWrap.style.transform;
const newTransform = currentTransform.replace(
/scale\([0-9.]+\)/,
`scale(${scale})`
);
zoomWrap.style.transform = newTransform;
};
const updateTransformOrigin = () => {
zoomWrap.style.transformOrigin = `${transformOrigin.x}px ${transformOrigin.y}px`;
};
zoomWrap.addEventListener("touchstart", handleTouchStart);
zoomWrap.addEventListener("touchend", handleTouchEnd);
}
}
function modifyShadowDOMLate(isDynamicRefresh = false) {
let commentsShadow = null;
let commentsHeaderShadow = null;
let headerBoxShadow = null;
const comment = document.getElementById("commentapp");
if (!comment) return;
const observer = new MutationObserver(handleCommentMutation);
observer.observe(comment, { childList: true, subtree: true });
function handleCommentMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "bili-comments") {
observeComments();
observer.disconnect();
}
});
});
}
function observeComments() {
var _a;
commentsShadow = (_a = document.querySelector("bili-comments")) == null ? void 0 : _a.shadowRoot;
if (!commentsShadow) return;
const observer2 = new MutationObserver(handleCommentsMutation);
observer2.observe(commentsShadow, { childList: true, subtree: true });
appendStyle2(
commentsShadow,
`
div#contents {
padding-top: 0;
}`
);
}
function handleCommentsMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.id === "contents") {
observeHeader();
observeContent();
observer.disconnect();
}
});
});
}
function observeHeader() {
var _a;
commentsHeaderShadow = (_a = commentsShadow == null ? void 0 : commentsShadow.querySelector(
"bili-comments-header-renderer"
)) == null ? void 0 : _a.shadowRoot;
if (!commentsHeaderShadow) return;
const observer2 = new MutationObserver(handleHeaderMutation);
observer2.observe(commentsHeaderShadow, { childList: true, subtree: true });
appendStyle2(
commentsHeaderShadow,
`
div#commentbox {
position: fixed;
left: 0;
bottom: var(--actionbar-height);
z-index: 10;
width: calc(100% - (100% - 200px) / 3);
padding: 7px calc((100% - 200px) / 6);
transition: calc(var(--actionbar-time)*1.40) ease-in;
display: var(--commentbox-display);
transform: var(--shadow-transform);
backdrop-filter: blur(3px);
background-color: rgba(255, 255, 255, .6);
}
div#commentbox[style] {
display: none;
}
div#commentbox[style]+.bili-comments-bottom-fixed-wrapper {
width: 100% !important;
bottom: var(--actionbar-height) !important;
}
div#commentbox[style]+.bili-comments-bottom-fixed-wrapper>div {
padding: 8px 12px !important;
width: calc(100% - 24px) !important;
transition: calc(var(--actionbar-time)* 1.40) ease-in;
display: var(--commentbox-display);
transform: var(--shadow-transform);
backdrop-filter: blur(3px);
background-color: rgba(255, 255, 255, .6) !important;
border: none !important;
}
div#navbar {
margin-bottom: 0;
}
#notice {
display: none;
}`
);
}
function handleHeaderMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "div" && node.id === "commentbox") {
observeHeader2();
observer.disconnect();
}
});
});
}
function observeHeader2() {
var _a;
headerBoxShadow = (_a = commentsHeaderShadow == null ? void 0 : commentsHeaderShadow.querySelector("bili-comment-box")) == null ? void 0 : _a.shadowRoot;
if (!headerBoxShadow) return;
const observer2 = new MutationObserver(handleHeader2Mutation);
observer2.observe(headerBoxShadow, { childList: true, subtree: true });
appendStyle2(
headerBoxShadow,
`
:host {
display: var(--commentbox-display) !important;
}
div#user-avatar {
display: none;
}
div#comment-area {
width: 100%;
}
div#editor {
border-radius: 13px;
padding: 0;
border: none;
}`
);
const headerVote = commentsHeaderShadow == null ? void 0 : commentsHeaderShadow.querySelector(
"bili-comments-vote-card"
);
if (headerVote) {
appendStyle2(
headerVote.shadowRoot,
`.option.left,
.option.right {
min-width: 0 !important;
}
#card {
padding-top: 27px !important;
}
#info {
transform: translateY(-23px);
}
#title {
overflow: visible !important;
white-space: nowrap;
position: absolute;
}
#desc {
padding-top: 20px;
}`
);
}
}
function handleHeader2Mutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "div" && node.id === "comment-area") {
observeHeader3();
observer.disconnect();
}
});
});
}
function observeHeader3() {
const oldTextarea = headerBoxShadow == null ? void 0 : headerBoxShadow.querySelector("bili-comment-textarea");
const textarea = oldTextarea ? oldTextarea : headerBoxShadow == null ? void 0 : headerBoxShadow.querySelector("bili-comment-rich-textarea");
if (oldTextarea) {
appendStyle2(
textarea.shadowRoot,
`textarea#input {
line-height: 26px;
min-height: 26px;
height: 26px !important;
}`
);
} else {
appendStyle2(
textarea.shadowRoot,
`div#input, div.brt-root {
line-height: 26px;
min-height: 26px;
--brt-line-height: 26px;
}`
);
}
}
function observeContent() {
const commentThreads = commentsShadow == null ? void 0 : commentsShadow.querySelectorAll(
"bili-comment-thread-renderer"
);
commentThreads == null ? void 0 : commentThreads.forEach((thread) => {
const threadShadow = thread.shadowRoot;
const observer2 = new MutationObserver(handleContentMutation);
observer2.observe(threadShadow, { childList: true, subtree: true });
});
}
function handleContentMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "div" && node.id === "replies") {
observeContent2(mutation.target);
observer.disconnect();
}
});
});
}
function observeContent2(threadShadow) {
var _a, _b;
const commentShadow = (_a = threadShadow == null ? void 0 : threadShadow.querySelector(
"bili-comment-renderer"
)) == null ? void 0 : _a.shadowRoot;
const repliesShadow = (_b = threadShadow == null ? void 0 : threadShadow.querySelector(
"bili-comment-replies-renderer"
)) == null ? void 0 : _b.shadowRoot;
appendStyle2(
commentShadow,
`
div#body {
padding-left: 45px;
--bili-comment-hover-more-display: block;
}
a#user-avatar {
left: 0;
}`
);
appendStyle2(
repliesShadow,
`
div#expander {
padding-left: 40px;
}`
);
const observer2 = new MutationObserver(handleCommentShadowMutation);
observer2.observe(commentShadow, { childList: true, subtree: true });
const observer22 = new MutationObserver(handleRepliesShadowMutation);
observer22.observe(repliesShadow, { childList: true, subtree: true });
}
function handleCommentShadowMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
var _a;
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "div" && node.id === "body") {
const avatarShadow = (_a = mutation.target.querySelector(
"bili-avatar"
)) == null ? void 0 : _a.shadowRoot;
appendStyle2(
avatarShadow,
`
.layer.center {
width: 48px !important;
height: 48px !important;
}`
);
observer.disconnect();
}
});
});
}
function handleRepliesShadowMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "div" && node.id === "expander") {
const replies = mutation.target.querySelectorAll(
"bili-comment-reply-renderer"
);
replies.forEach((reply) => {
const replyShadow = reply.shadowRoot;
appendStyle2(
replyShadow,
`
div#body {
padding: 4px 0 4px 29px;
--bili-comment-hover-more-display: block;
}`
);
observer.disconnect();
});
}
});
});
}
function appendStyle2(shadowRoot, cssText) {
const style = document.createElement("style");
style.textContent = cssText;
shadowRoot.appendChild(style);
}
if (isDynamicRefresh) {
return;
}
new MutationObserver(handleBodyMutation).observe(document.body, {
childList: true
});
function handleBodyMutation(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "bili-photoswipe") {
const photoShadow = node.shadowRoot;
const zoomWrap = photoShadow == null ? void 0 : photoShadow.querySelector(
"#zoom-wrap"
);
zoomWrap.addEventListener(
"click",
(event) => {
event.stopImmediatePropagation();
(photoShadow == null ? void 0 : photoShadow.querySelector("#close")).click();
},
{ capture: true, once: true }
);
touchZoomWrap(zoomWrap, photoShadow);
appendStyle2(
photoShadow,
`
#container {z-index:3;}
#thumb {z-index: 4;}
#prev, #next, #close {visibility: hidden;}
#item {
display: flex;
justify-content: center;
align-items: center;
}
#zoom-wrap {
position: unset !important;
transform: none !important;
}
`
);
}
});
});
}
new MutationObserver(handleBodyMutation2).observe(document.body, {
childList: true
});
function handleBodyMutation2(mutations) {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.nodeName.toLowerCase() === "bili-comments-popup") {
const iframe = node.querySelector("iframe");
iframe.addEventListener("load", () => {
const contentDocument = iframe.contentDocument;
const style = contentDocument.createElement("style");
style.textContent = `
div.bili-dyn-item-draw {
min-width: 0;
padding-left: 58px;
}
div.bili-dyn-item-draw__avatar {
width: 58px;
height: 58px;
}
.bili-album__preview__picture {
max-width: 100%;
height: auto !important;
}
.bili-album__preview[class*=grid] {
max-width: 100%;
}
.bili-album__preview[class*=grid] .bili-album__preview__picture {
margin-bottom: 4px;
}
`;
contentDocument.head.appendChild(style);
});
node.addEventListener(
"click",
() => {
node.shadowRoot.querySelector(
"#close"
).click();
},
{ once: true }
);
}
});
});
}
}
function setSidebarBtn(type) {
const videoMap = {
video: [".right-container", ".rec-footer"],
list: [".playlist-container--right", ".recommend-list-container"]
};
if (["video", "list"].includes(type)) {
handleVideoSidebar();
showMoreRecommend();
} else if (type === "message") {
handleMessageSidebar();
}
function handleVideoSidebar() {
const sidebarFab = document.getElementById("sidebar-fab");
const videoContainer = document.querySelector(
"#mirror-vdcon"
);
sidebarFab.addEventListener(
"click",
() => videoContainer.toggleAttribute("sidebar")
);
function closeSidebar() {
videoContainer.removeAttribute("sidebar");
}
const rightContainer = videoContainer.querySelector(
videoMap[type][0]
);
const recommendLiist = rightContainer.querySelector(
videoMap[type][1]
);
recommendLiist.addEventListener("click", (event) => {
const nextPlay = document.querySelector(".rec-title");
const recommendFooter = document.querySelector(".rec-footer");
if (!(nextPlay == null ? void 0 : nextPlay.contains(event.target)) && !recommendFooter.contains(event.target)) {
closeSidebar();
handleTransitionEndOnce(rightContainer, "transform", () => {
rightContainer.scrollTop = 0;
});
modifyShadowDOMLate(true);
}
});
}
function showMoreRecommend() {
var _a;
const recommendFooter = document.querySelector(".rec-footer");
setTimeout(() => {
recommendFooter == null ? void 0 : recommendFooter.click();
}, 2e3);
(_a = document.querySelector("video")) == null ? void 0 : _a.addEventListener("canplay", showMoreRecommend, { once: true });
}
function handleMessageSidebar() {
const sidebarFab = document.getElementById("sidebar-fab");
const messageContainer = document.querySelector(
"body>.container"
);
sidebarFab.addEventListener("click", () => {
messageContainer.toggleAttribute("sidebar");
sidebarOverlay.classList.toggle("show");
sidebarFab.classList.toggle("active");
});
const sidebarOverlay = document.createElement("div");
sidebarOverlay.id = "sidebar-overlay";
sidebarFab.appendChild(sidebarOverlay);
}
}
function handleActionbar(type) {
const actionbar = Object.assign(document.createElement("div"), {
id: "actionbar",
//
//
innerHTML: `
`
});
document.body.appendChild(actionbar);
document.body.appendChild(
Object.assign(document.createElement("div"), { id: "toast" })
);
actionbar.classList.add(type);
setHomeBtn();
setSearchBtn(type);
if (type !== "message") {
setMenuBtn();
}
switch (type) {
case "home":
setTopBtn();
setRefreshBtn();
break;
case "video":
case "list":
setFullbtn();
setSidebarBtn(type);
break;
case "search":
setTopBtn();
setShowMoreBtn();
break;
case "space":
setTopBtn();
setShowMoreBtn();
break;
case "message":
setSidebarBtn(type);
break;
}
function setTopBtn() {
const topBtn = document.getElementById("my-top");
topBtn.addEventListener("click", () => window.scrollTo({ top: 0 }));
}
function setHomeBtn() {
const home = document.getElementById("my-home");
home.addEventListener(
"click",
() => location.href = "https://www.bilibili.com/"
);
}
function setRefreshBtn() {
const refreshFab = document.getElementById("refresh-fab");
refreshFab.addEventListener("click", () => {
document.querySelector(".flexible-roll-btn-inner").click();
});
}
function setFullbtn() {
let clickTimer = 0;
const fullBtn = document.getElementById("full-now");
function playVideo() {
const video = document.querySelector("video");
video.play();
video.muted = false;
if (video.volume === 0) {
document.querySelector(".bpx-player-ctrl-muted-icon").click();
}
}
fullBtn.addEventListener("click", () => {
clearTimeout(clickTimer);
playVideo();
clickTimer = setTimeout(() => {
const videoWrap = document.querySelector(
".bpx-player-video-wrap"
);
videoWrap.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
}, 250);
});
fullBtn.addEventListener("dblclick", () => {
clearTimeout(clickTimer);
});
}
function setShowMoreBtn() {
const showMoreFab = document.getElementById("show-more-fab");
const handleClick = () => {
if (type === "search") {
const searchConditions = document.querySelector(
".search-conditions"
);
if (searchConditions) {
if (sessionStorage.getItem("show-conditions") !== "true") {
searchConditions.style.transition = ".4s ease-in";
searchConditions.classList.add("show");
searchConditions.addEventListener(
"transitionend",
() => {
searchConditions.style.transition = "";
},
{ once: true }
);
showMoreFab.classList.add("reverse");
sessionStorage.setItem("show-conditions", "true");
} else {
searchConditions.style.transition = ".4s ease-in";
searchConditions.classList.remove("show");
searchConditions.addEventListener(
"transitionend",
() => {
searchConditions.style.transition = "";
},
{ once: true }
);
showMoreFab.classList.remove("reverse");
sessionStorage.setItem("show-conditions", "");
}
}
} else if (type === "space") {
const followRow = document.querySelector(".h .h-action");
followRow.style.transition = ".4s ease-in";
followRow == null ? void 0 : followRow.classList.toggle("show");
followRow.addEventListener(
"transitionend",
() => {
followRow.style.transition = "";
},
{ once: true }
);
showMoreFab.classList.toggle("reverse");
}
};
showMoreFab.addEventListener("click", handleClick);
}
}
async function loadAI(card) {
const aiCardElement = createAICardElement(
card.querySelector(".bili-video-card__image--wrap")
);
const aiConclusionRes = await aiConclusion(card);
const bvid = card.querySelector(".bili-video-card__image--link").dataset.bvid;
genterateAIConclusionCard(aiConclusionRes, aiCardElement, bvid);
}
async function aiConclusion(card) {
const cardImageLinkElement = card.querySelector(
".bili-video-card__image--link"
);
const match = /\/video\/([A-Za-z0-9]+)/.exec(cardImageLinkElement.dataset.targetUrl) || /\/video\/([A-Za-z0-9]+)/.exec(cardImageLinkElement.href);
const bvid = match[1];
if (aiData[bvid] && aiData[bvid].code === 0) {
return aiData[bvid];
}
if (cardImageLinkElement.dataset.hasGotAi === void 0) {
const cid = cardImageLinkElement.dataset.cid;
const up_mid = cardImageLinkElement.dataset.upMid;
const aiConclusionRes = await getAIConclusion({ bvid, cid, up_mid });
aiData[bvid] = aiConclusionRes;
cardImageLinkElement.dataset.hasGotAi = true.toString();
if (aiConclusionRes.code === 0) {
return aiData[bvid];
}
}
}
function createAICardElement(cardElement) {
var _a;
const overlay = document.createElement("div");
overlay.id = "ai-conclusion-overlay";
overlay.innerHTML = `
`;
(_a = cardElement.closest(".bili-video-card")) == null ? void 0 : _a.appendChild(overlay);
overlay.classList.add("show");
overlay.addEventListener(
"click",
() => {
overlay.classList.remove("show");
overlay.addEventListener("transitionend", overlay.remove);
},
{ once: true }
);
const div = overlay.querySelector(".ai-conclusion-card");
div.addEventListener("click", (event) => event.stopPropagation());
return div;
}
function genterateAIConclusionCard(aiConclusionRes, aiCardElement, bvid) {
let aiCard = `
${aiConclusionRes.model_result.summary}
`;
aiConclusionRes.model_result.outline.forEach(
(item) => {
aiCard += `
`;
}
);
function timeNumberToTime(time) {
const min = Math.floor(time / 60);
const sec = time % 60;
return `${min.toString().padStart(2, "0")}:${sec.toString().padStart(2, "0")}`;
}
aiCardElement.innerHTML = aiCard;
}
function preloadAnchor() {
let anchor;
let firstUnloadElem;
let height;
const container = document.querySelector(".container");
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.className === "load-more-anchor") {
anchor = node;
firstUnloadElem = document.querySelector(
".container>.bili-video-card:not(.is-rcmd)"
);
height = firstUnloadElem.clientHeight + 8;
observer.disconnect();
}
});
});
});
observer.observe(container, { childList: true });
function preload() {
if ((firstUnloadElem == null ? void 0 : firstUnloadElem.getBoundingClientRect().top) < height * 6) {
window.removeEventListener("scroll", preload);
anchor.parentNode.children[1].appendChild(anchor);
setTimeout(() => {
firstUnloadElem.parentNode.appendChild(anchor);
window.addEventListener("scroll", preload);
}, 500);
}
}
window.addEventListener("scroll", preload);
}
function handleHeaderImage() {
const source = _GM_getValue("header-image-source", "unsplash");
const mapping = {
bing: "https://api.suyanw.cn/api/bing.php",
unsplash: "https://unsplash.it/1600/900?random",
picsum: "https://picsum.photos/1600/900",
meizi: "https://api.suyanw.cn/api/sjbz.php?method=pc&lx=meizi",
dongman: "https://api.suyanw.cn/api/sjbz.php?method=pc&lx=dongman",
fengjing: "https://api.suyanw.cn/api/sjbz.php?method=pc&lx=fengjing",
suiji: "https://api.suyanw.cn/api/sjbz.php?method=pc&lx=suiji"
};
let url = mapping[source];
const elementSelector = ".bili-header__banner";
const key = "header-image";
loadImage(key, elementSelector);
if (source !== "local") {
setTimeout(renewImage, 5e3);
}
window.addEventListener("variableChanged", (event) => {
const e = event;
if (e.detail.key === "header-image-source") {
url = mapping[e.detail.newValue];
setTimeout(() => renewImage(true), 0);
}
});
async function renewImage(loadImmediately) {
try {
const img = await getImage(url);
const base64Data = imageToBase64(img);
storeImage(key, base64Data);
if (loadImmediately) {
loadImage(key, elementSelector);
}
} catch (error) {
console.error("Failed to get image:", error);
}
}
function getImage(url2) {
return new Promise((resolve, reject) => {
const img = new Image();
img.crossOrigin = "Anonymous";
img.src = url2;
img.onload = () => resolve(img);
img.onerror = reject;
});
}
function imageToBase64(img) {
const canvas = document.createElement("canvas");
canvas.width = img.width;
canvas.height = img.height;
const ctx = canvas.getContext("2d");
ctx == null ? void 0 : ctx.drawImage(img, 0, 0);
return canvas.toDataURL("image/jpeg");
}
function storeImage(key2, base64Data) {
localStorage.setItem(key2, base64Data);
}
function loadImage(key2, elementSelector2) {
const base64Data = localStorage.getItem(key2);
if (base64Data) {
applyStyle(elementSelector2, base64Data);
} else {
getImage(url).then((img) => {
const base64Data2 = imageToBase64(img);
storeImage(key2, base64Data2);
applyStyle(elementSelector2, base64Data2);
}).catch((error) => console.error("Failed to get image:", error));
}
}
function applyStyle(elementSelector2, base64Data) {
const style = document.createElement("style");
style.innerHTML = `
${elementSelector2}::after {
content: '';
position: absolute;
top: 0;
left: 0;
width: 100%;
height: 100%;
z-index: -1;
background-image: url(${base64Data});
background-size: cover;
background-position: center;
}
`;
document.head.appendChild(style);
}
}
function handleVideoCard() {
judgeHasAi();
let isLoading = false;
new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (isLoading) {
return;
}
mutation.addedNodes.forEach((node) => {
if (node.nodeType === Node.ELEMENT_NODE && node.classList.contains("bili-video-card")) {
isLoading = true;
setTimeout(() => {
judgeHasAi();
isLoading = false;
}, 2e3);
}
});
});
}).observe(
document.querySelector(".recommended-container_floor-aside>.container"),
{ childList: true }
);
function judgeHasAi() {
const imageLinks = document.querySelectorAll(
".bili-video-card__image--link"
);
let delay = 0;
imageLinks.forEach(async (link) => {
await new Promise((resolve) => setTimeout(resolve, delay));
const card = link.closest(
".bili-video-card:not(:has(.bili-video-card__info--ad))"
);
if (card && !link.dataset.hasJudgedAi) {
const aiJudgeRes = await judge(card);
if (aiJudgeRes) {
card.dataset.hasAi = "true";
}
delay += 100;
}
link.dataset.hasJudgedAi = "true";
});
}
let lastPreviewCard = null;
new MutationObserver((mutations) => {
mutations.forEach(async (mutation) => {
var _a;
const firstChild = (_a = mutation.addedNodes[0]) == null ? void 0 : _a.firstChild;
if (firstChild && firstChild.className === "v-popover is-bottom-end") {
const panel = firstChild.querySelector(
".bili-video-card__info--no-interest-panel"
);
const previewOption = createOption("预览此视频");
panel.insertBefore(previewOption, panel.firstChild);
previewOption.addEventListener(
"click",
(event) => onPreviewOptionClick(event, firstChild)
);
const card = await getCard();
if (!card) {
return;
}
const hasAi = card.dataset.hasAi;
if (!hasAi) {
return;
}
const AIOption = createOption("生成视频总结");
panel.insertBefore(AIOption, previewOption.nextSibling);
AIOption.addEventListener("click", async (event) => {
event.stopPropagation();
firstChild.dispatchEvent(
new MouseEvent("mouseleave", { bubbles: true })
);
loadAI(card);
});
}
});
}).observe(document.body, { childList: true });
window.addEventListener("click", (event) => {
const btn = document.querySelector(
".bili-video-card__info--no-interest.active"
);
if (btn == null ? void 0 : btn.contains(event.target)) {
btn.dispatchEvent(new MouseEvent("mouseleave", { bubbles: true }));
btn.classList.remove("use");
btn.addEventListener(
"click",
() => {
btn.dispatchEvent(new MouseEvent("mouseenter", { bubbles: true }));
},
{ once: true }
);
}
});
function onPreviewOptionClick(event, firstChild) {
event.stopPropagation();
firstChild.dispatchEvent(new MouseEvent("mouseleave", { bubbles: true }));
window.addEventListener(
"click",
() => {
lastPreviewCard == null ? void 0 : lastPreviewCard.dispatchEvent(
new MouseEvent("mouseleave", { bubbles: true })
);
},
{ once: true }
);
const card = document.querySelector(".bili-video-card__info--no-interest.active").closest(".bili-video-card");
const cardEventWrap = card.querySelector(
".bili-video-card__image--wrap"
);
cardEventWrap.dispatchEvent(new MouseEvent("mouseenter", { bubbles: true }));
lastPreviewCard = cardEventWrap;
if (!cardEventWrap.querySelector(".inline-progress-bar")) {
const intervalId = setInterval(() => {
if (cardEventWrap.querySelector("video")) {
createProgressBar(cardEventWrap);
clearInterval(intervalId);
}
}, 1e3);
}
}
function createProgressBar(cardEventWrap) {
const progressBar = document.createElement("div");
progressBar.className = "inline-progress-bar";
progressBar.innerHTML = '
';
cardEventWrap.appendChild(progressBar);
const video = cardEventWrap.querySelector("video");
const progressBarFilled = progressBar.querySelector(
".inline-progress-bar-filled"
);
const progressBarThumb = progressBar.querySelector(
".inline-progress-bar-thumb"
);
const progressBarWidth = progressBar.offsetWidth;
function updateProgressBar(progress) {
progressBarFilled.style.width = `${progress * 100}%`;
progressBarThumb.style.left = `${progress * progressBarWidth}px`;
}
video.addEventListener(
"timeupdate",
() => {
const progress = Math.min(
Math.max(video.currentTime / video.duration, 0),
1
);
updateProgressBar(progress);
},
true
);
video.addEventListener(
"timeupdate",
(event) => event.stopImmediatePropagation(),
true
);
function onTouchEvent(event) {
const progress = (event.touches[0].clientX - progressBar.getBoundingClientRect().left) / progressBarWidth;
updateProgressBar(progress);
video.currentTime = progress * video.duration;
}
progressBar.addEventListener("touchstart", (event) => {
onTouchEvent(event);
document.addEventListener("touchmove", onTouchEvent);
});
document.addEventListener("touchend", () => {
document.removeEventListener("touchmove", onTouchEvent);
});
progressBar.addEventListener("click", (event) => {
event.preventDefault();
event.stopPropagation();
});
}
async function judge(card) {
const cardImageLinkElement = card.querySelector(
".bili-video-card__image--link"
);
const match = /\/video\/([A-Za-z0-9]+)/.exec(cardImageLinkElement.dataset.targetUrl) || /\/video\/([A-Za-z0-9]+)/.exec(cardImageLinkElement.href);
const bvid = match[1];
try {
const videoInfo = await getVideoInfo(bvid);
cardImageLinkElement.dataset.cid = videoInfo.cid;
cardImageLinkElement.dataset.bvid = videoInfo.bvid;
cardImageLinkElement.dataset.upMid = videoInfo.owner.mid;
const cid = videoInfo.cid;
const up_mid = videoInfo.owner.mid;
const aiJudgeRes = await getJudgeAI({ bvid, cid, up_mid });
return aiJudgeRes.judge === 1;
} catch (error) {
console.error(error);
}
}
function createOption(text) {
return Object.assign(document.createElement("div"), {
className: "bili-video-card__info--no-interest-panel--item",
textContent: text
});
}
async function getCard() {
return new Promise((resolve) => {
setTimeout(() => {
const btn = document.querySelector(
".bili-video-card__info--no-interest.active:not(.use)"
);
if (!btn) {
resolve(null);
console.log("疑似弹窗动作被打断:未获取到激活的视频更多选项按钮");
return;
}
const card = btn.closest(".bili-video-card");
btn.classList.add("use");
resolve(card);
}, 50);
});
}
}
function videoInteraction() {
handlePortrait();
handlelVideoClick();
handleVideoInteraction();
foldDescTag();
closeMiniPlayer();
setEndingContent();
modifyShadowDOMLate();
}
let isPortrait = false;
function handlePortrait() {
const video = document.querySelector(
"#bilibili-player video"
);
video.addEventListener("resize", () => {
isPortrait = video.videoHeight / video.videoWidth > 1;
});
}
function handlelVideoClick() {
const playerContainter = document.querySelector(
".bpx-player-container"
);
const videoArea = playerContainter.querySelector(
".bpx-player-video-area"
);
const videoPerch = videoArea.querySelector(
".bpx-player-video-perch"
);
const videoWrap = videoPerch.querySelector(
".bpx-player-video-wrap"
);
const video = videoWrap.querySelector("video");
videoArea.insertBefore(videoWrap, videoPerch);
video.playsInline = true;
const oldControlWrap = videoArea.querySelector(
".bpx-player-control-wrap"
);
const controlEntity = oldControlWrap.querySelector(
".bpx-player-control-entity"
);
let clickTimer;
let hideTimer;
const controlWrap = Object.assign(document.createElement("div"), {
className: "bpx-player-control-wrap new",
innerHTML: '
'
});
videoArea.insertBefore(controlWrap, oldControlWrap);
controlWrap.appendChild(controlEntity);
const isBpxStateShow = () => controlEntity.querySelector(
".bpx-player-control-bottom-right>.bpx-state-show"
);
const controlTop = controlEntity.querySelector(
".bpx-player-control-top"
);
const bottomRight = controlEntity.querySelector(
".bpx-player-control-bottom-right"
);
const isShown = () => playerContainter.getAttribute("ctrl-shown") === "true";
playerContainter.setAttribute("ctrl-shown", "false");
const observer = new MutationObserver((mutations) => {
mutations.forEach((mutation) => {
if (mutation.addedNodes[0].classList.contains(
"bpx-player-ctrl-web"
)) {
if (video.paused) {
showControlWrap();
}
const subtitleBtn = document.querySelector(".bpx-player-ctrl-subtitle");
if (subtitleBtn) {
window.addEventListener("click", (event) => {
if (!subtitleBtn.contains(event.target)) {
subtitleBtn.dispatchEvent(new MouseEvent("mouseleave"));
}
});
}
observer.disconnect();
}
});
});
observer.observe(bottomRight, { childList: true });
function hideControlWrap(isEnd = false) {
if (!video.paused && !isBpxStateShow() || isEnd) {
playerContainter.setAttribute("ctrl-shown", "false");
clearTimeout(hideTimer);
} else {
delayHideTimer();
}
}
video.addEventListener("ended", () => {
hideControlWrap(true);
});
function showControlWrap() {
playerContainter.setAttribute("ctrl-shown", "true");
delayHideTimer();
}
function delayHideTimer() {
clearTimeout(hideTimer);
hideTimer = setTimeout(hideControlWrap, 3e3);
}
videoWrap.addEventListener("mousemove", (event) => {
event.stopPropagation();
});
controlWrap.addEventListener("mousemove", (event) => {
event.stopPropagation();
});
video.addEventListener("play", delayHideTimer);
controlWrap.addEventListener("click", (event) => {
event.stopPropagation();
delayHideTimer();
});
controlTop.addEventListener("touchstart", delayHideTimer);
videoWrap.addEventListener("click", () => {
clearTimeout(clickTimer);
clickTimer = setTimeout(() => {
if (isShown()) hideControlWrap();
else showControlWrap();
if (!_GM_getValue("ban-video-click-play", false)) {
if (video.paused) video.play();
else video.pause();
}
}, 250);
});
videoWrap.addEventListener("dblclick", () => {
clearTimeout(clickTimer);
unmute();
if (isPortrait)
document.querySelector(".bpx-player-ctrl-web").click();
else videoPerch.dispatchEvent(new MouseEvent("dblclick", { bubbles: true }));
});
function unmute() {
video.muted = false;
if (video.volume === 0) {
document.querySelector(".bpx-player-ctrl-muted-icon").click();
}
}
videoArea.addEventListener("touchstart", (event) => {
event.stopPropagation();
});
if (_GM_getValue("video-click-unmute", false)) {
window.addEventListener("click", (event) => {
console.log(event.target);
if (!videoArea.contains(event.target)) {
unmute();
}
});
}
}
function closeMiniPlayer() {
if (!localStorage.getItem("is-mini-player-closed")) {
const miniPlayerBtn = document.getElementsByClassName(
"mini-player-window"
)[0];
new MutationObserver(
(mutations) => mutations.forEach((mutation) => {
if (mutation.target.classList.contains("on")) {
miniPlayerBtn.click();
localStorage.setItem("is-mini-player-closed", "true");
}
})
).observe(miniPlayerBtn, { attributes: true, attributeFilter: ["class"] });
}
}
function handleVideoInteraction() {
const video = document.querySelector("video");
let startX, startY, startTime;
const threshold = 10;
const initialCheckDuration = 300;
let isLongPress = false;
let isSliding = false;
let timeoutId;
let times;
let isSlideAllowed;
let progressInfo;
let progressInfoCreated = false;
let isCreatingProgressInfo = false;
video.addEventListener("touchstart", (event) => {
startX = event.touches[0].clientX;
startY = event.touches[0].clientY;
startTime = video.currentTime;
times = Number(_GM_getValue("video-longpress-speed", "2"));
isSlideAllowed = _GM_getValue("allow-video-slid", false);
timeoutId = setTimeout(() => {
video.playbackRate = video.playbackRate * times;
isLongPress = true;
}, initialCheckDuration);
});
video.addEventListener("touchmove", (event) => {
if (!isSlideAllowed) {
return;
}
const moveX = event.touches[0].clientX;
const moveY = event.touches[0].clientY;
const deltaX = moveX - startX;
const deltaY = moveY - startY;
if (Math.abs(deltaX) > threshold || Math.abs(deltaY) > threshold) {
if (!isLongPress) {
clearTimeout(timeoutId);
isSliding = true;
} else {
return;
}
if (isSliding) {
if (!progressInfoCreated && !isCreatingProgressInfo) {
isCreatingProgressInfo = true;
progressInfo = document.createElement("div");
progressInfo.id = "progress-info";
video.parentNode.insertBefore(progressInfo, video.nextSibling);
progressInfoCreated = true;
isCreatingProgressInfo = false;
}
video.pause();
const progressChange = deltaX / video.clientWidth * video.duration;
video.currentTime = startTime + progressChange;
if (progressInfoCreated) {
progressInfo.textContent = `进度: ${formatTime(video.currentTime)} / ${formatTime(video.duration)}`;
progressInfo.style.display = "block";
}
}
}
});
video.addEventListener("touchend", () => {
clearTimeout(timeoutId);
if (isLongPress) {
video.playbackRate = video.playbackRate / times;
isLongPress = false;
}
if (isSliding) {
video.play();
progressInfo.style.display = "";
isSliding = false;
}
});
function formatTime(seconds) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor(seconds % 3600 / 60);
const secs = Math.floor(seconds % 60);
return `${hours}:${String(minutes).padStart(2, "0")}:${String(secs).padStart(2, "0")}`;
}
}
function foldDescTag() {
if (!_GM_getValue("fold-desc-tag", false)) return;
const underPlayer = document.querySelector(".left-container-under-player");
const foldBtn = Object.assign(document.createElement("div"), {
id: "fold-desc-btn",
innerHTML: `
`
});
foldBtn.addEventListener("click", () => {
underPlayer.toggleAttribute("unfold");
});
setTimeout(() => {
var _a, _b;
underPlayer.insertBefore(foldBtn, underPlayer.firstChild);
(_a = document.querySelector(".toggle-btn")) == null ? void 0 : _a.click();
(_b = document.querySelector(".tag:has(>.show-more-btn)")) == null ? void 0 : _b.click();
}, 2e3);
}
function setEndingContent() {
addEndingScale();
function addEndingScale() {
const style = Object.assign(document.createElement("style"), {
id: "ending-content-scale",
textContent: `
.bpx-player-ending-content[screen-mode=little-screen] { transform: scale(calc(${window.innerWidth}/536*0.9)) !important; }
.bpx-player-ending-content { transform: scale(calc(${window.innerWidth}/710*0.9)) !important; }
.bpx-player-container[data-screen=full] .bpx-player-ending-content { transform: scale(calc(${window.innerWidth}/952*0.9)) !important; }
`
});
document.head.appendChild(style);
}
function renewEndingScale() {
var _a;
(_a = document.head.querySelector("#ending-content-scale")) == null ? void 0 : _a.remove();
addEndingScale();
}
screen.orientation.addEventListener("change", renewEndingScale);
window.addEventListener("resize", renewEndingScale);
}
function createUnfoldBtn() {
const observer = new MutationObserver(
(mutations) => mutations.forEach((mutation) => {
var _a;
if ((_a = mutation.addedNodes[0]) == null ? void 0 : _a.classList.contains("bili-im")) {
createElement();
observer.disconnect();
}
})
);
const messageContainer = document.querySelector(
"body>.container"
);
observer.observe(messageContainer, { childList: true, subtree: true });
function createElement() {
const unfoldBtn = Object.assign(document.createElement("div"), {
id: "unfold-btn",
textContent: "展开"
});
const messageList = document.querySelector(".bili-im .left");
messageList.appendChild(unfoldBtn);
unfoldBtn.addEventListener("click", () => {
if (messageList.style.cssText === "") {
messageList.style.cssText = "width: 240px !important";
unfoldBtn.textContent = "折叠";
} else {
messageList.style.cssText = "";
unfoldBtn.textContent = "展开";
}
});
}
}
function coverContextMenu() {
if (!_GM_getValue("cover-context-menu", false)) return;
window.addEventListener(
"contextmenu",
(event) => {
if (event.target.className === "message-content") {
event.stopImmediatePropagation();
}
},
true
// 在捕获阶段
);
}
(function() {
if (window.top !== window.self) {
return;
}
document.head.appendChild(
Object.assign(document.createElement("meta"), {
name: "viewport",
content: "width=device-width, initial-scale=1"
})
);
preventBeforeUnload();
countViewTime();
document.head.appendChild(
Object.assign(document.createElement("link"), {
rel: "stylesheet",
href: "https://s1.hdslb.com/bfs/static/jinkela/space/css/space.8.22c06a62b42dec796d083a84f5a769f44a97b325.css"
})
);
console.log("Bilibili mobile execute!");
const firstSubdomain = location.hostname.substring(
0,
location.hostname.indexOf(".")
);
const pathToTypeMap = {
"/video": "video",
"/list": "list"
};
const getTypeFromPath = (map) => {
for (const [prefix, type2] of Object.entries(map)) {
if (location.pathname.startsWith(prefix)) {
return type2;
}
}
return "unknow";
};
const type = firstSubdomain === "www" ? location.pathname === "/" ? "home" : getTypeFromPath(pathToTypeMap) : firstSubdomain;
function handleCommonSettings(type2) {
handleScriptPreSetting();
waitDOMContentLoaded(() => {
handleScriptSetting();
handleActionbar(type2);
handleScroll(type2);
setScriptHelp();
});
}
handleCommonSettings(type);
switch (type) {
case "home":
increaseVideoLoadSize();
handleHeaderImage();
waitDOMContentLoaded(() => {
preloadAnchor();
handleVideoCard();
});
break;
case "video":
case "list":
waitDOMContentLoaded(videoInteraction);
break;
case "message":
waitDOMContentLoaded(() => {
createUnfoldBtn();
coverContextMenu();
});
break;
}
})();
})();