|
Redfin Real Estate Forums :
Website Questions :
Show WalkScore (GreaseMonkey hack)
|
|
|
|
|
|
|
|
|
|
Re: Show WalkScore (GreaseMonkey hack)
[ Edited ]
|
|
Navtej
Redfin Staff
Posts: 3
Registered: 04-15-2008

Message 3 of 4

Viewed 2,354 times
|

|
Hi dub,
The reason your script is failing after the first alert is because Greasemonkey cannot access g_listing. Greasemonkey scripts don't actually run directly in the context of the page, but work inside a sandbox for security reasons. This O'Reilly article details some of the caveats pretty well.
That said, you can make your script work by referring to unsafeWindow.g_listing instead of just g_listing. unsafeWindow is the actual window object rather than Greasemonkey's proxy, so it contains the custom fields added by the page's script. Just take note (from the O'Reilly article):
It's called unsafeWindow for a reason: its properties and methods could be redefined by the page to do virtually anything. You should never call methods on unsafeWindow unless you completely trust the remote page not to mess with you. You should only ever use it as a parameter to call functions defined by the original page, or to watch window properties...
Also note, that you can actually see the error messages in Firefox's error console (under the Tools menu) rather than just relying on window.alert().
Message Edited by Navtej on 04-15-2008 12:59 PM
Navtej Sadhal Software Developer - Search Team
|
|
|
|
04-15-2008 11:15 AM
|
|
|
|
|
|
|
|
|
|