Add settings dock side

This commit is contained in:
the1812 2019-09-14 14:13:09 +08:00
parent e8c97726cf
commit ed799c5adb
14 changed files with 79 additions and 23 deletions

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -59,9 +59,9 @@
"full-page-title.min.js": "D761A0C4A8B0A25CC0A23A10C495C2A5E6028BC19C6460C8ABB8D4B0B855E748",
"full-tweets-title.min.css": "13A0CF1C96F374CED3FA59A532E28B4B620D7A4C374385A363F32AD1A7656764",
"full-tweets-title.min.js": "DD57BB732ABEF7739CA84AEFF97E86F8984FCC4A8A75B957213622350B2A7C37",
"gui-settings.min.css": "8D0BEF9A8125DD840172DCCC2FE87024EA5374368540260E71D6440214648B0A",
"gui-settings.min.html": "D80D1C36AD4B8166BB71ACA1CEF2E1044C8BFD4C6425A4C0FDD8ED92C72B5F41",
"gui-settings.min.js": "BE5C8F6D75F1AAF9DEBC1FA4D3F4CC3834F0EF647BDBECFC3C8A44E72CE177BF",
"gui-settings.min.css": "A21A378B3C813B2C74B3743D3794A98C0443D2595002F0219BF245FF21F294DC",
"gui-settings.min.html": "814EF4A1B6298256B4BDF362D079CA31322DBA8AC118C99E0AA0CD9CAABE11B8",
"gui-settings.min.js": "919485FA287E0A91D7CD778924C527219AB703A3042CE31D6C597047879EF107",
"haruna-scale.min.js": "7B0F89A664B6A3D0BE21F7501660058DE3DC0881A81FCDA44B9F3C31BBD73D30",
"hide-bangumi-reviews.min.js": "CC3CE6B3F1606F8AB0A4ADAD3B16E6DA9245D0676ACF74B97FB143FBFF0C7223",
"hide-banner.min.css": "FF157AF84741AF0564FE2930CC49F524F99A41739DB4C44DC944EC6F4F620A0F",

