处理 js 在 chrome 扩展中不起作用
Processing js not working in chrome extensions
我在 Google Chrome 扩展中使用 Processing JS。常规网页有效,但当我尝试扩展时,出现以下内容:
window.localStorage is not available in packaged apps. Use chrome.storage.local instead. extensions::platformApp:17
processing.js:718 Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
processing.js:798 Processing.js: Unable to execute pjs sketch.
processing.js:799 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: "default-src 'self' chrome-extension-resource:".
有办法解决这个问题吗?
没有
你不能放松 default CSP of Chrome Apps to allow eval
, and you can't get localStorage
to work, it is disabled 并且 chrome.storage
是异步的,因此你不能做一个 polyfill。
除非 Processing 制作了与 Chrome Apps 平台兼容的版本,或者您对其进行了大量修改,否则无法解决。
我在 Google Chrome 扩展中使用 Processing JS。常规网页有效,但当我尝试扩展时,出现以下内容:
window.localStorage is not available in packaged apps. Use chrome.storage.local instead. extensions::platformApp:17
processing.js:718 Refused to evaluate a string as JavaScript because 'unsafe-eval' is not an allowed source of script in the following Content Security Policy directive: "default-src 'self' chrome-extension-resource:". Note that 'script-src' was not explicitly set, so 'default-src' is used as a fallback.
processing.js:798 Processing.js: Unable to execute pjs sketch.
processing.js:799 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: "default-src 'self' chrome-extension-resource:".
有办法解决这个问题吗?
没有
你不能放松 default CSP of Chrome Apps to allow eval
, and you can't get localStorage
to work, it is disabled 并且 chrome.storage
是异步的,因此你不能做一个 polyfill。
除非 Processing 制作了与 Chrome Apps 平台兼容的版本,或者您对其进行了大量修改,否则无法解决。