Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimize settings injection with MutationObserver#225

Open
TirOFlanc wants to merge 15 commits into
GooseMod:main from
TirOFlanc:main
Open

Optimize settings injection with MutationObserver #225
TirOFlanc wants to merge 15 commits into
GooseMod:main from
TirOFlanc:main

Conversation

@TirOFlanc

@TirOFlanc TirOFlanc commented Jan 31, 2026

Copy link
Copy Markdown

Changes :
Replaces setInterval(800 ms) with MutationObserver for parameter injection.

No reference to mods but avoids conflicts with them.

Uses Discord's native "text-xxs/normal_cf4812" class and native "color:var(text-muted)" inline style for consistent styling.

Clicks :
Menu item → Opens the OpenAsar window
Version information → Opens the official website https://openasar.dev/

Plus :
Using the ${{ github.repository }} variable in the workflow to allow forks to create releases.

@CanadaHonk CanadaHonk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the PR! Needs some changes before it can be merged.

Comment thread src/mainWindow.js
if (clickableDiv) {
const oaVersion = document.createElement('div');
oaVersion.id = 'openasar-ver';
oaVersion.className = 'text-xxs/normal_cf4812';

@CanadaHonk CanadaHonk Feb 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hard-coded class names break easily which is why we need to clone existing elements.

Comment thread src/mainWindow.js
};

const observer = new MutationObserver(() => injectOpenAsar());
observer.observe(document.body, { childList: true, subtree: true });

@CanadaHonk CanadaHonk Feb 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am pretty sure this will be slower than the interval because it will run on every body change which is much more frequent than 800ms

Comment thread src/mainWindow.js
// Inject menu item after Advanced
if (!document.getElementById('openasar-item')) {
let advanced = sidebar.querySelector('[data-list-item-id*="advanced"]')
|| sidebar.querySelector('[data-settings-sidebar-item="advanced_panel"]')?.querySelector('[class*="item"]')

@CanadaHonk CanadaHonk Feb 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Having these be || instead of ifs is overcomplicated and serves no benefit?

Comment thread src/mainWindow.js
|| sidebar.querySelector('[data-settings-sidebar-item="advanced_panel"]')?.querySelector('[class*="item"]')
|| (() => {
const sections = sidebar.querySelectorAll('[class*="section"]');
return sections[2]?.querySelectorAll('[class*="item"]')[sections[2]?.querySelectorAll('[class*="item"]').length - 1];

@CanadaHonk CanadaHonk Feb 24, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Don't duplicate querySelector calls, it could change between calls to cause a race condition and is also not great for performance

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Reviewers

@CanadaHonk CanadaHonk CanadaHonk requested changes

Assignees

No one assigned

Labels

None yet

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /