« Greasemetal - the next step | Main | Q4M prebuilt binaries for MySQL 5.1.28-rc »

Greasemetal version 0.2 released

I have just uploaded version 0.2 of Greasemetal to greasemetal.31tools.com. I originally intended to add management UI for userscripts in the second release, but hearing the users' request for improved compatibility with Greasemonkey, I changed my mind. The main focus of the release is to improve compatibility with Greasemonkey. The changes from version 0.1 are as follows.

Improved Compatibility with Greamemonkey

After the initial release a number of users requested support for GM_* functions, to improve compatibily with many existing userscripts written for Greasemonkey. So in version 0.2, we have implemented following functions:

  • GM_log
  • GM_addStyle
  • GM_openInTab
  • unsafewindow
GM_registerMenuCommand is also defined as an empty function, so that scripts calling the function would at least not fail by its inexistence. Unsafewindow simply refers to the window object, since there is no support for Greasemonkey functions that require higher security (GM_xmlHttpRequest, GM_setValue, GM_getValue).

The functions were written by my colleague Amachang. He is the developer of a Javascript-based presentation tool S6 (an example) and JavaScript-XPath.

Execution Log of Userscripts

Greasemetal will write execution log of userscripts to the inspection window (to open the window, right click anywhere in the browser window and select Inspect). Greasemetal logs which userscripts are executed, and names the ones that failed and the reason why. Unfortunately the line number at where the error occured cannot be logged, but still I hope it would be helpful for developers makeing their userscripts compatibile with Greasemetal.

Suppress Unnecessary Error Logs

The debug.log file is no more generated. If you find one next to Greasemetal.exe, you are free to remove it. Also you would no more see the error message "Uncaught TypeError: Cannot call method 'setAutomationId' of undefined" in the inspection window increasing forever (although you would see one message per tab, it's inevitable).

Passing Command Line Arguments to Google Chrome

Command line arguments following " - " are passed to Google Chrome. For example, command below will start Google Chrome with Greasemetal but without displaying images.

> Greasemetal.exe - --disable-images

Possibility of Supporting other GM_* Functions and Security Implications

4:43pm added: Now that we have added support for some GM_* functions, the left ones are: GM_xmlHttpRequest, GM_getValue, and GM_setValue. The three functions require a different security model than that of ordinal web scripts (known as same domain policy). Even if we dismissed the pontential danger of not supporting a non-safeWindow, the functions will require a secure channel from userscripts to the internal web server of Greasemetal (that malicious web sites cannot intervene), for storing and accessing persistent data, or performing cross-domain access through the web server. However, since there is no way to enforce the order of JavaScript execution so that the script injected by Greasemetal is run before any scripts on a web page gets executed, it is difficult to create such a channel (a malicious web page might redefine necessary functions for communication, such as document.createElement). In other words, it would be mandatory to implement an encrypted channel (with replay attack-resistency) between the injected JavaScript and the web server, however it would require some ammount of engineering.

This is our current understanding on the technical aspects of supporting the functions, and thus, until these situation changes, we have little (if not any) interest in implementing them.


This is great, good work. Can't wait for the UI.

It looks good. I've created a workaround to allow the GM_xmlhttpRequest to be used. I've tried it in one of my scripts. If you include this code in your script:
//Allow GM_xmlhttpRequest in Greasemetal ("Greasemonkey" for Google Chrome)
var chromexmlhttp;
var ChromeHTTP = function(options)
var onload = options["onload"];
chromexmlhttp = new XMLHttpRequest();
chromexmlhttp.open(options["method"], options["url"], true);
chromexmlhttp.onload = function(resp) {
var resptext = chromexmlhttp.responseText;
var responseDetails = { responseText : resptext }
{ window.GM_xmlhttpRequest = ChromeHTTP;

it will create a GM_xmlhttpRequest method compatible with the standard method, if the method does not already exist. I've tested it one of my scripts and it worked perfectly.

Actually, I've realised that my workaround only works for scripts which request from the same domain as the page the script is on. Which, rereading the post, is the reason for the problem implementing it.

The homepage for it needs modifying since the folder for the userjs to go into has changed to \Program Files\Greasemetal\userjs.

Zero3K: Version 0.2 of Greasemonkey reads userscripts from BOTH folders, one under Program Files and one under My Documents (or Documents, on Windows Vista).

The former is intended for system use only.

Thanks for creating Greasemetal!

Any thoughts on how I can get user scripts to work with ajax requests? GM under FF works with AJAX http requests, but Greasemetal does not appear to. (Windows Vista)


Great stuff, thanks. It doesn't seem to work on secure (https:) pages though. Is there a way to get it to work? Greasemonkey on Firefox does. With Opera it doesn't work by default but there's an opera:config setting to allow it. Thanks.

Please ignore the last comment; https: works, I was just running into a different error.

I checked the greasemonky script 'webaborn'.

The script worked when typing URL directly or clicking a link with mouse-left-button.

But the script does not work when clicking a link with mouse-wheel-button to open new tab. Why..?

I'd just like to make a note on GreaseMetal. While the developer is still adding the UI, you can use an application I created called DocWatcher to automatically move .user.js files from your Downloads directory to your userjs directory when downloaded.

It should be fairly simple to do (read the documentation if you don't understand the application that well), but if you still have problems, you can email me at jrhodes@roket-productions.com

Note: You don't need the Plus edition if your downloads directory is under My Documents.

Just a quick feature request that should be easy to implement: if you could read in any command-line options given to greasemetal and pass them along to Chrome, that would be excellent. I use a command-line switch to set a custom profile directory for chrome, so that would allow me to keep my user directory where it is.

> some GM_* functions
Looking on aagmfunctions.js from http://www.howtocreate.co.uk/operaStuff/userJavaScript.html
It contains emulations most of GM function for Opera browser.
It uses cookies for GM_[gs]etValue and emulation menu for GM_registerMenuCommand.

+1 to Hach-Que's request to allow for command-line options. I want to use this with the --app option to run web applications.

Correction: Request by Isochronous, not Hach-Que

Thanks for the utility first.Yesterday I tried it on flickr photo sharing flickrPM user script. What I observed is, when I open a new tab by middle mouse button, the tab gets opened up where as my control is still in the current page. In this case, the scripts functionality is not working on new tab content. When I go there and refresh it again works. Looks like, current window (tab) only renders with scripts in place.

- my 2 cents
thanks in advance again

Good article. Very informative. Thanks!

help a beginner, running Vista.

i installed GM, and placed YouTube Black into Documents/userjs.

Nothing happens. YouTube is not black.


Thanks for GM, I got my script to work. The only problem is, even with a 'hello world' script, it never works first time entering a page, it only ever works after you refresh or start clicking around on the site. Any ideas?

Kazuho, respect from Russia.

One problem, think you know, is that current greasemetal release doesn't work with latest GC release.

It's a pity.

Is it possible to resolve problem's reason? Sure it is! So, please, do it!

Dozens of GM fans are looking at you! =)

From Russia, with love.

Post a comment

(If you haven't left a comment here before, you may need to be approved by the site owner before your comment will appear. Until then, it won't appear on the entry. Thanks for waiting.)