Skip to content

Commit

Permalink
feat: Add enabled plugin names to <html> element to make CSS styling …
Browse files Browse the repository at this point in the history
…easier. #258
  • Loading branch information
shdwmtr committed Mar 9, 2025
1 parent 1cb2619 commit 938bb82
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 2 deletions.
8 changes: 8 additions & 0 deletions assets/core/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,12 @@
def get_load_config():
config = cfg.get_config()

enabled_plugins = []

for plugin in json.loads(find_all_plugins()):
if plugin["enabled"]:
enabled_plugins.append(plugin["data"]["name"])

return json.dumps({
"accent_color": json.loads(Colors.get_accent_color(config["accentColor"])),
"conditions": config["conditions"] if "conditions" in config else None,
Expand All @@ -41,6 +47,8 @@ def get_load_config():

"wantsUpdates": MillenniumUpdater.user_wants_updates().value,
"wantsNotify": MillenniumUpdater.user_wants_update_notify().value,

"enabledPlugins": enabled_plugins
})


Expand Down
1 change: 1 addition & 0 deletions assets/src/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ const InitializePatcher = (startTime: number, result: SettingsProps) => {
version: result?.millenniumVersion,
wantsMillenniumUpdates: result?.wantsUpdates ?? true,
wantsMillenniumUpdateNotifications: result?.wantsNotify ?? true,
enabledPlugins: result?.enabledPlugins ?? []
});

PatchMissedDocuments();
Expand Down
7 changes: 6 additions & 1 deletion assets/src/patcher/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,17 @@ const getDocumentClassList = (context: any): string[] => {

function patchDocumentContext(windowContext: any)
{
const document: Document = windowContext.m_popup.document

for (const plugin of pluginSelf.enabledPlugins) {
document.documentElement.classList.add(plugin)
}

if (pluginSelf.isDefaultTheme) {
return
}

const activeTheme: ThemeItem = pluginSelf.activeTheme
const document: Document = windowContext.m_popup.document
const classList: string[] = getDocumentClassList(windowContext);
const documentTitle: string = windowContext.m_strTitle

Expand Down
3 changes: 2 additions & 1 deletion assets/src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,8 @@ export interface SettingsProps {
useInterface: boolean,
millenniumVersion: string,
wantsUpdates: boolean,
wantsNotify: boolean
wantsNotify: boolean,
enabledPlugins: string
}

export interface ColorProp {
Expand Down

0 comments on commit 938bb82

Please sign in to comment.