Hi,
It would be really useful to have the ability to insert a function or set of
functions from the greasemonkey script into the client page. For things like
cookie handling, or functions to be triggered from additional/changed
anchors I've added to the client page I find that I have to code the
function as a greasemonkey script function, and then escape a copy of it
into a string (http://www.htmlescape.net/stringescape_tool.html) does this
with overkill, and then add it to the client page by appending a script to
the header of the page:
[code]
var script = document.createElement('script');
script.type = 'text/javascript';
script.innerHTML = "function helloworld(){alert('hello world';}";
document.getElementsByTagName('head')[0].appendChild(script);
[/code]
This isn't great, especially when the slightest mistake in escaping the
script leaves it non-working without any errors being thrown to help you
debug. It's also a complete pain in the ass to maintain...
It would be great to be able to define the script, and then have an API call
to insert it to the client page:
[code]
function helloworld(){
alert('hello world';
}
GM_addScript('helloworld');
[/code]
I understand the risks of allowing the client page any access into the
greasemonkey script, however a function to deliberately add code from the
script to the page without this workaround would be really good.
--
You received this message because you are subscribed to the Google Groups
"greasemonkey-users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/greasemonkey-users?hl=en.