Binary file not shown.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@ -1 +1 @@
(()=>{return(e,t)=>{const{ThemeColors:n}=t.import("theme-colors");const{SettingsSearch:i}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let r=[];function a(e){let t=e.nextElementSibling;const n=[];while(t!==null&&!t.classList.contains("category")){n.push(t);t=t.nextElementSibling}return n}function l(){r.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function d(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});r.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");a(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function u(){c.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=t.checked;e[n]=i})});r.forEach(t=>{t.addEventListener("change",()=>{const n=t.getAttribute("key");const i=s.getValidator(n).validate(t.value);e[n]=i;t.value=i})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,n])=>{if(e[0]===undefined){return}const i=()=>{if(e.every(e=>e.checked)){t(n).classList.remove("disabled")}else{t(n).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",i));i()})}function p(){if(typeof offlineData!=="undefined"){}}function f(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false}}function b(){for(const[e,t]of Object.entries(Resource.displayNames)){const n=o.find(t=>t.getAttribute("key")===e);if(!n){continue}switch(n.type){case"checkbox":n.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=n.parentElement;if(e.classList.contains("gui-settings-textbox-container")){n.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");t.applyImportantStyle("iconsStyle");document.body.classList.add("round-corner");const e=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(e){document.querySelector(".gui-settings-icon-panel").style.display="none"}const s=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",s);const{style:a}=await t.importAsync("mdi");if(!a){document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">`)}const m=document.querySelector(".widgets-container");const y=m.querySelector(".empty-tip");Observer.childList(m,()=>{if(m.childElementCount<=1){y.classList.add("show")}else{y.classList.remove("show")}});const h=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");const E=document.querySelector(".gui-settings-icon-panel");E.addEventListener("mouseover",async()=>{const{loadTooltip:e}=await t.importAsync("settings-tooltip.loader");await e();await t.applyDropdownOptions();t.applyWidgets();raiseEvent(E,"be:load");raiseEvent(dq(".bilibili-evolved-about"),"be:about-load");(new n).setupDom();h.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");r=o.filter(e=>e.type==="text"&&!e.parentElement.classList.contains("gui-settings-dropdown"));d();p();l();g();u();f();b();new i},{once:true})})()}})();
(()=>{return(e,t)=>{const{ThemeColors:i}=t.import("theme-colors");const{SettingsSearch:n}=t.import("settings-search");const{Validator:s}=t.import("text-validate");let o=[];let c=[];let a=[];function r(e){let t=e.nextElementSibling;const i=[];while(t!==null&&!t.classList.contains("category")){i.push(t);t=t.nextElementSibling}return i}function l(){a.forEach(t=>t.value=e[t.getAttribute("key")]);c.forEach(t=>t.checked=e[t.getAttribute("key")])}function d(){document.querySelector(".gui-settings-mask").addEventListener("click",()=>{document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box,.gui-settings-mask,.bilibili-evolved-about").forEach(e=>e.classList.remove("opened"))});a.forEach(t=>{t.setAttribute("placeholder",e[t.getAttribute("key")])});document.querySelectorAll(".gui-settings-content ul li.category").forEach(e=>{e.addEventListener("click",e=>{const t=document.querySelector(".gui-settings-search");if(t.value!==""){t.value="";raiseEvent(t,"input")}e.currentTarget.classList.toggle("folded");r(e.currentTarget).forEach(e=>e.classList.toggle("folded"))})});document.querySelectorAll(".gui-settings-dropdown>input").forEach(e=>{e.addEventListener("click",e=>{e.currentTarget.parentElement.classList.toggle("opened")})})}function u(){c.forEach(t=>{t.addEventListener("change",()=>{const i=t.getAttribute("key");const n=t.checked;e[i]=n})});a.forEach(t=>{t.addEventListener("change",()=>{const i=t.getAttribute("key");const n=s.getValidator(i).validate(t.value);e[i]=n;t.value=n})})}function g(){const e=o.map(e=>[e.getAttribute("dependencies").split(" ").map(e=>o.find(t=>t.getAttribute("key")===e)),e]);const t=e=>e.nodeName.toUpperCase()==="LI"?e:t(e.parentElement);e.forEach(([e,i])=>{if(e[0]===undefined){return}const n=()=>{if(e.every(e=>e.checked)){t(i).classList.remove("disabled")}else{t(i).classList.add("disabled")}};e.forEach(e=>e.addEventListener("change",n));n()})}function f(){if(typeof offlineData!=="undefined"){}}function p(){if(!CSS.supports("backdrop-filter","blur(24px)")&&!CSS.supports("-webkit-backdrop-filter","blur(24px)")){o.find(e=>e.getAttribute("key")==="blurVideoControl").disabled=true;e.blurVideoControl=false}if(window.devicePixelRatio===1){o.find(e=>e.getAttribute("key")==="harunaScale").disabled=true;o.find(e=>e.getAttribute("key")==="imageResolution").disabled=true;e.harunaScale=false;e.imageResolution=false}}function b(){for(const[e,t]of Object.entries(Resource.displayNames)){const i=o.find(t=>t.getAttribute("key")===e);if(!i){continue}switch(i.type){case"checkbox":i.nextElementSibling.nextElementSibling.innerHTML=t;break;case"text":const e=i.parentElement;if(e.classList.contains("gui-settings-textbox-container")){i.previousElementSibling.innerHTML=t}else if(e.classList.contains("gui-settings-dropdown")){e.previousElementSibling.innerHTML=t}break;default:break}}}(async()=>{t.applyStyle("guiSettingsStyle");t.applyImportantStyle("iconsStyle");document.body.classList.add("round-corner");const s=document.body&&unsafeWindow.parent.window!==unsafeWindow;if(s){document.querySelector(".gui-settings-icon-panel").style.display="none"}if(e.guiSettingsDockSide==="右侧"){document.body.classList.add("gui-settings-dock-right")}const r=t.data.guiSettingsHtml.text;document.body.insertAdjacentHTML("beforeend",r);const{style:m}=await t.importAsync("mdi");if(!m){document.body.insertAdjacentHTML("afterbegin",`<link rel="stylesheet" href="//cdn.materialdesignicons.com/3.6.95/css/materialdesignicons.min.css">`)}const y=document.querySelector(".widgets-container");const h=y.querySelector(".empty-tip");Observer.childList(y,()=>{if(y.childElementCount<=1){h.classList.add("show")}else{h.classList.remove("show")}});const S=document.querySelectorAll(".gui-settings-widgets-box,.gui-settings-box");const E=document.querySelector(".gui-settings-icon-panel");E.addEventListener("mouseover",async()=>{const{loadTooltip:e}=await t.importAsync("settings-tooltip.loader");await e();await t.applyDropdownOptions();t.applyWidgets();raiseEvent(E,"be:load");raiseEvent(dq(".bilibili-evolved-about"),"be:about-load");(new i).setupDom();S.forEach(e=>e.classList.add("loaded"));o=[...document.querySelectorAll("input[key]")];c=o.filter(e=>e.type==="checkbox");a=o.filter(e=>e.type==="text"&&!e.parentElement.classList.contains("gui-settings-dropdown"));d();f();l();g();u();p();b();addSettingsListener("guiSettingsDockSide",e=>{document.body.classList[e==="右侧"?"add":"remove"]("gui-settings-dock-right")});new n},{once:true})})()}})();

View File

@ -94,7 +94,12 @@ Resource.manifest = {
sideBarOffset: '侧栏垂直偏移量',
ajaxHook: '启用 Ajax Hook API',
scriptLoadingMode: '加载模式',
}
guiSettingsDockSide: '设置面板停靠位置',
},
dropdown: {
key: 'guiSettingsDockSide',
items: ['左侧', '右侧']
},
},
useDarkStyle: {
path: 'dark-styles.min.js',

View File

@ -0,0 +1,23 @@
.gui-settings-dock-right {
.gui-settings-icon-panel {
right: 0;
left: unset;
.gui-settings,
.gui-settings-widgets {
transform: translateX(16px);
border-radius: 50% 0 0 50%;
&:hover {
transform: translateX(0);
}
}
}
.gui-settings-box,
.gui-settings-widgets-box {
right: 0;
left: unset;
transform: translateX(100%);
&.opened {
transform: translateX(0);
}
}
}

View File

@ -127,6 +127,7 @@
<textbox indent="0" key="sideBarOffset" dependencies=""></textbox>
<checkbox indent="0" key="ajaxHook" dependencies=""></checkbox>
<dropdown indent="0" key="scriptLoadingMode" dependencies=""></dropdown>
<dropdown indent="0" key="guiSettingsDockSide" dependencies=""></dropdown>
</ul>
</div>
<div class="gui-settings-tooltip"></div>

View File

@ -132,6 +132,9 @@ function setDisplayNames () {
// return;
}
if (settings.guiSettingsDockSide === '右侧') {
document.body.classList.add('gui-settings-dock-right')
}
const settingsBox = resources.data.guiSettingsHtml.text
document.body.insertAdjacentHTML('beforeend', settingsBox)
@ -171,6 +174,9 @@ function setDisplayNames () {
// foldAllCategories();
checkCompatibility()
setDisplayNames()
addSettingsListener('guiSettingsDockSide', value => {
document.body.classList[value === '右侧' ? 'add' : 'remove']('gui-settings-dock-right')
})
new SettingsSearch()
}, { once: true })
})()

View File

@ -627,3 +627,4 @@ body.round-corner {
border-radius: var(--corner-radius);
}
}
@import "_gui-settings-dock"