Issue using YUI as content script

445 views
Skip to first unread message

b0uh

unread,
May 27, 2011, 3:17:22 AM5/27/11
to Chromium-extensions
Hi,
I got an issue that I don't understand. I want to use YUI as a
content script. But I always got an error. By the way I don't get any
error when I don't load any module.

Here is the code, it's simple :

--------------------------------
manifest.json--------------------------------
{
"name": "My First Extension",
"version": "1.0",
"description": "The first extension that I made.",
"permissions": ["tabs"],
"content_scripts": [
{
"matches": ["http://*/*","https://*/*"],
"js" : ["yui-debug.js", "main.js"]
}
]
}
-----------------------------------------------------------------------------------

------------------------------------
main.js------------------------------------
YUI().use('node', function (Y) {
});
-----------------------------------------------------------------------------------

---------------------------------error
output---------------------------------
yui: Modules missing: node, 1
yui: Fetching loader: http://yui.yahooapis.com/3.3.0/build/loader/loader-min.js
get: attempting to load http://yui.yahooapis.com/3.3.0/build/loader/loader-min.js
**Uncaught ReferenceError: YUI is not defined**
yui: NOT loaded: loader
yui: Modules missing: node, 1
yui: Attaching available dependencies: node
yui: NOT loaded: node
yui: caching request: node
-----------------------------------------------------------------------------------

Chrome 11.0.696.65

Thanks !

PhistucK

unread,
May 27, 2011, 4:18:58 AM5/27/11
to b0uh, Chromium-extensions
You must include all of the necessary files in order for it to work.
Loading scripts dynamically (at least in the YUI way) will not work with content scripts, because they will execute within the world of the page, not within the world of the content script (which do no share variable and such, except for the actual DOM).

So, you have to include that loader-min.js within your extension and add it to the content script entry within the manifest.
PhistucK




--
You received this message because you are subscribed to the Google Groups "Chromium-extensions" group.
To post to this group, send email to chromium-...@chromium.org.
To unsubscribe from this group, send email to chromium-extens...@chromium.org.
For more options, visit this group at http://groups.google.com/a/chromium.org/group/chromium-extensions/?hl=en.


b0uh

unread,
May 30, 2011, 2:51:14 AM5/30/11
to Chromium-extensions
You are right, I have to load each YUI module myself.

Thanks for the tip :)

On May 27, 10:18 am, PhistucK <phist...@gmail.com> wrote:
> You must include all of the necessary files in order for it to work.
> Loading scripts dynamically (at least in the YUI way) will not work with
> content scripts, because they will execute within the world of the page, not
> within the world of the content script (which do no share variable and such,
> except for the actual DOM).
>
> So, you have to include that
> loader-min.js<http://yui.yahooapis.com/3.3.0/build/loader/loader-min.js>
> within
> your extension and add it to the content script entry within the manifest.
> ☆*PhistucK*
> > To post to this group, send email to chromium-extensi...@chromium.org.
> > To unsubscribe from this group, send email to
> > chromium-extensions+unsubscr...@chromium.org.
Reply all
Reply to author
Forward
0 new messages