Reputation: 141
I am working on Kango framework. In which I am facing problem to fetch external files in kango framework (browser extension).
Upvotes: 1
Views: 114
Reputation: 1869
Background script:
In the background script JavaScript files are included by adding them to common/extension_info.json
like this:
{
"background_scripts": [
"foo.js",
"main.js"
]
}
Content script:
In the content script JavaScript depndencies are added by adding a header annotation to the main file (the one declared as content script in common/extension_info.json
):
// ==UserScript==
// @require foo.js
// ==/UserScript==
// do stuff here...
Kango does not provide a good way to add CSS files in the content script. This has to be done by adding (and possibly removing) a <link>
tag to the <head>
section:
var link = document.createElement('link');
link.setAttribute('type', 'text/css');
link.setAttribute('rel', 'stylesheet');
link.setAttribute('href', kango.io.getResourceUrl('foo.css'));
document.getElementsByTagName('head')[0].appendChild(link);
Upvotes: 1