web: Minor improvements to the extension player page

This commit is contained in:
Toad06 2023-05-16 15:12:26 +02:00 committed by relrelb
parent 8cd5414c5d
commit b9abc463d6
2 changed files with 13 additions and 3 deletions

View File

@ -1952,13 +1952,22 @@ export class RufflePlayer extends HTMLElement {
this.isExtension && this.isExtension &&
window.location.origin !== this.swfUrl!.origin window.location.origin !== this.swfUrl!.origin
) { ) {
const url = new URL(this.swfUrl!);
if (this.loadedConfig?.parameters) {
const parameters = sanitizeParameters(
this.loadedConfig.parameters
);
Object.entries(parameters).forEach(([key, value]) => {
url.searchParams.set(key, value);
});
}
this.hideSplashScreen(); this.hideSplashScreen();
const div = document.createElement("div"); const div = document.createElement("div");
div.id = "message_overlay"; div.id = "message_overlay";
div.innerHTML = `<div class="message"> div.innerHTML = `<div class="message">
${textAsParagraphs("message-cant-embed")} ${textAsParagraphs("message-cant-embed")}
<div> <div>
<a target="_blank" href="${this.swfUrl}">${text( <a target="_blank" href="${url}">${text(
"open-in-new-tab" "open-in-new-tab"
)}</a> )}</a>
</div> </div>

View File

@ -29,9 +29,10 @@ window.addEventListener("DOMContentLoaded", async () => {
player.load({ player.load({
...options, ...options,
// Override default value for 'letterbox' when playing in the extension player page.
letterbox: "on" as Letterbox,
url: swfUrl, url: swfUrl,
base: swfUrl.substring(0, swfUrl.lastIndexOf("/") + 1), base: swfUrl.substring(0, swfUrl.lastIndexOf("/") + 1),
// Override some default values when playing in the extension player page.
letterbox: "on" as Letterbox,
forceScale: true,
}); });
}); });