-
-
Save kroo/11205755 to your computer and use it in GitHub Desktop.
/** | |
* 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]; |
Good point. Updated instructions.
really glad you took the time to write this up and post.
noob question, but apparently i am doing something wrong. i am using the following string:
sudo /Users/Eli/GrowlVoiceFix/Cycript cycript -p GrowlVoice fix_growlvoice.js
I am getting "command not found" error.
did i place the "fix growlvoice" in the wrong place - see directory results here (i place the .js file in the cycript main folder - http://www.screencast.com/t/NeaFzVNrNZ6i
@katzly, you probably need a /
between Cycript
and cycript
. Try:
sudo /Users/Eli/GrowlVoiceFix/Cycript/cycript -p GrowlVoice /Users/Eli/GrowlVoiceFix/Cycript/fix_growlvoice.js
(assuming fix_growlvoice.js
is in the Cycript
directory)
It seems that the only malformed parts of the json are
'
instead of"
for strings, and- the following object contains an extraneous comma
'settings': {
'voicemailFeature1': false,
}
When I regexed the single quotes into double quotes and fixed the comma the resulting json was considered valid by at least one parser. It should be simple to take out all cases of commas before a ]
or }
and all the single quotes using NSRegularExpression.
@rdodesigns, agreed. GV may decide to change that at some point, of course.
Trying to run it for the first time, and getting the following error when I run the command in step 8:
dyld: Library not loaded: /usr/lib/libapr-1.0.dylib
Referenced from: /Users/jgruman/cycript/Cycript.lib/cycript
Reason: Incompatible library version: cycript requires version 5.0.0 or later, but libapr-1.0.dylib provides version 4.0.0
Trace/BPT trap
@jgruman, which version of OS X are you running? It looks like cycript was compiled with a newer version of libapr than is installed on your system...
@kroo, 10.6.8
Not sure if this is going to work for me but even if it doesn't, many thanks for putting the effort out to help those with severe GrowlVoice withdrawals (like me).
It worked for me, mate. Great job!
The line to run the script later should be:
cd /Applications/Utilities/cycript && sudo ./cycript -p GrowlVoice fix_growlvoice.js
I'm getting the error
Error: unrecognized selector signIn sent to object 0x60000001fd20
Any guesses as to why? Thanks.
@kroo - I'm on OSX 10.6.8 as well with the same error, any ideas on getting libapr-1.0.dylib
v5? Other than building it from http://www.opensource.apple.com/source/apr/apr-29.1/ which I assume is the correct source?
I wonder if someone on system 10.7+ could share their library file "/usr/lib/libapr-1.0.dylib" and those of us on 10.6.8 could use it to link our cycript?
Finally able to fix the libapr-1.0.dylib error, used Mac Ports to download a new version of "apr".
Now I'm having a new error:
Error: *** _assert(count == TASK_DYLD_INFO_COUNT):../Mach/Inject.cpp(117):InjectLibrary
any ideas?
I made a wrapper to automate running this patch every time GrowlVoice is launched.
This should remove any recurring hassle that comes with using this hack.
See here » http://szhu.github.io/fix-growlvoice/
I have used szhu's patch and it worked flawlessly for me.
Yay Internet!
I'm getting a similar "unrecognized selector signIn sent to object" error. Any ideas?
to those with "unrecognized selector signIn sent to object":
did you delete your user account? simply attempt to create it again. worked for me.
This script does not work OSX 10.10. Will patiently wait for a fix.
I receive the following error in Mac OS X 10.10: "ReferenceError: Can't find variable: require"
+1 not working on 10.10 with the same referenceError: Can't find variable: require. Any love for Yosemite?
I was thinking of making an Applescript to run Growl Voice and execute the command. Doesn't quite work:
do shell script "open -a GrowlVoice"
do shell script "~/cycript/cycript -p GrowlVoice fix_growlvoice.js" with administrator privileges
It returns an error
error "*** _assert(!stream->fail()):../Console.cpp(874):Main" number 1
Any thoughts on how to make a single double-clickable to launch GrowlVoice?
(this has been a helpful thread!)
dave
If you are just wanting to avoid running the terminal command manually at each launch, then this should take care of things for you.
Hey guys, if you're trying to get this to work under 10.10 and have some time to spare for debugging, cycript author @saurik gave some pointers on how to fix this in szhu/fix-growlvoice#6.
Another update for you guys — d235j/GVFixer is a SIMBL plugin that works on 10.10 and is dead simple to set up.
I get this when I run the command..
*** _krncall(task_for_pid(self, pid, &task)):../Mach/Inject.cpp(65):InjectLibrary [return=0x5]
any ideas?
Edit: sudo fixed it. Thanks