user1548936 user1548936 - 1 year ago 202
JSON Question

Use local files with Browser extensions (kango framework)

I'm working on a "browser extension" using "Kango Framework" (

When i want to link a css file i have to use external source (href=', how should i change the href to make is source from the plugin folder ? (ex: href='mylocalpluginfolder/localfile.css')

i've tried 'localfile.css' and putting the file in the same folder as the JS file.

How should i change the json file to make it work ? Should i declare the files as "extended_scripts" or "content_scripts" ?

I've a hard time finding support for this framework, even though the admins are awesome !
Thanks for your help. (please do not suggest to use other solutions, because i won't be able to code plugins for IE and Kango is my only option for this). I didn't find any samples matching my need as the only example available on their site is linking to outside content (christmas tree).

Answer Source

If you want to add CSS in page from content script you should:

  1. Get CSS file contents
  2. Inject CSS code in page
function addStyle(cssCode, id) {
    if (id && document.getElementById(id))
    var styleElement = document.createElement("style");
    styleElement.type = "text/css";
    if (id) = id;
    if (styleElement.styleSheet){
        styleElement.styleSheet.cssText = cssCode;
    var father = null;
    var heads = document.getElementsByTagName("head");
    if (heads.length>0){
        father = heads[0];
        if (typeof document.documentElement!='undefined'){
            father = document.documentElement
            var bodies = document.getElementsByTagName("body");
            if (bodies.length>0){
                father = bodies[0];
    if (father!=null)

var details = {
        url: 'styles.css',
        method: 'GET',
        async: true,
        contentType: 'text'
kango.xhr.send(details, function(data) {
        var content = data.response;
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download