I want to put all my functions in js file and refer to them from my code in the extension is th开发者_如何学编程at possible?
If you wana use it from a html:
<script type="text/javascript" src="path/my_functions.js"></script>
If you wanna refer to them from a content script:
chrome.tabs.executeScript(null, {file: "path/my_functions.js"}, function(){
oneOfMyFunctions();
});
If you wanna refer to them from the manifest file:
{
"name": "My extension",
...
"content_scripts": [
{
"matches": ["http://www.google.com/*"],
"js": ["path/my_functions.js"]
}
],
...
}
More info available here.
精彩评论