added window.location.hash
authorJames Bunton <jamesbunton@delx.net.au>
Thu, 8 Oct 2015 11:13:49 +0000 (22:13 +1100)
committerJames Bunton <jamesbunton@delx.net.au>
Thu, 8 Oct 2015 11:13:49 +0000 (22:13 +1100)
youtube.cgi

index 3149343..7d39357 100755 (executable)
@@ -165,11 +165,14 @@ def decode_signature(js_url, signature):
         stdout=subprocess.PIPE
     )
     js_decode_script = ("""
-        var vm = require("vm");
+        var vm = require('vm');
 
         var sandbox = {
             window: {
-                location: {},
+                location: {
+                    hash: '',
+                    href: ''
+                },
                 history: {
                     pushState: function(){}
                 },
@@ -181,8 +184,9 @@ def decode_signature(js_url, signature):
             transformed_signature: null
         };
 
-        var execstring = ";transformed_signature = %(func_name)s(signature);";
-        vm.runInNewContext(%(code)s + execstring, sandbox);
+        var code_string = %(code)s + ';';
+        var exec_string = 'transformed_signature = %(func_name)s(signature);';
+        vm.runInNewContext(code_string + exec_string, sandbox);
 
         console.log(sandbox.transformed_signature);
     """ % params)