Skip to content

Instantly share code, notes, and snippets.

@kroo
Last active June 26, 2017 18:11

Revisions

  1. kroo revised this gist Apr 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## How to Use ##

    Open a `Terminal.app` in your /Applications/Utilities directory, then run these commands, one after each other:
    Open up `Terminal.app` in your `/Applications/Utilities` directory, then type in these commands, one after each other:

    1. Create a temporary directory for cycript:
    ```
  2. kroo revised this gist Apr 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    ## How to Use ##

    Open a `Terminal.app` in your applications directory, then run these commands, one after each other:
    Open a `Terminal.app` in your /Applications/Utilities directory, then run these commands, one after each other:

    1. Create a temporary directory for cycript:
    ```
  3. kroo revised this gist Apr 23, 2014. 1 changed file with 2 additions and 1 deletion.
    3 changes: 2 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -38,4 +38,5 @@ Open a `Terminal.app` in your applications directory, then run these commands, o
    ```
    sudo ./cycript -p GrowlVoice fix_growlvoice.js
    ```


    Each time you restart GrowlVoice, you will need to run this fix script again. Run `cd ~/cycript && sudo ./cycript -p GrowlVoice fix_growlvoice.js` to run the script sometime later.
  4. kroo revised this gist Apr 23, 2014. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion README.md
    Original file line number Diff line number Diff line change
    @@ -16,20 +16,26 @@ Open a `Terminal.app` in your applications directory, then run these commands, o
    ```
    unzip cycript.zip
    ```

    4. Download `fix_growlvoice.js`:
    ```
    curl https://gist.githubusercontent.com/kroo/11205755/raw/fix_growlvoice.js -o fix_growlvoice.js
    ```

    5. Start GrowlVoice now.
    ```
    open -a GrowlVoice
    ```

    6. A popup window should appear about malformed JSON. Close it.

    7. Ensure cycript is executable:
    ```
    chmod +x ./cycript
    ```

    8. Patch the running GrowlVoice process:
    ```
    sudo ./cycript -p GrowlVoice fix_growlvoice.js
    ```
    ```

  5. kroo revised this gist Apr 23, 2014. 1 changed file with 35 additions and 0 deletions.
    35 changes: 35 additions & 0 deletions README.md
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,35 @@
    ## How to Use ##

    Open a `Terminal.app` in your applications directory, then run these commands, one after each other:

    1. Create a temporary directory for cycript:
    ```
    mkdir cycript && cd cycript
    ```

    2. Pull the latest cycript from cycript.org:
    ```
    curl -L https://cydia.saurik.com/api/latest/3 -o cycript.zip
    ```

    3. Unzip cycript:
    ```
    unzip cycript.zip
    ```
    4. Download `fix_growlvoice.js`:
    ```
    curl https://gist.githubusercontent.com/kroo/11205755/raw/fix_growlvoice.js -o fix_growlvoice.js
    ```
    5. Start GrowlVoice now.
    ```
    open -a GrowlVoice
    ```
    6. A popup window should appear about malformed JSON. Close it.
    7. Ensure cycript is executable:
    ```
    chmod +x ./cycript
    ```
    8. Patch the running GrowlVoice process:
    ```
    sudo ./cycript -p GrowlVoice fix_growlvoice.js
    ```
  6. kroo revised this gist Apr 23, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion fix_growlvoice.js
    Original file line number Diff line number Diff line change
    @@ -14,7 +14,7 @@
    * - Download cycript from cycript.org, and extract somewhere sane
    * - download this script to the same place as cycript
    * - Start GrowlVoice (it will complain about malformed JSON)
    * - Run ./cycript -p GrowlVoice fix_growlvoice.js
    * - Run sudo ./cycript -p GrowlVoice fix_growlvoice.js
    */

    @import com.saurik.substrate.MS
  7. kroo created this gist Apr 23, 2014.
    67 changes: 67 additions & 0 deletions fix_growlvoice.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,67 @@
    /**
    * A quick n' dirty hack to fix a dying GrowlVoice
    *
    * GrowlVoice is now officially dead: https://twitter.com/GrowlVoice/status/455931023868448768
    * However, Google didn't really shut off API access (there wasn't really any to begin with);
    * they slightly mangled a JSON object GrowlVoice was looking for on one of Google Voice's
    * internal pages.
    *
    * The following is a Cycript script that will bring a dead GrowlVoice back
    * to life for the moment (until Google decides to mangle things more).
    *
    * To use:
    *
    * - Download cycript from cycript.org, and extract somewhere sane
    * - download this script to the same place as cycript
    * - Start GrowlVoice (it will complain about malformed JSON)
    * - Run ./cycript -p GrowlVoice fix_growlvoice.js
    */

    @import com.saurik.substrate.MS

    var oldm = {},
    NSUTF8StringEncoding = 4,
    MESSAGE = @selector(accountInfoFetcher:finishedWithData:error:),
    START_TOKEN = 'var _gcData = ',
    END_TOKEN = '};';

    // It's failing in accountInfoFetcher:finishedWithData:error:, a callback method
    // that parses a response from Google's auth page, and pulls in a bunch of info.
    //
    // Since it's failing there, let's hook it, and massage the data we're getting
    // back until GrowlVoice can understand it again.
    //
    // Using MobileSubstrate, the following line 'swizzles' the method, replacing
    // it with our own wrapper function:
    MS.hookMessage(GoogleVoiceLoginInterface, MESSAGE, function (fetcher, data, err) {
    // In particular, we need to find a json object embedded in the page that was
    // just returned into this function (as the second arg, data).

    // Convert to NSString from NSData
    var sdata = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];

    // Find the start and end of the JSON object, then split the page into 3
    // sections: before the json object, after, and the object itself. This is
    // pretty fragile, but exactly what GrowlVoice does, so we might as well be
    // consistant.
    var startIndex = sdata.indexOf(START_TOKEN) + START_TOKEN.length;
    var endIndex = sdata.indexOf(END_TOKEN, startIndex) + 1;
    var prefix = sdata.slice(0, startIndex);
    var suffix = sdata.slice(endIndex);
    var authJSON = sdata.slice(startIndex, endIndex);

    // Now, fix the JSON object. This method is robust, but dangerous:
    // Google's new JSON encoding format only works when evaluating as a
    // javascript statement -- it's really not even close to valid json.
    // Therefore, we evaluate that line as a javascript statement, then
    // re-encode back to well-formed json.
    eval('var gcData = ' + authJSON);
    var fixedJSON = JSON.stringify(gcData);

    // reconstruct the original page, and pass back through to the original method
    var newdata = [(prefix + fixedJSON + suffix) dataUsingEncoding:NSUTF8StringEncoding];
    oldm->call(this, fetcher, newdata, err);
    }, oldm);

    // trigger the signin process again
    [choose(GoogleVoiceLoginInterface)[0] signIn];