Last active
April 8, 2021 09:20
-
-
Save johnou/da7bd6d1f1efd7c049191e7f928c4364 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package { | |
import flash.display.Sprite; | |
import flash.events.LocationChangeEvent; | |
import flash.geom.Rectangle; | |
import flash.media.StageWebView; | |
public class Main extends Sprite { | |
private static const CAPTCHA_ENDPOINT : String = "https://www.habbo" + ".com/api/public/captcha"; | |
//private static const CAPTCHA_ENDPOINT : String = "https://www.google.com"; | |
private static const TOKEN_KEY : String = "token="; | |
public function Main() { | |
var webView : StageWebView = new StageWebView(true, false); // also fails with false | |
// [trace] SyntaxError: Parse error | |
// [trace] https://www.gstatic.com/recaptcha/releases/bfvuz6tShG5aoZp4K4zPVf5t/recaptcha__en.js : 14 | |
webView.stage = this.stage; | |
webView.viewPort = new Rectangle(0, 0, 500, 500); | |
webView.loadURL(CAPTCHA_ENDPOINT); | |
webView.addEventListener(LocationChangeEvent.LOCATION_CHANGE, onLocationChange); | |
} | |
private function onLocationChange(e:LocationChangeEvent):void { | |
var token : String = resolveToken(e.location); | |
if (token != null){ | |
//handleCaptchaResult(token); | |
} | |
} | |
private static function resolveToken(location:String):String { | |
var tokenIndex:int = location != null ? location.indexOf(TOKEN_KEY) : -1; | |
if (tokenIndex < 0) { | |
return null; | |
} | |
return location.substr(tokenIndex + TOKEN_KEY.length); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment