mirror of
https://github.com/the1812/Bilibili-Evolved.git
synced 2025-11-04 21:22:45 +08:00
Fix bugs, make comments style reloadable
This commit is contained in:
parent
3e9b5071ca
commit
9ed32e0b7b
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
@ -171,13 +171,14 @@ function loadSettings()
|
||||
},
|
||||
set(newValue)
|
||||
{
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
|
||||
const handlers = settingsChangeHandlers[key];
|
||||
if (handlers)
|
||||
{
|
||||
handlers.forEach(h => h(newValue, value));
|
||||
}
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
const input = document.querySelector(`input[key=${key}]`);
|
||||
if (input !== null)
|
||||
{
|
||||
@ -455,6 +456,7 @@ function loadResources()
|
||||
playerShadow: "playerShadow",
|
||||
narrowDanmaku: "narrowDanmaku",
|
||||
compactLayout: "compactLayout",
|
||||
useCommentStyle: "useCommentStyle",
|
||||
};
|
||||
for (const [key, data] of Object.entries(Resource.manifest))
|
||||
{
|
||||
@ -1650,9 +1652,9 @@ Resource.manifest = {
|
||||
useCommentStyle: "简化评论区",
|
||||
},
|
||||
},
|
||||
commentDarkStyle: {
|
||||
path: "comment-dark.min.css"
|
||||
},
|
||||
// commentDarkStyle: {
|
||||
// path: "comment-dark.min.css"
|
||||
// },
|
||||
title: {
|
||||
path: "title.min.js"
|
||||
},
|
||||
@ -2048,15 +2050,14 @@ class ResourceManager
|
||||
const attributes = this.attributes[targetKey];
|
||||
if (attributes === undefined)
|
||||
{
|
||||
const fetchListener = newValue =>
|
||||
const fetchListener = async newValue =>
|
||||
{
|
||||
if (newValue === true)
|
||||
{
|
||||
this.fetchByKey(targetKey).then(() =>
|
||||
{
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
});
|
||||
await this.styleManager.fetchStyleByKey(targetKey);
|
||||
await this.fetchByKey(targetKey);
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
}
|
||||
};
|
||||
addSettingsListener(key, fetchListener);
|
||||
|
||||
@ -171,13 +171,14 @@ function loadSettings()
|
||||
},
|
||||
set(newValue)
|
||||
{
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
|
||||
const handlers = settingsChangeHandlers[key];
|
||||
if (handlers)
|
||||
{
|
||||
handlers.forEach(h => h(newValue, value));
|
||||
}
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
const input = document.querySelector(`input[key=${key}]`);
|
||||
if (input !== null)
|
||||
{
|
||||
@ -455,6 +456,7 @@ function loadResources()
|
||||
playerShadow: "playerShadow",
|
||||
narrowDanmaku: "narrowDanmaku",
|
||||
compactLayout: "compactLayout",
|
||||
useCommentStyle: "useCommentStyle",
|
||||
};
|
||||
for (const [key, data] of Object.entries(Resource.manifest))
|
||||
{
|
||||
@ -1650,9 +1652,9 @@ Resource.manifest = {
|
||||
useCommentStyle: "简化评论区",
|
||||
},
|
||||
},
|
||||
commentDarkStyle: {
|
||||
path: "comment-dark.min.css"
|
||||
},
|
||||
// commentDarkStyle: {
|
||||
// path: "comment-dark.min.css"
|
||||
// },
|
||||
title: {
|
||||
path: "title.min.js"
|
||||
},
|
||||
@ -2048,15 +2050,14 @@ class ResourceManager
|
||||
const attributes = this.attributes[targetKey];
|
||||
if (attributes === undefined)
|
||||
{
|
||||
const fetchListener = newValue =>
|
||||
const fetchListener = async newValue =>
|
||||
{
|
||||
if (newValue === true)
|
||||
{
|
||||
this.fetchByKey(targetKey).then(() =>
|
||||
{
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
});
|
||||
await this.styleManager.fetchStyleByKey(targetKey);
|
||||
await this.fetchByKey(targetKey);
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
}
|
||||
};
|
||||
addSettingsListener(key, fetchListener);
|
||||
|
||||
@ -10,6 +10,7 @@ export function loadResources()
|
||||
playerShadow: "playerShadow",
|
||||
narrowDanmaku: "narrowDanmaku",
|
||||
compactLayout: "compactLayout",
|
||||
useCommentStyle: "useCommentStyle",
|
||||
};
|
||||
for (const [key, data] of Object.entries(Resource.manifest))
|
||||
{
|
||||
|
||||
@ -203,15 +203,14 @@ export class ResourceManager
|
||||
const attributes = this.attributes[targetKey];
|
||||
if (attributes === undefined)
|
||||
{
|
||||
const fetchListener = newValue =>
|
||||
const fetchListener = async newValue =>
|
||||
{
|
||||
if (newValue === true)
|
||||
{
|
||||
this.fetchByKey(targetKey).then(() =>
|
||||
{
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
});
|
||||
await this.styleManager.fetchStyleByKey(targetKey);
|
||||
await this.fetchByKey(targetKey);
|
||||
removeSettingsListener(key, fetchListener);
|
||||
checkAttribute(key, this.attributes[targetKey]);
|
||||
}
|
||||
};
|
||||
addSettingsListener(key, fetchListener);
|
||||
|
||||
@ -462,9 +462,9 @@ Resource.manifest = {
|
||||
useCommentStyle: "简化评论区",
|
||||
},
|
||||
},
|
||||
commentDarkStyle: {
|
||||
path: "comment-dark.min.css"
|
||||
},
|
||||
// commentDarkStyle: {
|
||||
// path: "comment-dark.min.css"
|
||||
// },
|
||||
title: {
|
||||
path: "title.min.js"
|
||||
},
|
||||
|
||||
@ -146,13 +146,14 @@ export function loadSettings()
|
||||
},
|
||||
set(newValue)
|
||||
{
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
|
||||
const handlers = settingsChangeHandlers[key];
|
||||
if (handlers)
|
||||
{
|
||||
handlers.forEach(h => h(newValue, value));
|
||||
}
|
||||
value = newValue;
|
||||
GM_setValue(key, newValue);
|
||||
const input = document.querySelector(`input[key=${key}]`);
|
||||
if (input !== null)
|
||||
{
|
||||
|
||||
2
min/comment.min.js
vendored
2
min/comment.min.js
vendored
@ -1 +1 @@
|
||||
(()=>{return(r,e)=>{}})();
|
||||
(()=>{return(e,t)=>{t.applyImportantStyle("useCommentStyleStyle");return{reload:()=>t.applyImportantStyle("useCommentStyleStyle"),unload:()=>t.removeStyle("useCommentStyleStyle")}}})();
|
||||
2
min/custom-navbar.min.js
vendored
2
min/custom-navbar.min.js
vendored
File diff suppressed because one or more lines are too long
@ -0,0 +1,6 @@
|
||||
// Style key looks strange as it's a generated key
|
||||
resources.applyImportantStyle("useCommentStyleStyle");
|
||||
export default {
|
||||
reload: () => resources.applyImportantStyle("useCommentStyleStyle"),
|
||||
unload: () => resources.removeStyle("useCommentStyleStyle"),
|
||||
}
|
||||
@ -842,6 +842,7 @@ export default {
|
||||
<i class="mdi mdi-24px mdi-auto-fix"></i>
|
||||
<span>顶栏次序</span>
|
||||
</div>`,
|
||||
condition: () => false, // TODO: remove this line after complete
|
||||
success: async () =>
|
||||
{
|
||||
const settingsPanel = await SpinQuery.select(".custom-navbar-settings");
|
||||
@ -860,12 +861,20 @@ export default {
|
||||
},
|
||||
unload: () =>
|
||||
{
|
||||
document.querySelector(".custom-navbar").style.display = "none";
|
||||
const navbar = document.querySelector(".custom-navbar");
|
||||
if (navbar !== null)
|
||||
{
|
||||
navbar.style.display = "none";
|
||||
}
|
||||
resources.removeStyle("customNavbarStyle");
|
||||
},
|
||||
reload: () =>
|
||||
{
|
||||
document.querySelector(".custom-navbar").style.display = "flex";
|
||||
const navbar = document.querySelector(".custom-navbar");
|
||||
if (navbar !== null)
|
||||
{
|
||||
navbar.style.display = "flex";
|
||||
}
|
||||
resources.applyImportantStyle("customNavbarStyle");
|
||||
},
|
||||
};
|
||||
Loading…
Reference in New Issue
Block a user