Unknown
diff --git a/src/ext/lib/settings/SiteSettings.ts b/src/ext/lib/settings/SiteSettings.ts
index f596f7d..e76b1f3 100644
--- a/src/ext/lib/settings/SiteSettings.ts
+++ b/src/ext/lib/settings/SiteSettings.ts
@@ -307,10 +307,18 @@ export class SiteSettings {
* @param optionValue new value of option
* @param reload whether we should trigger a reload in components that require it
*/
- async set(optionPath: string, optionValue: any, options: {reload?: boolean, noSave?: boolean} = {reload: false}) {
- // if no settings exist for this site, create an empty object
- if (!this.settings.active.sites[this.site]) {
- this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@empty']);
+ async set(optionPath: string, optionValue: any, options: {reload?: boolean, noSave?: boolean, scripted?: boolean} = {reload: false}) {
+ // if no settings exist for this site, create an empty object.
+ // If this function is not being called in response to user actin,
+ // create fake settings object.
+ if (options.scripted && !this.settings.active.sites[this.site]) {
+ this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@global']);
+ this.settings.active.sites[this.site].autocreated = true;
+ this.settings.active.sites[this.site].type = 'unknown';
+ } else {
+ if (!this.settings.active.sites[this.site] || this.settings.active.sites[this.site].autocreated) {
+ this.settings.active.sites[this.site] = _cp(this.settings.active.sites['@empty']);
+ }
}
const pathParts = optionPath.split('.');
diff --git a/src/ext/lib/video-data/PlayerData.ts b/src/ext/lib/video-data/PlayerData.ts
index 84dbc06..85d63b6 100644
--- a/src/ext/lib/video-data/PlayerData.ts
+++ b/src/ext/lib/video-data/PlayerData.ts
@@ -718,7 +718,7 @@ class PlayerData {
} else {
bestCandidate.heuristics['autoMatch'] = true;
if (this.siteSettings.data.playerAutoConfig?.initialIndex !== bestCandidate.index) {
- this.siteSettings.set('playerAutoConfig.initialIndex', bestCandidate.index, {reload: false});
+ this.siteSettings.set('playerAutoConfig.initialIndex', bestCandidate.index, {reload: false, scripted: true});
}
}