tags:

views:

130

answers:

2

Hi

Can I call function() of my custom Greasemonkey from my page?

For example,

I created a GM script that contains do_this() function. I want my-web-site.com call the do_this() function. But I can't.

I know, I can by doing unsafeWindow.do_this() but doing so prevents me from calling GM_xmlhttpRequest().

Any ideas?

+1  A: 

No, GM_* functions are not accessible from webpage.

S.Mark
+1  A: 

I just had the same Problem. You can find good information here in the wiki. I would suggest to use script injection to insert the needed code into the document. That way it will run like its in the sourcecode of the page. You can't use GM_ functions there either but you can use a combination of script injection (to retrieve a variable for example) and classic greasemonkey scripting with all the GM_ functions (For example you could use the variables you read and POST them with GM_xmlhttpRequest()).

Furthermore, techniques like script injection have several security-related advantages over unsafeWindow.

I hope that helps.

das_weezul