Skip to content

Conversation

anthony-hyo
Copy link
Contributor

@anthony-hyo anthony-hyo commented Sep 23, 2025

Frontend / UI

  • Global settings section
  • Advanced settings section
  • Per-site rules modal with toggles
  • Review inputs & numbers & selects
  • Move inline JS (modal open/close & toggles) to options.js

Backend / Storage

  • Load per-site rules from storage (using utils.storage)
  • Save new/edited rules to storage
  • Apply per-site overrides when the player runs
  • Remove or edit site rules dynamically

Other

  • Validation for input fields (domains, numbers, colors)
  • Integration with actual player settings

Preview

Preview 1 Preview 2
Settings Per-site Rules Modal

@danielhjacobs
Copy link
Contributor

danielhjacobs commented Sep 23, 2025

I know it can be a little unclear, so in case you haven't pieced together the JS logic yet, working in reverse order, the final step for creating the config is here:

if (window.RufflePlayer === undefined) {
window.RufflePlayer = {};
}
if (window.RufflePlayer.config === undefined) {
window.RufflePlayer.config = {};
}
window.RufflePlayer.config = {
...message.config,
...window.RufflePlayer.config,
openInNewTab,
};

Before that, message.config is sent here:

await sendMessageToPage({
type: "load",
config: {
...explicitOptions,
autoplay: options.autostart ? "on" : "auto",
unmuteOverlay: options.autostart ? "hidden" : "visible",
splashScreen: !options.autostart,
},
publicPath: utils.runtime.getURL("/dist/"),
});

Explicit options uses this function:

* In the future we should just not store options we don't want to set.
*/
export async function getExplicitOptions(): Promise<Options> {
const options = await getOptions();
const defaultOptions = DEFAULT_OPTIONS;
for (const key in defaultOptions) {
// @ts-expect-error: Element implicitly has an any type
if (key in options && defaultOptions[key] === options[key]) {
// @ts-expect-error: Element implicitly has an any type
// eslint-disable-next-line @typescript-eslint/no-dynamic-delete
delete options[key];
}
}

And getOptions is here:

export async function getOptions(): Promise<Options> {
const options = await storage.sync.get();
// Copy over default options if they don't exist yet.
return { ...DEFAULT_OPTIONS, ...options };
}

The options are instantly set on change here:

element.input.addEventListener("change", () => {
const value = element.value;
options[key] = value as never;
utils.storage.sync.set({ [key]: value });
});

@Lord-McSweeney Lord-McSweeney added A-web Area: Web & Extensions T-feature Type: New Feature (that Flash doesn't have) labels Sep 24, 2025
@anthony-hyo anthony-hyo force-pushed the feat/per-site-options branch from 1a265bb to 7171b73 Compare October 2, 2025 05:54
@anthony-hyo
Copy link
Contributor Author

Some visual updates.

preview3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-web Area: Web & Extensions T-feature Type: New Feature (that Flash doesn't have)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants