diff --git a/README.md b/README.md index 6b073c418..b5d097663 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ # Bilibili-Evolved 增强哔哩哔哩Web端体验的油猴脚本. -**注: 作为[原脚本](bilibili-touch.js)的工程化形式,目前尚未完成,在完成之前可以先使用[原脚本](bilibili-touch.js).** +**注: 作为[原脚本](bilibili-touch.user.js)的工程化形式,目前尚未完成,在完成之前可以先使用[原脚本](bilibili-touch.user.js).([安装原脚本](https://github.com/the1812/Bilibili-Evolved/raw/master/bilibili-touch.user.js))** # 功能概览 ## 新样式 @@ -67,7 +67,7 @@ ![放大前](images/player-buttons-original.png) ##### 启用后 ![放大后](images/player-buttons-large.png) -## 展开弹幕列表 +## 自动展开弹幕列表 新版播放页面中,弹幕列表默认收起以显示推荐的其他视频.启用此功能可在每次加载视频时自动展开弹幕列表. ## 删除广告 删除嵌于页面中的推广横幅. @@ -80,3 +80,9 @@ # 安装 - [正式版](https://github.com/the1812/Bilibili-Evolved/raw/master/bilibili-evolved.user.js) - [预览版](https://github.com/the1812/Bilibili-Evolved/raw/preview/bilibili-evolved.preview.user.js) +# 兼容性 +浏览器 | 兼容性 | 注释 +------|-------|----- +Chrome | 兼容 | | +FireFox | 未知 | 滚动条样式无效. | +Edge | 部分兼容 | 自定义颜色与滚动条样式无效,图片锯齿严重,顶栏触摸体验不佳. | diff --git a/bilibili-evolved.preview.user.js b/bilibili-evolved.preview.user.js index edd5cc31a..2c43c8040 100644 --- a/bilibili-evolved.preview.user.js +++ b/bilibili-evolved.preview.user.js @@ -1,12 +1,14 @@ // ==UserScript== // @name Bilibili Evolved (Preview) -// @version 0.9.0 +// @version 0.9.2 // @description 增强哔哩哔哩Web端体验. (预览版分支) // @author Grant Howard // @match *://*.bilibili.com/* // @match *://*.bilibili.com // @grant unsafeWindow -// @require https://static.hdslb.com/js/jquery.min.js +// @grant GM_getValue +// @grant GM_setValue +// @require https://code.jquery.com/jquery-3.2.1.min.js // @icon https://raw.githubusercontent.com/the1812/Bilibili-Evolved/preview/images/logo.png // ==/UserScript== (self$ => @@ -35,19 +37,13 @@ grey: "#757575", blueGrey: "#607D8B" }; - // User settings will overwrite default settings below - const userSettings = { - customStyleColor: colors.pink, - showBanner: false, - useDarkStyle: true - }; const settings = { // remove ads removeAds: true, // max retry count used for query elements - touchNavBar: true, + touchNavBar: false, // (Experimental) touch support for video player - touchVideoPlayer: true, + touchVideoPlayer: false, // redirect to original sites in watchlater list watchLaterRedirect: true, // auto expand danmaku list @@ -65,15 +61,11 @@ // show top banner showBanner: true, // [New Styles] - // (Not Implemented) use dark mode - useDarkStyle: true, + // (Experimental) use dark mode + useDarkStyle: false, // use new styles for nav bar and player useNewStyle: true }; - for (const key in userSettings) - { - settings[key] = userSettings[key]; - } const ajaxReload = [ "touchVideoPlayer", "watchLaterRedirect", @@ -116,7 +108,42 @@ xhr.open("GET", url); xhr.send(); } - + function reload(resources) + { + // settings.guiSettings = true; + for (const key in settings) + { + if (settings[key] === true) + { + const func = eval(resources.data[key]); + if (func) + { + func(settings, resources); + if (ajaxReload.indexOf(key) !== -1) + { + $(document).ajaxComplete(() => + { + func(settings, resources); + }); + } + } + } + } + } + function loadSettings() + { + for (const key in settings) + { + settings[key] = GM_getValue(key, settings[key]); + } + } + function saveSettings() + { + for (const key in settings) + { + GM_setValue(key, settings[key]); + } + } class ExternalResource { static get resourceUrls() @@ -129,6 +156,9 @@ touchPlayerStyle: "style/style-touch-player.scss", navbarOverrideStyle: "style/style-navbar-override.css", noBannerStyle: "style/style-no-banner.css", + guiSettingsStyle: "style/style-gui-settings.scss", + guiSettingsDom: "utils/gui-settings.html", + guiSettings: "utils/gui-settings.js", useDarkStyle: "style/dark-styles.min.js", useNewStyle: "style/new-styles.min.js", touchNavBar: "touch/touch-navbar.min.js", @@ -216,27 +246,159 @@ } } + loadSettings(); const resources = new ExternalResource(); resources.ready(() => { - for (const key in settings) - { - if (settings[key] === true) + reload(resources); + + // gui-settings.js + const svgData = { + settings: "M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z", + close: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z", + ok: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" + }; + const textValidate = { + "customStyleColor": text => { - const func = eval(resources.data[key]); - if (func) + const match = text.match(/^#([0-9a-fA-F]{6}|[0-9a-fA-F]{3})$/); + if (match) { - func(settings, resources); - if (ajaxReload.indexOf(key) !== -1) + if (text.length < 7) { - $(document).ajaxComplete(() => - { - func(settings, resources); - }); + return `#${text[0]}${text[0]}${text[1]}${text[1]}${text[2]}${text[2]}`; + } + else + { + return text; } } + else + { + return settings.customStyleColor; + } + }, + "blurBackgroundOpacity": text => + { + const match = text.match(/^([-\+]?\d+)(\.\d+)?$/); + if (match) + { + const value = parseFloat(text); + if (value >= 0 && value <= 1) + { + return text; + } + } + return settings.blurBackgroundOpacity; } - } + }; + waitForQuery()( + () => $(".gr__bilibili_com>body"), + it => it.length > 0, + it => + { + if ($(".gui-settings").length === 0) + { + it.append(`
+ + + +
`); + $(".gui-settings").on("click", () => + { + $(".gui-settings-panel").css("display", "flex"); + }); + } + const style = resources.getStyle("guiSettingsStyle", "gui-settings-style"); + $("body").after(style); + const settingsBox = resources.data.guiSettingsDom; + if (settingsBox) + { + const reloadGuiSettings = () => + { + for (const key in settings) + { + $(`input[type='checkbox'][key='${key}']`).prop("checked", settings[key]); + $(`input[type='text'][key='${key}']`).val(settings[key]); + } + }; + $("body").append(settingsBox); + $(".gui-settings-header .gui-settings-close").on("click", () => + { + $(".gui-settings-panel").css("display", "none"); + }); + $("button.save").on("click", () => + { + $("input[type='checkbox'][key]") + .each((_, element) => + { + settings[$(element).attr("key")] = $(element).prop("checked"); + }); + $("input[type='text'][key]") + .each((_, element) => + { + const key = $(element).attr("key"); + const value = $(element).val(); + settings[key] = textValidate[key](value); + }); + saveSettings(); + const svg = $(".gui-settings-footer svg.gui-settings-ok"); + if (parseInt(svg.css("width")) === 0) + { + svg.css({ + width: "30px", + marginLeft: "3rem" + }); + setTimeout(() => + { + svg.css({ + width: "0", + marginLeft: "0" + }); + }, 3000); + } + reloadGuiSettings(); + }); + + $(".gui-settings-close path").attr("d", svgData.close); + $(".gui-settings-ok path").attr("d", svgData.ok); + $(".gui-settings svg path").attr("d", svgData.settings); + + reloadGuiSettings(); + const dependencies = {}; + $(`input[dependencies]`).each((_, element) => + { + dependencies[$(element).attr("key")] = $(element).attr("dependencies"); + }); + $(`input[type='checkbox']`).on("change", e => + { + const self = $(e.srcElement); + const checked = self.prop("checked"); + for (const key in dependencies) + { + const dependency = dependencies[key].split(" "); + if (dependency.indexOf(self.attr("key")) !== -1) + { + let value = true; + if (checked && dependency.every(k => $(`input[key='${k}']`).prop("checked"))) + { + value = false; + } + $(`input[key='${key}']`).prop("disabled", value); + if (value) + { + $(`input[key='${key}'][type='text']`).parent().addClass("disabled"); + } + else + { + $(`input[key='${key}'][type='text']`).parent().removeClass("disabled"); + } + } + } + }); + } + } + ); }); }); })(window.jQuery.noConflict(true)); diff --git a/bilibili-evolved.user.js b/bilibili-evolved.user.js index aa3b72013..6270b45b5 100644 --- a/bilibili-evolved.user.js +++ b/bilibili-evolved.user.js @@ -129,6 +129,9 @@ touchPlayerStyle: "style/style-touch-player.scss", navbarOverrideStyle: "style/style-navbar-override.css", noBannerStyle: "style/style-no-banner.css", + guiSettingsStyle: "style/style-gui-settings.scss", + guiSettingsDom: "utils/gui-settings.html", + guiSettings: "utils/gui-settings.js", useDarkStyle: "style/dark-styles.min.js", useNewStyle: "style/new-styles.min.js", touchNavBar: "touch/touch-navbar.min.js", @@ -219,6 +222,7 @@ const resources = new ExternalResource(); resources.ready(() => { + settings.guiSettings = true; for (const key in settings) { if (settings[key] === true) diff --git a/bilibili-touch.js b/bilibili-touch.user.js similarity index 100% rename from bilibili-touch.js rename to bilibili-touch.user.js diff --git a/style/dark-styles.js b/style/dark-styles.js index 351e29033..16a42be11 100644 --- a/style/dark-styles.js +++ b/style/dark-styles.js @@ -2,10 +2,10 @@ { return (settings, resources) => { + $("#bilibili-new-style-dark").remove(); if (settings.useNewStyle) { const styles = resources.getStyle("darkStyle", "bilibili-new-style-dark"); - $("#bilibili-new-style-dark").remove(); $("body").after(styles); } }; diff --git a/style/dark-styles.min.js b/style/dark-styles.min.js index b6a9d7469..0c76ad572 100644 --- a/style/dark-styles.min.js +++ b/style/dark-styles.min.js @@ -1 +1 @@ -(()=>(settings,resources)=>{if(settings.useNewStyle){const styles=resources.getStyle("darkStyle","bilibili-new-style-dark");$("#bilibili-new-style-dark").remove(),$("body").after(styles)}})(); \ No newline at end of file +(()=>(e,i)=>{if($("#bilibili-new-style-dark").remove(),e.useNewStyle){const e=i.getStyle("darkStyle","bilibili-new-style-dark");$("body").after(e)}})(); \ No newline at end of file diff --git a/style/new-styles.js b/style/new-styles.js index 373acf957..847a77654 100644 --- a/style/new-styles.js +++ b/style/new-styles.js @@ -4,7 +4,7 @@ { waitForQuery()( () => $(".nav-search-keyword"), - it => it.length > 0, + it => it.length > 0 && it.attr("placeholder").length > 0, textBox => textBox.attr("placeholder", "搜索") ); waitForQuery()( diff --git a/style/new-styles.min.js b/style/new-styles.min.js index 5ab3d21d1..ca3d4a44e 100644 --- a/style/new-styles.min.js +++ b/style/new-styles.min.js @@ -1 +1 @@ -(()=>(settings,resources)=>{waitForQuery()(()=>$(".nav-search-keyword"),it=>it.length>0,textBox=>textBox.attr("placeholder","搜索")),waitForQuery()(()=>$(".custom-scrollbar"),it=>it.length>0,it=>it.removeClass("custom-scrollbar"));const navbar=document.getElementsByClassName("bili-wrapper")[0];let stardustStyles=!1;navbar instanceof Element&&(stardustStyles=50===parseInt(window.getComputedStyle(navbar).height));let styles="";if(styles=stardustStyles?resources.getStyle("style","bilibili-new-style"):resources.getStyle("oldStyle","bilibili-new-style"),$("#bilibili-new-style").remove(),$("body").after(styles),settings.overrideNavBar){waitForQuery()(()=>$(".search"),it=>it.length>0&&$(".nav-con.fr").length>0,textBox=>{textBox.detach().insertAfter(".nav-con.fr")}),waitForQuery()(()=>$("input.search-keyword"),it=>it.length>0,textBox=>textBox.attr("placeholder","搜索"));const navBarStyles=resources.getStyle("navbarOverrideStyle","bilibili-nav-bar-override");if($("body").after(navBarStyles),!settings.showBanner){const bannerStyles=resources.getStyle("noBannerStyle","bilibili-banner-override");$("body").after(bannerStyles)}}})(); \ No newline at end of file +(()=>(e,t)=>{waitForQuery()(()=>$(".nav-search-keyword"),e=>e.length>0&&e.attr("placeholder").length>0,e=>e.attr("placeholder","搜索")),waitForQuery()(()=>$(".custom-scrollbar"),e=>e.length>0,e=>e.removeClass("custom-scrollbar"));const r=document.getElementsByClassName("bili-wrapper")[0];let l=!1;r instanceof Element&&(l=50===parseInt(window.getComputedStyle(r).height));let a="";if(a=l?t.getStyle("style","bilibili-new-style"):t.getStyle("oldStyle","bilibili-new-style"),$("#bilibili-new-style").remove(),$("body").after(a),e.overrideNavBar){waitForQuery()(()=>$(".search"),e=>e.length>0&&$(".nav-con.fr").length>0,e=>{e.detach().insertAfter(".nav-con.fr")}),waitForQuery()(()=>$("input.search-keyword"),e=>e.length>0,e=>e.attr("placeholder","搜索"));const r=t.getStyle("navbarOverrideStyle","bilibili-nav-bar-override");if($("body").after(r),!e.showBanner){const e=t.getStyle("noBannerStyle","bilibili-banner-override");$("body").after(e)}}})(); \ No newline at end of file diff --git a/style/style-dark.scss b/style/style-dark.scss index 54dde7cbe..10385051c 100644 --- a/style/style-dark.scss +++ b/style/style-dark.scss @@ -123,7 +123,9 @@ div.con, .my-album .tab-list, #page-setting #setting-new-tag, #page-setting #setting-new-tag-btn, -.imagesbox .boost-img +.imagesbox .boost-img, +.bui-slider .bui-track.bui-track-video-progress .bui-bar-wrap, +.gui-settings-box { background-color: #222 !important; } @@ -173,7 +175,6 @@ li.suggest-item:hover, div.drag-bar, .bpui-slider-tracker, .bilibili-player-video-progress-buffer, -.bilibili-player-video-btn:hover, .bilibili-player-setting-menu-wrap, .bilibili-player-setting-menu-list, .opera-list, @@ -238,7 +239,8 @@ a.more.tc-slate:hover, #page-setting .setting-index-module, .btn.ghost, .bili-header-m .profile-m .grade .bar, -.video-page-card .card-box .info .pre-mask +.video-page-card .card-box .info .pre-mask, +.bui-button.bui-button-transparent { background-color: #444 !important; } @@ -291,6 +293,10 @@ li.context-menu-descipline a, { background-color: #222e !important; } +.bilibili-player-video-sendbar .bilibili-player-video-inputbar +{ + background: #fff1 !important; +} .bili-footer a, a.pic>p.title, @@ -640,7 +646,13 @@ div.con header, #page-channel-index .channel-item .channel-name, #page-setting .setting-privacy-item .setting-privacy-name, #page-setting #setting-new-tag, -.btn.ghost +.btn.ghost, +.gui-settings, +.bui-button.bui-button-transparent, +.gui-settings-box, +.pop-live .pl__head, +.pop-live .pl__title, +.gui-settings-textbox-container input { color: #eee !important; } @@ -836,7 +848,9 @@ div.con header, .elec .elec-avatar, .contribution-sidenav~.main-content, .contribution-sidenav, -#page-myalbum .album-content +#page-myalbum .album-content, +.v-wrap .s_tag, +.bui-button.bui-button-transparent { border-color: #444 !important } @@ -986,6 +1000,7 @@ div.desc-tips>span.arrow-left, { opacity: 0 !important; } +.bui-bar.bui-bar-buffer, .bilibili-player-video-progress-buffer-range { opacity: 0.5 !important; @@ -1086,7 +1101,8 @@ input[type=text]:focus, .wrapper .modal-body .choice-wrp.selected .elec-input, .wrapper .modal-body .choice-wrp.selected .battery, .be-pager-item-active, -.top-title .concern +.top-title .concern, +.bui-button.bui-button-transparent:hover { border-color: $customStyleColor !important; } @@ -1160,7 +1176,8 @@ a.s-btn:hover, #page-channel-index .channel-option.no-channel .create-channel, .be-switch-container.is-checked .be-switch, #page-setting #setting-new-tag-btn, -.top-title .concern +.top-title .concern, +.bui-button.bui-button-transparent:hover { background-color: $customStyleColor !important; } @@ -1291,7 +1308,10 @@ a.up-name:hover, .tabs a:hover, #page-subs .detail a:hover, #page-subs .action .sub-action, -#page-channel-index .no-channel-container em +#page-channel-index .no-channel-container em, +.bui-switch .bui-checkbox:checked+.bui-body .bui-dot, +.bilibili-player-video-danmaku-setting-left-block-content .bilibili-player-block-filter-type.disabled .bilibili-player-block-filter-label, +.bui-select.bui-select-quality-menu .bui-select-item.bui-select-item-active { color: $customStyleColor !important; } @@ -1346,15 +1366,26 @@ a.s-btn:hover, .be-pager-item-active a, .contribution-sidenav .contribution-item.cur .text:hover, .be-pager-item.be-pager-item-active:hover a, -.top-title .concern +.top-title .concern, +.bui-button.bui-button-transparent:hover { color: $foreground !important; } .bui-checkbox .bui-checkbox-input:checked+.bui-checkbox-label .bui-checkbox-icon svg, -.bui-checkbox:hover .bui-checkbox-icon svg +.bui-checkbox:hover .bui-checkbox-icon svg, +.bui-switch .bui-checkbox:checked+.bui-body .bui-dot, +.bilibili-player-block-filter-type:hover .bilibili-player-block-filter-image, +.bilibili-player-video-danmaku-setting-left-block-content .bilibili-player-block-filter-type.disabled .bilibili-player-block-filter-image, +.bilibili-player-mode-selection-container .bilibili-player-mode-selection-panel .bilibili-player-mode-selection-row.mode .selection-span.active, + .bilibili-player-mode-selection-container .bilibili-player-mode-selection-panel .bilibili-player-mode-selection-row.mode .selection-span.active:hover, + .bilibili-player-mode-selection-container .bilibili-player-mode-selection-panel .bilibili-player-mode-selection-row.mode .selection-span:hover { fill: $customStyleColor !important; } +.gui-settings-close path +{ + fill: #eee; +} .history-wrap .active:before, .history-wrap .time-label:after, diff --git a/style/style-gui-settings.scss b/style/style-gui-settings.scss new file mode 100644 index 000000000..224cff0d6 --- /dev/null +++ b/style/style-gui-settings.scss @@ -0,0 +1,234 @@ +.gui-settings-icon-panel +{ + height: 100%; + display: flex; + justify-content: center; + align-items: center; + position: absolute; + top: 0; + left: 0; + width: 24px; +} +.gui-settings +{ + display: flex; + justify-content: center; + align-items: center; + cursor: pointer; + -webkit-tap-highlight-color: transparent; + transform: translateX(-12px); +} +.gui-settings, +.gui-settings-header .gui-settings-close path, +.gui-settings svg path +{ + transition: all 0.2s; +} +.gui-settings svg path +{ + fill: #8884; + opacity: 0.5; + transform-origin: center !important; +} +.gui-settings:hover +{ + transform: translateX(0px); +} +.gui-settings:hover svg path +{ + opacity: 1; + transform: rotate(120deg); +} +.gui-settings-panel +{ + width: 100%; + height: 100%; + background: transparent; + position: absolute; + left: 0; + top: 0; + z-index: 10000; + display: none; + align-items: center; + justify-content: center; +} +.gui-settings-box +{ + width: 400px; + height: 90%; + background: white; + border-radius: 8px; + box-shadow: 0px 3px 20px 2px #0004; + display: flex; + flex-direction: column; +} +.gui-settings-footer, +.gui-settings-header +{ + flex-grow: 0; + height: 50px; + display: flex; + align-items: center; +} +.gui-settings-footer +{ + height: 80px; + justify-content: center; +} +.gui-settings-content +{ + flex-grow: 1; + overflow: auto; +} +.gui-settings-content ul li +{ + font-size: 16px; + margin: 16px 0; + display: flex; +} +.gui-settings-content ul li.indent-0 +{ + margin-left: 16px; +} +.gui-settings-content ul li.indent-1 +{ + margin-left: 80px; +} +.gui-settings-content ul li.indent-2 +{ + margin-left: 144px; +} +.gui-settings-title +{ + flex-grow: 1; + font-size: 16px; + margin: 16px; +} +.gui-settings-close +{ + width: 24px; + height: 24px; + padding: 16px; +} +.gui-settings-header .gui-settings-close +{ + cursor: pointer; + -webkit-tap-highlight-color: transparent; +} +.gui-settings-header .gui-settings-close:hover path +{ + fill: $customStyleColor !important; +} +.gui-settings-close path +{ + fill: #222; +} +.gui-settings-ok path +{ + fill: transparent; +} +.gui-settings-textbox-container +{ + display: flex; + justify-content: center; + align-items: center; + -webkit-tap-highlight-color: transparent; +} +.gui-settings-textbox-container span +{ + margin: 0 16px; + transition: all 0.2s; +} +.gui-settings-textbox-container input +{ + border-radius: 4px; + border: none; + height: 100%; + max-width: 70px; + padding: 2px 8px; + background: #8884; + transition: all 0.2s; +} +.gui-settings-textbox-container input:disabled, +.gui-settings-textbox-container.disabled span +{ + opacity: 0.5; +} +.gui-settings-checkbox-container +{ + cursor: pointer; + display: flex; + justify-content: center; + align-items: center; + padding: 0 16px; + -webkit-tap-highlight-color: transparent; +} +.gui-settings-checkbox-container input +{ + opacity: 0; + width: 0; + transition: all 0.2s; +} +.gui-settings-checkbox-container svg +{ + width: 24px; + height: 24px; + border-radius: 4px; + margin-right: 16px; + transition: all 0.2s; +} +.gui-settings-checkbox-container svg path +{ + transform: scale(0.8); + transform-origin: center; +} +.gui-settings-checkbox-container input ~ svg +{ + background-color: #8884; +} +.gui-settings-checkbox-container input:checked ~ svg +{ + background-color: $customStyleColor; +} +.gui-settings-checkbox-container input:checked ~ svg path +{ + fill: $foreground; +} +.gui-settings-checkbox-container input:disabled ~ svg, +.gui-settings-checkbox-container input:disabled ~ span +{ + opacity: 0.5; +} +button.save +{ + padding: 8px 32px; + border: none; + background: $customStyleColor; + color: $foreground; + border-radius: 4px; + font-size: 16px; + /*box-shadow: 0px 1px 15px 1px $customStyleColor80;*/ + cursor: pointer; + transition: all 0.2s; + -webkit-tap-highlight-color: transparent; +} +button.save:hover +{ + /*box-shadow: 0px 3px 20px 3px $customStyleColor80;*/ + transform: translateY(-2px); +} +button.save:focus +{ + outline: none; +} +.gui-settings-footer svg +{ + width: 0; + height: 30px; + margin-left: 0; + transition: all 0.2s; +} +.gui-settings-footer svg path +{ + fill: $customStyleColor; +} diff --git a/style/style-touch-player.scss b/style/style-touch-player.scss index 5d21bc42e..20c04108f 100644 --- a/style/style-touch-player.scss +++ b/style/style-touch-player.scss @@ -74,7 +74,7 @@ } .videoshot { - display:none; + display: none; background-image: none; flex-grow: 0; @@ -93,7 +93,7 @@ div.bilibili-player-video-control .bilibili-player-video-btn { flex-grow: 1 !important; - height: 38px !important; + height: 100% !important; display: flex !important; align-items: center !important; justify-content: center !important; @@ -141,3 +141,97 @@ div.bilibili-player-video-control { left: unset !important; } +.bilibili-player-video-control-wrap +{ + padding: 0 !important; + background: #222d !important; +} +.bilibili-player-video-control-bottom +{ + align-items: center !important; +} +.bilibili-player-video-control-bottom-left +{ + display: flex; + align-items: center; +} +.bilibili-player-video-btn-danmaku +{ + flex-grow: 0 !important; + display: flex !important; + align-items: center !important; + height: 100% !important; + margin: 0 !important; + padding: 0 !important; +} +.bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-right +{ + flex-grow: 1 !important; +} +.bilibili-player.mode-fullscreen .bilibili-player-video-sendbar +{ + bottom: 0 !important; +} +.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-fullscreen +{ + margin-right: 0 !important; +} +.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn.bilibili-player-video-btn-start +{ + padding-left: 0 !important; + flex-grow: 1.2 !important; + margin-right: 4px !important; + margin-left: 0 !important; +} +.bilibili-player .bilibili-player-area .bilibili-player-video-control .bilibili-player-video-btn +{ + padding: 0 3px !important; +} +.bui-slider .bui-track.bui-track-video-progress .bui-bar-wrap +{ + background: #666; +} +.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom, +.bilibili-player-video-control-bottom-left, +.bilibili-player .bilibili-player-area .bilibili-player-video-control-bottom-right +{ + height: 100% !important; + margin: 0 !important; +} +.bilibili-player-video-btn-setting-panel-hover-bridge +{ + display: none !important; +} +@media screen and (min-width: 750px) +{ + .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar, + .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-center .bilibili-player-video-sendbar .bilibili-player-video-inputbar + { + background: #fff1 !important; + } + .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control, + .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control + { + height: 100% !important; + margin: 0 !important; + } + .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom, + .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom + { + margin: 0 !important; + } + .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left, + .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-bottom-left + { + height: 100% !important; + } + .bilibili-player-video-btn.bilibili-player-video-btn-start + { + flex-grow: 0.5 !important; + } + .bilibili-player.mode-fullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top, + .bilibili-player.mode-webfullscreen .bilibili-player-video-control-wrap .bilibili-player-video-control-top + { + bottom: 48px !important; + } +} diff --git a/touch/touch-navbar.js b/touch/touch-navbar.js index 365305dc2..9674e8c9e 100644 --- a/touch/touch-navbar.js +++ b/touch/touch-navbar.js @@ -7,14 +7,14 @@ it => it.length === 6, navItems => { - const navTouch = (_, nav) => + const enableTouch = (_, nav) => { const $nav = $(nav); $nav.css("cursor", "pointer"); const a = $nav.find("a.t"); a.removeAttr("href"); }; - navItems.each(navTouch); + navItems.each(enableTouch); } ); }; diff --git a/touch/touch-navbar.min.js b/touch/touch-navbar.min.js index b9a4b7f6e..bf4215a38 100644 --- a/touch/touch-navbar.min.js +++ b/touch/touch-navbar.min.js @@ -1 +1 @@ -(()=>()=>{waitForQuery()(()=>$("ul.fr>li.nav-item").not(".profile-info"),it=>6===it.length,navItems=>{const navTouch=(_,nav)=>{const $nav=$(nav);$nav.css("cursor","pointer");const a=$nav.find("a.t");a.removeAttr("href")};navItems.each(navTouch)})})(); \ No newline at end of file +(()=>()=>{waitForQuery()(()=>$("ul.fr>li.nav-item").not(".profile-info"),t=>6===t.length,t=>{const o=(t,o)=>{const r=$(o);r.css("cursor","pointer");const e=r.find("a.t");e.removeAttr("href")};t.each(o)})})(); \ No newline at end of file diff --git a/touch/touch-player.min.js b/touch/touch-player.min.js index 51761ed2a..f424ab0ce 100644 --- a/touch/touch-player.min.js +++ b/touch/touch-player.min.js @@ -1 +1 @@ -(()=>(_,resources)=>{const getEventHandler=(element,event)=>element.data("events")[event][0].handler,getPosition=element=>{let x=0,y=0;for(;element&&!isNaN(element.offsetLeft)&&!isNaN(element.offsetTop);)x+=element.offsetLeft-element.scrollLeft,y+=element.offsetTop-element.scrollTop,element=element.offsetParent;return{x:x,y:y}};class Swiper{constructor(element){this.action=new SwipeAction(element),this.onTouchStart=void 0,this.onTouchEnd=void 0,this._direction=null,element.addEventListener("touchstart",e=>{this._xDown=e.touches[0].clientX,this._yDown=e.touches[0].clientY,this.onTouchStart&&this.onTouchStart(e)}),element.addEventListener("touchmove",e=>{if(!this._xDown||!this._yDown)return;const xUp=e.touches[0].clientX,yUp=e.touches[0].clientY,elementPosition=getPosition(element),position={x:(e.touches[0].pageX-elementPosition.x)/element.clientWidth,y:(e.touches[0].pageY-elementPosition.y)/element.clientHeight,width:element.clientWidth,height:element.clientHeight},xDiff=this._xDown-xUp,yDiff=this._yDown-yUp;if(this._direction)"vertical"===this._direction?this.action.startAction(this._direction,yDiff,position):"horizontal"===this._direction&&this.action.startAction(this._direction,-xDiff,position),e.preventDefault();else{let direction="";direction=Math.abs(xDiff)>Math.abs(yDiff)?"horizontal":"vertical",this._direction=direction,e.preventDefault()}}),element.addEventListener("touchend",e=>{this._xDown=null,this._yDown=null,this._direction=null,this.onTouchEnd&&this.onTouchEnd(e)})}}class SwipeAction{constructor(element){this.lowSpeedForward=void 0,this.lowSpeedBackward=void 0,this.mediumSpeedForward=void 0,this.mediumSpeedBackward=void 0,this.highSpeedForward=void 0,this.highSpeedBackward=void 0,this.lowVolumeUp=void 0,this.lowVolumeDown=void 0,this.mediumVolumeUp=void 0,this.mediumVolumeDown=void 0,this.highVolumeUp=void 0,this.highVolumeDown=void 0,this.speedCancel=void 0,this.volumeCancel=void 0,this.minSwipeDistance=20,this.onActionStart=void 0,this.onActionEnd=void 0,this._element=element,this._touchStart=!1,this._startPosition=null,this._lastAction=null,element.addEventListener("touchstart",()=>{this._touchStart=!0}),element.addEventListener("touchend",()=>{this._startPosition=null,this.onActionEnd&&this.onActionEnd(this._lastAction),this._lastAction=null})}startAction(direction,distance,position){if(this._touchStart&&(this.onActionStart&&this.onActionStart(),this._startPosition=position,this._touchStart=!1),"vertical"===direction)if(Math.abs(distance)=1/3&&this._startPosition.x<=2/3?(volumeFactor=1,upHandler=this.mediumVolumeUp,downHandler=this.mediumVolumeDown):(volumeFactor=2,upHandler=this.highVolumeUp,downHandler=this.highVolumeDown),distance>0){const volumeChange=Math.round(100*volumeFactor*(distance-this.minSwipeDistance)/(1.5*position.height));upHandler&&upHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}else{const volumeChange=Math.round(100*volumeFactor*(distance+this.minSwipeDistance)/(1.5*position.height));downHandler&&downHandler(volumeChange),this._lastAction={type:"volume",volume:volumeChange}}}else if("horizontal"===direction)if(position.y<1/3&&(position.x<.1||position.x>.9)||Math.abs(distance)=1/3&&this._startPosition.y<=2/3?(speedFactor=.2,forwardHandler=this.mediumSpeedForward,backwardHandler=this.mediumSpeedBackward):(speedFactor=1,forwardHandler=this.highSpeedForward,backwardHandler=this.highSpeedBackward),distance>0){const seconds=(distance-this.minSwipeDistance)*speedFactor;forwardHandler&&forwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}else{const seconds=(distance+this.minSwipeDistance)*speedFactor;backwardHandler&&backwardHandler(seconds),this._lastAction={type:"playback",seconds:seconds}}}}}if(waitForQuery()(()=>$(".bilibili-player-video-web-fullscreen"),it=>it.length>0,fullscreenButton=>{if(!fullscreenButton.hasClass("bilibili-player-video-btn")&&$(".bilibili-player-video-btn-fullscreen").data("events")){const clickHandler=getEventHandler($(".bilibili-player-video-btn-fullscreen"),"click");fullscreenButton.detach().insertAfter(".bilibili-player-video-btn-widescreen").addClass("bilibili-player-video-btn").on("click",clickHandler)}}),waitForQuery()(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),it=>it.length>0,icons=>icons.unbind("click")),waitForQuery()(()=>$(".bilibili-player-video"),it=>it.length>0&&$("video").length>0,player=>{if(0===$(".touch-video-box").length){$(".bilibili-player-video-subtitle").before("
\n
\n
\n
\n
");const swiper=new Swiper(player.get(0)),text=document.getElementsByClassName("touch-video-info")[0],box=document.getElementsByClassName("touch-video-box")[0];swiper.action.speedCancel=(()=>{text.innerHTML="松开手指,取消进退"}),swiper.action.volumeCancel=(()=>{text.innerHTML="松开手指,取消调整"}),swiper.action.onActionStart=(()=>{box.style.display="flex",text.innerHTML=""});const fixed=(number,precision=1)=>{const str=number.toString(),index=str.indexOf(".");return-1!==index?str.length-index>precision+1?str.substring(0,index+precision+1):str:str+".0"},secondsToTime=sec=>{sec=Math.abs(sec);const hours=Math.floor(sec/3600),minutes=Math.floor((sec-3600*hours)/60),seconds=sec-3600*hours-60*minutes;let result=fixed(seconds)+"秒";return minutes>0&&(result=minutes+"分"+result),hours>0&&(result=hours+"小时"+result),result},secondsToHms=sec=>{sec=Math.abs(sec);const hours=Math.floor(sec/3600),minutes=Math.floor((sec-3600*hours)/60),seconds=sec-3600*hours-60*minutes;let result=(seconds<10?"0":"")+fixed(seconds);return result=(hours<10?"0":"")+hours+":"+(result=(minutes<10?"0":"")+minutes+":"+result)},video=$("video"),videoDuration=video.prop("duration"),speedChange=speed=>sec=>{const current=video.prop("currentTime");let info=`
${speed}速进度: ${sec>0?"+":"-"}`;const commonInfoPart="
",finalTime=current+sec;info+=finalTime>videoDuration?`${secondsToTime(videoDuration-current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(videoDuration)} (100%)`:finalTime<0?`${secondsToTime(current)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(0)} (0%)`:`${secondsToTime(sec)}${commonInfoPart}${secondsToHms(current)} → ${secondsToHms(finalTime)} (${fixed(100*finalTime/videoDuration)}%)`,text.innerHTML=info+"
"};swiper.action.lowSpeedBackward=speedChange("低"),swiper.action.lowSpeedForward=speedChange("低"),swiper.action.mediumSpeedBackward=speedChange("中"),swiper.action.mediumSpeedForward=speedChange("中"),swiper.action.highSpeedBackward=speedChange("高"),swiper.action.highSpeedForward=speedChange("高");const volumeChange=speed=>volume=>{const current=Math.round(100*video.prop("volume"));let info=`
${speed}速音量: ${volume>0?"+":"-"}`;const commonInfoPart="
",finalVolume=current+volume;info+=finalVolume>100?`${100-current}${commonInfoPart}${current} → 100`:finalVolume<0?`${current}${commonInfoPart}${current} → 0`:`${Math.abs(volume)}${commonInfoPart}${current} → ${finalVolume}`,text.innerHTML=info+"
"};swiper.action.lowVolumeUp=volumeChange("低"),swiper.action.lowVolumeDown=volumeChange("低"),swiper.action.mediumVolumeUp=volumeChange("中"),swiper.action.mediumVolumeDown=volumeChange("中"),swiper.action.highVolumeUp=volumeChange("高"),swiper.action.highVolumeDown=volumeChange("高"),swiper.action.onActionEnd=(action=>{if(box.style.display="none",text.innerHTML="",action)if("volume"===action.type){let volume=video.prop("volume");(volume+=action.volume/100)<0?volume=0:volume>1&&(volume=1),video.prop("volume",volume),$(".bilibili-player-video-volume-num").text(Math.round(100*volume)),$(".bpui-slider-progress").css("height",100*volume+"%"),$(".bpui-slider-handle").css("bottom",(35+230*volume)/3+"%"),0===volume?($(".icon-24soundoff").show(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").hide()):volume>=.5?($(".icon-24soundoff").hide(),$(".icon-24soundlarge").show(),$(".icon-24soundsmall").hide()):($(".icon-24soundoff").hide(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").show())}else if("playback"===action.type){let time=video.prop("currentTime");(time+=action.seconds)<0?time=0:time>videoDuration&&(time=videoDuration),video.prop("currentTime",time)}})}}),0===$("#bilibili-touch-video-player").length){const style=resources.getStyle("touchPlayerStyle","bilibili-touch-video-player");$("body").after(style)}})(); \ No newline at end of file +(()=>(i,t)=>{const o=(i,t)=>i.data("events")[t][0].handler,e=i=>{let t=0,o=0;for(;i&&!isNaN(i.offsetLeft)&&!isNaN(i.offsetTop);)t+=i.offsetLeft-i.scrollLeft,o+=i.offsetTop-i.scrollTop,i=i.offsetParent;return{x:t,y:o}};class s{constructor(i){this.action=new n(i),this.onTouchStart=void 0,this.onTouchEnd=void 0,this._direction=null,i.addEventListener("touchstart",i=>{this._xDown=i.touches[0].clientX,this._yDown=i.touches[0].clientY,this.onTouchStart&&this.onTouchStart(i)}),i.addEventListener("touchmove",t=>{if(!this._xDown||!this._yDown)return;const o=t.touches[0].clientX,s=t.touches[0].clientY,n=e(i),l={x:(t.touches[0].pageX-n.x)/i.clientWidth,y:(t.touches[0].pageY-n.y)/i.clientHeight,width:i.clientWidth,height:i.clientHeight},a=this._xDown-o,h=this._yDown-s;if(this._direction)"vertical"===this._direction?this.action.startAction(this._direction,h,l):"horizontal"===this._direction&&this.action.startAction(this._direction,-a,l),t.preventDefault();else{let i="";i=Math.abs(a)>Math.abs(h)?"horizontal":"vertical",this._direction=i,t.preventDefault()}}),i.addEventListener("touchend",i=>{this._xDown=null,this._yDown=null,this._direction=null,this.onTouchEnd&&this.onTouchEnd(i)})}}class n{constructor(i){this.lowSpeedForward=void 0,this.lowSpeedBackward=void 0,this.mediumSpeedForward=void 0,this.mediumSpeedBackward=void 0,this.highSpeedForward=void 0,this.highSpeedBackward=void 0,this.lowVolumeUp=void 0,this.lowVolumeDown=void 0,this.mediumVolumeUp=void 0,this.mediumVolumeDown=void 0,this.highVolumeUp=void 0,this.highVolumeDown=void 0,this.speedCancel=void 0,this.volumeCancel=void 0,this.minSwipeDistance=20,this.onActionStart=void 0,this.onActionEnd=void 0,this._element=i,this._touchStart=!1,this._startPosition=null,this._lastAction=null,i.addEventListener("touchstart",()=>{this._touchStart=!0}),i.addEventListener("touchend",()=>{this._startPosition=null,this.onActionEnd&&this.onActionEnd(this._lastAction),this._lastAction=null})}startAction(i,t,o){if(this._touchStart&&(this.onActionStart&&this.onActionStart(),this._startPosition=o,this._touchStart=!1),"vertical"===i)if(Math.abs(t)=1/3&&this._startPosition.x<=2/3?(i=1,e=this.mediumVolumeUp,s=this.mediumVolumeDown):(i=2,e=this.highVolumeUp,s=this.highVolumeDown),t>0){const s=Math.round(100*i*(t-this.minSwipeDistance)/(1.5*o.height));e&&e(s),this._lastAction={type:"volume",volume:s}}else{const e=Math.round(100*i*(t+this.minSwipeDistance)/(1.5*o.height));s&&s(e),this._lastAction={type:"volume",volume:e}}}else if("horizontal"===i)if(o.y<1/3&&(o.x<.1||o.x>.9)||Math.abs(t)=1/3&&this._startPosition.y<=2/3?(i=.2,o=this.mediumSpeedForward,e=this.mediumSpeedBackward):(i=1,o=this.highSpeedForward,e=this.highSpeedBackward),t>0){const e=(t-this.minSwipeDistance)*i;o&&o(e),this._lastAction={type:"playback",seconds:e}}else{const o=(t+this.minSwipeDistance)*i;e&&e(o),this._lastAction={type:"playback",seconds:o}}}}}if(waitForQuery()(()=>$(".bilibili-player-video-web-fullscreen"),i=>i.length>0,i=>{if(!i.hasClass("bilibili-player-video-btn")&&$(".bilibili-player-video-btn-fullscreen").data("events")){const t=o($(".bilibili-player-video-btn-fullscreen"),"click");i.detach().insertAfter(".bilibili-player-video-btn-widescreen").addClass("bilibili-player-video-btn").on("click",t)}}),waitForQuery()(()=>$(".bilibili-player-iconfont,.bilibili-player-video-quality-menu"),i=>i.length>0,i=>i.unbind("click")),waitForQuery()(()=>$(".bilibili-player-video"),i=>i.length>0&&$("video").length>0,i=>{if(0===$(".touch-video-box").length){$(".bilibili-player-video-subtitle").before("
\n
\n
\n
\n
");const t=new s(i.get(0)),o=document.getElementsByClassName("touch-video-info")[0],e=document.getElementsByClassName("touch-video-box")[0];t.action.speedCancel=(()=>{o.innerHTML="松开手指,取消进退"}),t.action.volumeCancel=(()=>{o.innerHTML="松开手指,取消调整"}),t.action.onActionStart=(()=>{e.style.display="flex",o.innerHTML=""});const n=(i,t=1)=>{const o=i.toString(),e=o.indexOf(".");return-1!==e?o.length-e>t+1?o.substring(0,e+t+1):o:o+".0"},l=i=>{i=Math.abs(i);const t=Math.floor(i/3600),o=Math.floor((i-3600*t)/60),e=i-3600*t-60*o;let s=n(e)+"秒";return o>0&&(s=o+"分"+s),t>0&&(s=t+"小时"+s),s},a=i=>{i=Math.abs(i);const t=Math.floor(i/3600),o=Math.floor((i-3600*t)/60),e=i-3600*t-60*o;let s=(e<10?"0":"")+n(e);return s=(o<10?"0":"")+o+":"+s,s=(t<10?"0":"")+t+":"+s},h=$("video"),c=h.prop("duration"),d=i=>t=>{const e=h.prop("currentTime");let s=`
${i}速进度: ${t>0?"+":"-"}`;const d="
",r=e+t;s+=r>c?`${l(c-e)}${d}${a(e)} → ${a(c)} (100%)`:r<0?`${l(e)}${d}${a(e)} → ${a(0)} (0%)`:`${l(t)}${d}${a(e)} → ${a(r)} (${n(100*r/c)}%)`,o.innerHTML=s+"
"};t.action.lowSpeedBackward=d("低"),t.action.lowSpeedForward=d("低"),t.action.mediumSpeedBackward=d("中"),t.action.mediumSpeedForward=d("中"),t.action.highSpeedBackward=d("高"),t.action.highSpeedForward=d("高");const r=i=>t=>{const e=Math.round(100*h.prop("volume"));let s=`
${i}速音量: ${t>0?"+":"-"}`;const n="
",l=e+t;s+=l>100?`${100-e}${n}${e} → 100`:l<0?`${e}${n}${e} → 0`:`${Math.abs(t)}${n}${e} → ${l}`,o.innerHTML=s+"
"};t.action.lowVolumeUp=r("低"),t.action.lowVolumeDown=r("低"),t.action.mediumVolumeUp=r("中"),t.action.mediumVolumeDown=r("中"),t.action.highVolumeUp=r("高"),t.action.highVolumeDown=r("高"),t.action.onActionEnd=(i=>{if(e.style.display="none",o.innerHTML="",i)if("volume"===i.type){let t=h.prop("volume");(t+=i.volume/100)<0?t=0:t>1&&(t=1),h.prop("volume",t),$(".bilibili-player-video-volume-num").text(Math.round(100*t)),$(".bpui-slider-progress").css("height",100*t+"%"),$(".bpui-slider-handle").css("bottom",(35+230*t)/3+"%"),0===t?($(".icon-24soundoff").show(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").hide()):t>=.5?($(".icon-24soundoff").hide(),$(".icon-24soundlarge").show(),$(".icon-24soundsmall").hide()):($(".icon-24soundoff").hide(),$(".icon-24soundlarge").hide(),$(".icon-24soundsmall").show())}else if("playback"===i.type){let t=h.prop("currentTime");(t+=i.seconds)<0?t=0:t>c&&(t=c),h.prop("currentTime",t)}})}}),0===$("#bilibili-touch-video-player").length){const i=t.getStyle("touchPlayerStyle","bilibili-touch-video-player");$("body").after(i)}})(); \ No newline at end of file diff --git a/utils/expand-danmaku.min.js b/utils/expand-danmaku.min.js index f442fda72..cdc05f2fe 100644 --- a/utils/expand-danmaku.min.js +++ b/utils/expand-danmaku.min.js @@ -1 +1 @@ -(()=>()=>{waitForQuery()(()=>$(".bui-collapse-header"),it=>it.length>0,button=>{0===parseInt($(".bui-collapse-body").css("height"))&&"展开"===$(".bui-collapse-arrow-text").text()&&button.click()})})(); \ No newline at end of file +(()=>()=>{waitForQuery()(()=>$(".bui-collapse-header"),e=>e.length>0,e=>{0===parseInt($(".bui-collapse-body").css("height"))&&"展开"===$(".bui-collapse-arrow-text").text()&&e.click()})})(); \ No newline at end of file diff --git a/utils/gui-settings.html b/utils/gui-settings.html new file mode 100644 index 000000000..ce2f8a971 --- /dev/null +++ b/utils/gui-settings.html @@ -0,0 +1,115 @@ +
+
+
+ 设置 + + + +
+
+
    +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
  • + +
  • +
+
+ +
+
diff --git a/utils/gui-settings.js b/utils/gui-settings.js index e69de29bb..8dfd4975f 100644 --- a/utils/gui-settings.js +++ b/utils/gui-settings.js @@ -0,0 +1,97 @@ +(() => +{ + return (settings, resources) => + { + const svgData = { + settings: "M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z", + close: "M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z", + ok: "M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z" + }; + waitForQuery()( + () => $("body"), + it => it.length > 0, + it => + { + if ($(".gui-settings").length === 0) + { + it.append(`
+ + + +
`); + $(".gui-settings").on("click", () => + { + $(".gui-settings-panel").css("display", "flex"); + }); + } + const style = resources.getStyle("guiSettingsStyle", "gui-settings-style"); + $("body").after(style); + const settingsBox = resources.data.guiSettingsDom; + if (settingsBox) + { + $("body").append(settingsBox); + $(".gui-settings-header .gui-settings-close").on("click", () => + { + $(".gui-settings-panel").css("display", "none"); + }); + $("button.save").on("click", () => + { + $("input[type='checkbox'][key]").each((_, element) => + { + settings[$(element).attr("key")] = $(element).prop("checked"); + }); + saveSettings(); + const svg = $(".gui-settings-footer svg.gui-settings-ok"); + if (parseInt(svg.css("width")) === 0) + { + svg.css({ + width: "30px", + marginLeft: "3rem" + }); + setTimeout(() => + { + svg.css({ + width: "0", + marginLeft: "0" + }); + }, 3000); + } + }); + + $(".gui-settings-close path").attr("d", svgData.close); + $(".gui-settings-ok path").attr("d", svgData.ok); + $(".gui-settings svg path").attr("d", svgData.settings); + + const dependencies = {}; + for (const key in settings) + { + $(`input[type='checkbox'][key='${key}']`).prop("checked", settings[key]); + $(`input[dependencies]`).each((_, element) => + { + dependencies[$(element).attr("key")] = $(element).attr("dependencies"); + }); + $(`input[type='checkbox']`).on("change", e => + { + const self = $(e.srcElement); + const checked = self.prop("checked"); + for (const key in dependencies) + { + const dependency = dependencies[key].split(" "); + if (dependency.indexOf(self.attr("key")) !== -1) + { + let value = true; + if (checked && dependency.every(k => $(`input[key='${k}']`).prop("checked"))) + { + value = false; + } + $(`input[key='${key}']`).prop("disabled", value); + } + + } + }); + } + } + } + ); + }; +})(); diff --git a/utils/gui-settings.min.js b/utils/gui-settings.min.js new file mode 100644 index 000000000..c43a7a323 --- /dev/null +++ b/utils/gui-settings.min.js @@ -0,0 +1 @@ +(()=>(t,e)=>{const s="M12,15.5A3.5,3.5 0 0,1 8.5,12A3.5,3.5 0 0,1 12,8.5A3.5,3.5 0 0,1 15.5,12A3.5,3.5 0 0,1 12,15.5M19.43,12.97C19.47,12.65 19.5,12.33 19.5,12C19.5,11.67 19.47,11.34 19.43,11L21.54,9.37C21.73,9.22 21.78,8.95 21.66,8.73L19.66,5.27C19.54,5.05 19.27,4.96 19.05,5.05L16.56,6.05C16.04,5.66 15.5,5.32 14.87,5.07L14.5,2.42C14.46,2.18 14.25,2 14,2H10C9.75,2 9.54,2.18 9.5,2.42L9.13,5.07C8.5,5.32 7.96,5.66 7.44,6.05L4.95,5.05C4.73,4.96 4.46,5.05 4.34,5.27L2.34,8.73C2.21,8.95 2.27,9.22 2.46,9.37L4.57,11C4.53,11.34 4.5,11.67 4.5,12C4.5,12.33 4.53,12.65 4.57,12.97L2.46,14.63C2.27,14.78 2.21,15.05 2.34,15.27L4.34,18.73C4.46,18.95 4.73,19.03 4.95,18.95L7.44,17.94C7.96,18.34 8.5,18.68 9.13,18.93L9.5,21.58C9.54,21.82 9.75,22 10,22H14C14.25,22 14.46,21.82 14.5,21.58L14.87,18.93C15.5,18.67 16.04,18.34 16.56,17.94L19.05,18.95C19.27,19.03 19.54,18.95 19.66,18.73L21.66,15.27C21.78,15.05 21.73,14.78 21.54,14.63L19.43,12.97Z",i="M19,6.41L17.59,5L12,10.59L6.41,5L5,6.41L10.59,12L5,17.59L6.41,19L12,13.41L17.59,19L19,17.59L13.41,12L19,6.41Z",n="M21,7L9,19L3.5,13.5L4.91,12.09L9,16.17L19.59,5.59L21,7Z";waitForQuery()(()=>$("body"),t=>t.length>0,c=>{0===$(".gui-settings").length&&(c.append("
\n \n \n \n
"),$(".gui-settings").on("click",()=>{$(".gui-settings-panel").css("display","flex")}));const g=e.getStyle("guiSettingsStyle","gui-settings-style");$("body").after(g);const o=e.data.guiSettingsDom;if(o){$("body").append(o),$(".gui-settings-header .gui-settings-close").on("click",()=>{$(".gui-settings-panel").css("display","none")}),$("button.save").on("click",()=>{$("input[type='checkbox'][key]").each((e,s)=>{t[$(s).attr("key")]=$(s).prop("checked")}),saveSettings();const e=$(".gui-settings-footer svg.gui-settings-ok");0===parseInt(e.css("width"))&&(e.css({width:"30px",marginLeft:"3rem"}),setTimeout(()=>{e.css({width:"0",marginLeft:"0"})},3e3))}),$(".gui-settings-close path").attr("d",i),$(".gui-settings-ok path").attr("d",n),$(".gui-settings svg path").attr("d",s);const e={};for(const s in t)$(`input[type='checkbox'][key='${s}']`).prop("checked",t[s]),$("input[dependencies]").each((t,s)=>{e[$(s).attr("key")]=$(s).attr("dependencies")}),$("input[type='checkbox']").on("change",t=>{const s=$(t.srcElement),i=s.prop("checked");for(const t in e){const n=e[t].split(" ");if(-1!==n.indexOf(s.attr("key"))){let e=!0;i&&n.every(t=>$(`input[key='${t}']`).prop("checked"))&&(e=!1),$(`input[key='${t}']`).prop("disabled",e)}}})}})})(); \ No newline at end of file diff --git a/utils/remove-promotions.min.js b/utils/remove-promotions.min.js index 26289982e..7fab081a3 100644 --- a/utils/remove-promotions.min.js +++ b/utils/remove-promotions.min.js @@ -1 +1 @@ -(()=>()=>{waitForQuery()(()=>$("#slide_ad"),it=>it.length>0,it=>it.css("display","none")),waitForQuery()(()=>$("#home_popularize"),it=>it.length>0,it=>it.css("display","none")),waitForQuery()(()=>$(".gg-floor-module"),it=>it.length>0,it=>it.css("display","none"))})(); \ No newline at end of file +(()=>()=>{waitForQuery()(()=>$("#slide_ad"),e=>e.length>0,e=>e.css("display","none")),waitForQuery()(()=>$("#home_popularize"),e=>e.length>0,e=>e.css("display","none")),waitForQuery()(()=>$(".gg-floor-module"),e=>e.length>0,e=>e.css("display","none"))})(); \ No newline at end of file