Showing posts with label greasemonkey. Show all posts
Showing posts with label greasemonkey. Show all posts

Monday, January 31, 2011

User-scripts in Google Chrome aren't GreaseMonkey scripts

This weekend I was playing around with writing a GreaseMonkey script to force the new Twitter layout to take up the full screen width for the list of tweets.

What I expected to be a 5 minute job turned into an hour and a half. The main issue was that it turns out I wasn't writing a GreaseMonkey script. While the user-scripts in Google Chrome are very similar to GreaseMonkey scripts, they differ in how they handle security (as well as some other more minor differences such as no @require). Eventually I found a helpful page on the Chromiumn wiki explaining the differences.

For me the biggest difference was the absence of unsafeWindow. The easiest way I found to workaround this limitation (which is just a sensible security protect) was to inject the javascript to execute into the document.

The resulting code isn't pretty and is a little harder to debug, but it works and I now don't have large areas of blank screen space when using Twitter.

Creative Commons License
The words and photos on this webpage which are created by Toby Gray are licensed under a Creative Commons Attribution-NonCommercial-ShareAlike 2.0 England & Wales License.