I personnally do that way to include javascript in a page from content
script :
(function() {
var script = document.createElement('script');
script.type = 'text/javascript';
script.src = chrome.extension.getURL('script_embed.js');
document.body.appendChild(script);
})();
The script_embed.js code can access the webpage's javascript.
--
AlK
On Dec 15, 4:44 pm, PhistucK <[email protected]> wrote:
> Well, if you control the webpage, you can access everything and do not need
> "unsafeWindow" in a user script, no?
> But if case you do, I guess you can create an event with
> document.location.href = "javascript:..." and it will execute itself as if
> it were the webpage.
>
> ☆PhistucK
>
> 2009/12/15 MaartenC <[email protected]>
>
>
>
> > I checked the info and it seems to be only for sharing events between
> > contentscripts and webpage scripts. But the script(s) I'd like to
> > convert use variables from the webpage.
>
> > I can maybe insert a little script in the webpage that passes on all
> > the variables via an event or something?
>
> > On 14 dec, 17:18, Aaron Boodman <[email protected]> wrote:
> > > Some Greasemonkey scripts accessunsafeWindowbut don't really need
> > > it. First you should try replacing "unsafeWindow" with just "window"
> > > and see if it works.
>
> > > If you really do needunsafeWindow(because you are accessing the
> > > JavaScript environment of the page), you'll need to use the technique
> > > here:
>
> > >http://code.google.com/chrome/extensions/content_scripts.html#host-pa...
>
> > > - a
>
> > > 2009/12/14 [G] <[email protected]>:
>
> > > > Chrome extensons can't access the host web page's script ,so has not
> > > > "unsafeWindow" like GM
>
> > > > On 12月14日, 下午9时45分, MaartenC <[email protected]> wrote:
> > > >> I'm converting some GreaseMonkey script to Chrome extensions and I
> > > >> need a way to do the same asunsafeWindowfrom GM. Some kind of
> > > >> workaround. I've been reading some topics about it but there doesn't
> > > >> seem to be a good solution so I hope anyone here can help me with
> > > >> this.
>
> > > >> Greetz,
> > > >> MaartenC
>
> > > > --
>
> > > > You received this message because you are subscribed to the Google
> > Groups "Chromium-extensions" group.
> > > > To post to this group, send email to
> > [email protected].
> > > > To unsubscribe from this group, send email to
> > [email protected]<chromium-extensions%2Bunsu
> > [email protected]>
> > .
> > > > For more options, visit this group athttp://
> > groups.google.com/group/chromium-extensions?hl=en.
>
> > --
>
> > You received this message because you are subscribed to the Google Groups
> > "Chromium-extensions" group.
> > To post to this group, send email to [email protected].
> > To unsubscribe from this group, send email to
> > [email protected]<chromium-extensions%2Bunsu
> > [email protected]>
> > .
> > For more options, visit this group at
> >http://groups.google.com/group/chromium-extensions?hl=en.
--
You received this message because you are subscribed to the Google Groups
"Chromium-extensions" 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/chromium-extensions?hl=en.