From 86c36aeea44b0836fc28dbadea71f3e05e873bc5 Mon Sep 17 00:00:00 2001 From: finn Date: Mon, 16 May 2022 15:41:06 -0700 Subject: [PATCH] Add support for registration tokens --- README.md | 10 +++++++++- signal-captcha-helper.vala | 19 ++++++++++++++----- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 3182ea8..4266b88 100644 --- a/README.md +++ b/README.md @@ -22,8 +22,16 @@ valac --pkg gtk+-3.0 --pkg webkit2gtk-4.0 signal-captcha-helper.vala The captcha token is output to standard out when the program completes, so you probably want to launch this tool from the terminal so you can see the output. There are no -options (for now), so just invoke it directly: +options (for now), so just invoke it directly. + +For a captcha token to use when registering an account: ``` ./signal-captcha-helper ``` + +for a challenge token to use to send messages: + +``` +./signal-captcha-helper --challenge +``` diff --git a/signal-captcha-helper.vala b/signal-captcha-helper.vala index cdcdbe3..9312a57 100644 --- a/signal-captcha-helper.vala +++ b/signal-captcha-helper.vala @@ -4,13 +4,14 @@ using WebKit; public class ValaBrowser : Window { private const string TITLE = "Signal Captcha Helper"; - private const string DEFAULT_URL = "https://signalcaptchas.org/registration/generate.html"; + private const string CHALLENGE_URL = "https://signalcaptchas.org/challenge/generate.html"; + private const string REGISTER_URL = "https://signalcaptchas.org/registration/generate.html"; private WebView web_view; public ValaBrowser () { this.title = ValaBrowser.TITLE; - set_default_size (450, 600); + set_default_size (500, 600); this.web_view = new WebView (); this.web_view.web_context.register_uri_scheme("signalcaptcha", token_issued); @@ -28,16 +29,24 @@ public class ValaBrowser : Window { Gtk.main_quit(); } - public void start () { + public void start (string url) { show_all (); - this.web_view.load_uri (DEFAULT_URL); + this.web_view.load_uri (url); } public static int main (string[] args) { Gtk.init (ref args); var browser = new ValaBrowser (); - browser.start(); + var url = REGISTER_URL; + + if(args.length > 0) { + if(args[1] == "--challenge") { + url = CHALLENGE_URL; + } + } + + browser.start(url); Gtk.main ();