2

If I download the minified YUI3 loader and include it in my background.html I get the following error:

Uncaught EvalError: Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "script-src 'self' chrome-extension-resource:".

Can YUI3 be used in an extension?

4

2 回答 2

1

看起来它阻止您使用 eval()。确保清单中有以下行。

"content_security_policy": "script-src 'self' 'unsafe-eval'; object-src 'self'"

于 2013-07-27T02:35:11.993 回答
0

这就是我能够做到的。从 git 克隆 yui3 和 yui3-gallery,在我的扩展树中添加我需要的模块。然后从 popup.html 和 background.html 加载 config.js。该文件如下所示:

YUI_config = {
    filter: "raw",
    base: "yui3/build/",
    root: "yui3/build/",
    comboBase: "/combo?",
    combine: false,
    groups: {
        gallery: {
            base: "yui3-gallery/build/",
            root: "yui3-gallery/build/",
            comboBase: "/combo?",
            combine: false,
            patterns: {
                "gallery-": {},
                "gallerycss-": { type: "css" }
            }
        }
    }
};

现在一切正常!

于 2013-02-20T16:25:38.893 回答