Greasy Fork is available in English.

Kongregate Flash games fixer

You can now chose between Flash, SuperNova, Ruffle and AwayFL to play Flash games on Kongregate!

< Spätná väzba na Kongregate Flash games fixer

Hodnotenie: Dobré - skript funguje

§
Pridaný: 22.03.2023

Thanks for this useful tool! Recently I noticed that Kongregate is passing flashvars to Ruffle incorrectly; see my comment here: https://github.com/ruffle-rs/ruffle/issues/9573#issuecomment-1477341626

Here is a patch for your script to make it decode flashvars before passing them to Ruffle. This makes games like HitBox that use the Kongregate API work correctly in Ruffle.

@@ -254,6 +254,7 @@ function activateGame4348(swf_player){
         // For CORS-related reasons, the base must be changed to a konggames.com base.
         window.RufflePlayer.config.base=prot+"://game"+swfobject_flash_vars.kongregate_game_id+".konggames`+file_url_base.substring(file_url_base.indexOf(".com"),file_url_base.length)+`";

+        var ruffle_flash_vars={}; for(var k in swfobject_flash_vars){ ruffle_flash_vars[k] = decodeURIComponent(swfobject_flash_vars[k]); };
         const ruffle = window.RufflePlayer.newest();
         const player = ruffle.createPlayer();
         player.style.width = "100%";
@@ -263,7 +264,7 @@ function activateGame4348(swf_player){
         container.appendChild(player);
         player.load({
             url: Ruffle_swf_location,
-            parameters: swfobject_flash_vars,
+            parameters: ruffle_flash_vars,
             allowScriptAccess: true
         });
     }
Matrix4348Autor
§
Pridaný: 22.03.2023

Hello nosamu!

I am so glad that a Ruffle developer found this, because the various changes in the Kongregate staff and Flash games pages (including flashvars disappearing or being given the wrong values) made me fear that the Kongregate API would not be able to work as before in Ruffle (high scores submission, premium content...). Especially the AVM1 API, with that game shell thing... Happy to know that the correct values will be able to be used for testing.

I actually read this comment yesterday and was surprised. The encoded values were what had always been parsed to Adobe Flash Player to make everything work. should not Ruffle behave the same way? Why would it only accept decoded/non-encoded variables?
Anyway, I will update my script later today. Thank you, I had not realized that the non-encoded values had a positive output.

By the way, if you ever need some tweaks for further testing, or even a specific version, feel free to ask me.

Matrix4348Autor
§
Pridaný: 22.03.2023

Fix released!

§
Pridaný: 23.03.2023

made me fear that the Kongregate API would not be able to work as before in Ruffle

Well, I think there's some advanced interactions between the Kong API and the page JS that Ruffle may not be able to support, but more basic functionality is there at least.

The encoded values were what had always been parsed to Adobe Flash Player to make everything work. should not Ruffle behave the same way? Why would it only accept decoded/non-encoded variables?

Ruffle's polyfill script correctly detects encoded flashvars, but users of Ruffle's JavaScript API are expected to conform to its standards. I guess the Ruffle developers who designed the API thought it made more sense to make it accept non-encoded flashvars. Those are the original values after all, so theoretically it's wasteful to make users encode the values just for Ruffle to decode them again.

Fix released!

Great, thanks! Can confirm that it works.

Matrix4348Autor
§
Pridaný: 23.03.2023

Ruffle's polyfill script correctly detects encoded flashvars, but users of Ruffle's JavaScript API are expected to conform to its standards. I guess the Ruffle developers who designed the API thought it made more sense to make it accept non-encoded flashvars. Those are the original values after all, so theoretically it's wasteful to make users encode the values just for Ruffle to decode them again.

Aaah, okay. It makes sense.

§
Pridaný: 23.03.2023

By the way, if you ever need some tweaks for further testing, or even a specific version, feel free to ask me.

I appreciate it! It would actually be really useful for me to have a way to set the default player that loads on the game page without needing to edit the script's code. Right now the logic seems to be 'Flash Player if supported, otherwise SuperNova if on Windows, otherwise Ruffle'. As a Ruffle developer, I'd like to set it to Ruffle all the time. I already edited the code on my end, but I think you could add a preference for it with something like GM.getValue, though I'm not sure if that's the most cross-compatible way.

Matrix4348Autor
§
Pridaný: 23.03.2023

Hmm... I would like to avoid adding extra permissions. What would you think about a second user script, a sort of add-on to the main one? This would actually be a lot easier to make, and I could even modify the buttons specifically for you: removing the superNova one for example (do you even need it?), and even adding a button that makes Ruffle load AVM1 games load inside their game shell (which is needed for the AVM1 Kongregate API to work, but is not possible yet so you might want to be able to test it more easily).

§
Pridaný: 23.03.2023

I've never looked into the AVM1 API. This could be something to consider for the future if we try to get that working - I'll remember to ask you about it then. For now I guess I'm fine with editing the script after each update, it's not a big deal.

Matrix4348Autor
§
Pridaný: 23.03.2023

Well, here is the add-on script: https://greasyfork.org/en/scripts/462430-kongregate-flash-games-fixer-add-on-ruffle-oriented
You will no longer need to modify the main one's code, which could have prevented you from getting automatic updates. All it does for now is changing the default swf player to Ruffle, but I will add more if you ever need it - just tell me!

§
Pridaný: 24.03.2023

Got it, thanks!

§
Pridaný: 28.03.2023
Upravený: 28.03.2023

I just noticed that your script is breaking Ruffle's SWF download functionality ("Download .swf" in the context menu). This is happening because the script is changing the SWF URL to use HTTP instead of HTTPS. Is there a particular reason to do that? Changing var prot="http"; to var prot="https"; fixes the problem.

Matrix4348Autor
§
Pridaný: 28.03.2023

Argh! Yes, I default most games to http because when Kongregate switched to https in... 2017 (?), they identified somes games that would break on https and kept them on http, but did not identify ALL of those games. Considering that there is no cross-origin problem with Ruffle when using different protocols, I figured that this would be harmless.
Is there any way to modify the download URL without modifying the played swf? If there is not, then I will make files load from the page protocol.

§
Pridaný: 14.02.2024

What is missing or different at Ruffle side to send high scores like Flash Player?

Matrix4348Autor
§
Pridaný: 14.02.2024

From what I understood, Kongregate is using some kind of exploit in Flash Player's code to send them. They are not the only ones to use it though, and apparently it was not that uncommon back in the day. For security reasons, Ruffle is not reproducing this behaviour. Therefore, unless they change their mind Kongregate will have to modify a few lines of codes on their end (which would be a terrible thing to do, considering the current incompetency of their engineers).
Another thing to note is that a good part of older Flash games on Kongregate (a third?) would not send high scores even if this was fixed because there is an issue with how Ruffle handles... some things. That should be fixed someday but I do not know when. I wish I could work on the project, eh.

Here was my little understanding of the situation but I am not a computer wizard nor a Ruffle developer so there could be some mistakes.

Pridať odpoveď

Aby ste mohli pridať odpoveď, prihláste sa.