about summary refs log tree commit diff
path: root/pkgs/games/humblebundle
diff options
context:
space:
mode:
authoraszlig <aszlig@nix.build>2019-02-13 18:34:48 +0100
committeraszlig <aszlig@nix.build>2019-02-13 18:34:48 +0100
commit982f16d913c55eb474eb8a9f2b93cb78554f6eae (patch)
tree562f15335e577f93de93b3a3fa2dc353389fefd0 /pkgs/games/humblebundle
parent8bf8d1091af819f98759ae7e83f44354030efed6 (diff)
fetchHumbleBundle: Fix getting recaptcha response
The object in question to get the response from the Recaptcha widget is
now called "grecaptcha" instead of just "captcha" and the method to call
now is also called "getResponse" instead of "get_response".

Another change is that the grecaptcha object isn't available immediately
once the page is loaded, so I added a try...catch loop for that. I know
it's evil to do that, but I tried to check just for whether grecaptcha
is available and then call the getResponse method but found out that
during object construction there is a small time window where
getResponse is available but isn't a callable method.

There is still another issue with the HB fetcher, but the first step is
hereby fixed.

Signed-off-by: aszlig <aszlig@nix.build>
Diffstat (limited to 'pkgs/games/humblebundle')
-rw-r--r--pkgs/games/humblebundle/fetch-humble-bundle/default.nix6
1 files changed, 5 insertions, 1 deletions
diff --git a/pkgs/games/humblebundle/fetch-humble-bundle/default.nix b/pkgs/games/humblebundle/fetch-humble-bundle/default.nix
index 44b0537a..8431799b 100644
--- a/pkgs/games/humblebundle/fetch-humble-bundle/default.nix
+++ b/pkgs/games/humblebundle/fetch-humble-bundle/default.nix
@@ -13,7 +13,11 @@
   getCaptcha = let
     injectedJS = ''
       function waitForResponse() {
-        var response = captcha.get_response();
+        try {
+          var response = grecaptcha.getResponse();
+        } catch(_) {
+          return setTimeout(waitForResponse, 50);
+        }
         if (response != "")
           document.title = response;
         else