Skip to content

Instantly share code, notes, and snippets.

@johnou
Last active April 8, 2021 09:20
Show Gist options
  • Save johnou/da7bd6d1f1efd7c049191e7f928c4364 to your computer and use it in GitHub Desktop.
Save johnou/da7bd6d1f1efd7c049191e7f928c4364 to your computer and use it in GitHub Desktop.
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