ruffle-rs / ruffle

A Flash Player emulator written in Rust
https://ruffle.rs
Other
15.43k stars 799 forks source link

Extension should clean up after itself in the DOM #15862

Closed jeremyredhead closed 5 months ago

jeremyredhead commented 5 months ago

This is admittedly an esoteric request, but if possible could the Ruffle Addon remove the <script> elements it adds to the DOM after those scripts have ran?

The reason I request this is because I often use Ctrl+S to save web pages as "Web Page, Complete", which downloads to disk a snapshot of the page's DOM along with all linked resources in use. Including the two ruffle scripts (the inline one and the ruffle.js one). They take up a lot of disk space, and would probably interfere with Ruffle playback via the addon should any of the pages I download ever include flash content.

Alternatives I have considered


And btw, thank you all so much for creating Ruffle and keeping the dream of Flash alive. Viva La Flash!

danielhjacobs commented 5 months ago

Btw, this a tangent and your enhancement request is a good one, but I assume you use Firefox if you're talking about there being two script tags. injectScriptRaw, which adds the inline script tag, only runs on browsers without the scripting permission:

https://github.com/ruffle-rs/ruffle/blob/1bcc4d530a2440eca86f1d64db9106be8e8047fd/web/packages/extension/src/content.ts#L151-L155

That's just Firefox, and that code should be able to be removed after https://bugzilla.mozilla.org/show_bug.cgi?id=1736575 is fixed, as then we can add the scripting permission here: https://github.com/ruffle-rs/ruffle/blob/1bcc4d530a2440eca86f1d64db9106be8e8047fd/web/packages/extension/manifest_firefox.json5#L50

I only note this because once there is just a single script tag injected by Ruffle (the ruffle.js one) maybe it will become easier to make the extension clean that up.

This is what Chromium browsers do:

https://github.com/ruffle-rs/ruffle/blob/1bcc4d530a2440eca86f1d64db9106be8e8047fd/web/packages/extension/src/background.ts#L13-L29

Edit: Actually, removing this script tag is the easier part of this request, see #15958.