Greasemetal - a userscript runtime for Google Chrome
For more than two years, I have been using Firefox. And Greasemonkey. Then, last week, came Google Chrome. It was at the moment I tried the new browser that I suddenly noticed I could no more live without userscripts (especially, AutoPagerize). So I started looking into the source code of Google Chrome, and found out a way to implement a userscript runtime. And that's Greasemetal. It is now available from the link below.
Technically, Greasemetal executes userscripts in the following steps.
- setup a local web server that sends userscripts to Google Chrome
- launch Google Chrome specifying the browser to connect its AutomationProxy (an interprocess communication channel of the web browser implemented for automated UI tests) to Greasemetal
- periodically execute JavaScript in each browser tab that inserts <script> tags to download necessary userscripts from the local web server
The userscripts I checked and found compatible are;
- Mylingual and Japanize - a community-based web UI localization service
- oAutoPagerize - a port of AutoPagerize (the Safari version seems to be compatible with Greasemetal)
This is the first release of Greasemetal, and it still lacks a number of features (especially the UI for managing userscripts). I hope I can release the next version early (hopefully a code-signed version), but if you find any bugs or have any suggestions, please let me know (although I am afraid I might not be able to answer to compatibility problems of each userscripts). Anyway, have fun!
Comments
GreaseMetal version: 0.1
Google Chrome version: 0.2.149.29
Problem: I'm getting a lot of errors that state "Uncaught TypeError: Cannot call method 'SetAutomationId' of undefinded" (you can see them if you were to right click on any part of a website, select Inspect element and then click on the stop sign in the lower right hand corner).
Posted by: Zero3K | September 11, 2008 04:32 AM
Thank you for reporting the problem.
I check the source code of Google Chrome, and the error message is a side effect of inserting userscripts.
Although it would not do any harm, I will minimize the display of the error message in the next version, since its certainly annoying (it seems impossible to completely eliminate the message).
Posted by: kazuho | September 11, 2008 11:19 AM
Nice program! I would really like it if you can integrate your program into Google Chrome. That would be nice so I don't have to shortcut your program everywhere :).
Posted by: James | January 21, 2009 08:05 AM
Hello!
I wrote for my own use a little userscript, it's for using the back/forward functions with the mouse buttons. If you do this: downright+downleft+upright+upleft it goes back, and if you do downleft+downright+upleft+upright it goes forward.
Just put this in a something.user.js file in the correct directory:
// ==UserScript==
// @name MouseHistory
// ==/UserScript==
var conm=true;
document.oncontextmenu = function(){return conm;};
var ar=new Array(4);
ar[1]=-1;
ar[2]=-1;
ar[3]=-1;
ar[4]=-1;
function enablecon(truefalse){
if(conm != truefalse){
conm=truefalse;
}
}
function test(){
if(ar[4]==2 && ar[3]==4 && ar[2]==1 && ar[1]==3){
history.back(1);
}
if(ar[4]==4 && ar[3]==2 && ar[2]==3 && ar[1]==1){
//alert("forward");
history.forward(1);
}
if((ar[3]==1 && ar[4]==4)||(ar[3]==2 && ar[4]==4)){enablecon(false);}
else{enablecon(true);};
}
document.addEventListener('mousedown', function(event) {
enablecon(false);
ar[1]=ar[2];
ar[2]=ar[3];
ar[3]=ar[4];
if(event.button==0){ar[4]=1;}
if(event.button==2){ar[4]=3;}
}, true);
document.addEventListener('mouseup', function(event) {
enablecon(false);
ar[1]=ar[2];
ar[2]=ar[3];
ar[3]=ar[4];
if(event.button==0){ar[4]=2;}
if(event.button==2){ar[4]=4;}
test();
}, true);
ok, thats it.
known limitation: it doesnt work on the first page chrome displays in empty tabs , aka the shortcuts page, because i think greasemetal doesnt work on them.
cheers,
mcstar
Posted by: mcstar | January 26, 2009 06:10 PM
i think greasemetal doesnt work
Videolar
Posted by: 123456 | March 17, 2009 08:32 PM
I was having trouble at first, but now the problem was solved, thank you
youtube
Posted by: video | April 4, 2009 11:07 PM
is it possible to get this to work with SRWare iron since the iron browser is almost Identical to Chrome?
Posted by: Paroxysm | April 10, 2009 01:26 AM
Thanks for the article. It works perfeclty fine at my side. Thank you kazuho for this nice article.
Youtube
Posted by: joe123 | May 3, 2009 08:02 AM
Thanks for the article. It works perfeclty fine at my side. Thank you kazuho for this nice article
Posted by: arabalife | May 18, 2009 07:14 PM
hihi. I have a problem. When I run greasemonkey, chrome opens for a few milliseconds and then it closes immediately. May I know what's the problem and how I can resolve it? I have tried reinstalling chrome and greasemetal.
Posted by: ajeftw | June 8, 2009 03:32 AM
thanks
Posted by: akif | June 9, 2009 08:41 PM