Firefox WebExtention not loading

So, I tried to download my add-on using a page about:debuggingin Firefox. But it just didn't boot. Somewhere where an error will be logged to find it?

Here is my manifest. JSON Code:

{
    "description": "Adds a stickfigure",
    "manifest_version": 2,
    "name": "StickMan",
    "version": "1.0",
    "icons": {
        "48": "icons/StickMan-48.png"
    },
    "applications": {
        "gecko": {
          "id": "extention@stick.man",
          "strict_min_version": "45.0"
        }
    },
    "permissions": [
        "activeTab"
    ],
    "background": {
        "scripts": ["StickManUpdate.js"]
    },
    "browser_action": {
        "default_icon": {
            "48": "icons/StickManButton.png"
        },
        "default_title": "Call StickMan",
    },
}

I hope this helps other frustrated add-in developers.

Thanks in advance

-1
source share
1 answer

The absence of a download problem is that you have several syntax errors in the JSON of your manifest.json file. In the manifest.json file, specify the lines at the end of the file:

        "default_title": "Call StickMan",
    },
}

, ( , Object):

        "default_title": "Call StickMan"
    }
}

Firefox Developer Edition, , , :

FF dev edition Error loading WebExtension

, Firefox 47.0.1 Browser Console ( : Ctrl - Shift - J), , :

A promise chain failed to handle a rejection. Did you forget to '.catch', or did you forget to 'return'?
See https://developer.mozilla.org/Mozilla/JavaScript_code_modules/Promise.jsm/Promise

Date: Sun Jul 17 2016 11:11:22 GMT-0700 (Pacific Standard Time)
Full Message: SyntaxError: JSON.parse: expected double-quoted property name at line 33 column 2 of the JSON data
Full Stack: readJSON/</<@resource://gre/modules/Extension.jsm:628:19
NetUtil_asyncFetch/<.onStopRequest@resource://gre/modules/NetUtil.jsm:128:17

, - :

Full Message: SyntaxError: JSON.parse: expected double-quoted property name at line 33 column 2 of the JSON data

, Firefox Developer Edition, , :

SyntaxError: JSON.parse: expected double-quoted property name at line 33 column 2 of the JSON data
Stack trace:
readJSON/</<@resource://gre/modules/Extension.jsm:859:19
NetUtil_asyncFetch/<.onStopRequest@resource://gre/modules/NetUtil.jsm:128:17

WebExtensions:
API WebExtensions. WebExtension, , Firefox Nightly Firefox Developer Edition, .

:

:
. , , . , , StickManUpdate.js :

browser.tabs.sendMessage(
    message: "End";
);

. . tabs.sendMessage(). tabId. , , , Object , , , , . . , , , , , .

browserAction:
browserAction , browser.browserAction. browserAction . browserAction , : var browserAction = browser.browserAction;.

browserAction.getTitle(), , :
browserAction.getTitle(), . , . . , :

, browserAction.setTitle():
, ( Object), , , . , WebExtensions , . , , .

, ID :
tabId, . StickMan canvas . .

document.body.innerHTML stickman.js:
innerHTML . . DOM. , , , HTML DOM HTML , , /: insertAdjacentHTML(). :

document.body.innerHTML+= '<canvas id="StickManCanvas0000000" width="100" height="200"></canvas>';

:

document.body.insertAdjacentHTML("beforeend", '<canvas id="StickManCanvas0000000" width="100" height="200"></canvas>');

, - insertAdjacentHTML() . , insertAdjacentHTML() innerHTML. , AMO . , DOM. - , /, . , JavaScript (, canvas.style.position). . canvas JavaScript. , 4 , , innerHTML, getElementById(), canvas.

insertAdjacentHTML() . , HTML. . , , DOM document.createElement() setAttribute() . , , , insertAdjacentHTML() .

script canvas:
, browserAction, script . , - , , , browser.tabs.sendMessage() canvas. - chrome.tabs.executeScript() script , , canvas DOM. , StickMan , setTitle(), .

:
. stickman.js . .

manifest.json:

{
    "description": "Adds a stickfigure",
    "manifest_version": 2,
    "name": "StickMan",
    "version": "1.0",
    "icons": {
        "48": "icons/StickMan-48.png"
    },
    "applications": {
        "gecko": {
            "id": "extention@stick.man",
            "strict_min_version": "45.0"
        }
    },
    "permissions": [
        "activeTab"
    ],
    "background": {
        "scripts": ["StickManUpdate.js"]
    },
    "browser_action": {
        "default_icon": {
            "48": "icons/StickManButton.png"
        },
        "default_title": "Call StickMan",
        "browser_style": true
    }
}

StickManUpdate.js:

browser.browserAction.onClicked.addListener(function(tab) {
    browser.browserAction.getTitle({tabId:tab.id},function(title){
        if(title  === 'Call StickMan') {
            chrome.tabs.executeScript(tab.id, {
                file: "/content_scripts/stickman.js"
            });
            browser.browserAction.setTitle({title:'Recall StickMan',tabId:tab.id});
        } else if (title  === 'Call StickMan again') {
            browser.tabs.sendMessage(tab.id,"Draw");
            browser.browserAction.setTitle({title:'Recall StickMan',tabId:tab.id});
        }else {
            browser.tabs.sendMessage(tab.id,"End");
            browser.browserAction.setTitle({title:'Call StickMan again',tabId:tab.id});
        }
    });
});

stickman.js:

var running = true;
//document.body.insertAdjacentHTML("beforeend", '<canvas id="StickManCanvas0000000" width="100" height="200"></canvas>');
var canvas = document.createElement("canvas");
canvas.setAttribute("width",100);
canvas.setAttribute("height",200);
//var canvas = document.getElementById('StickManCanvas0000000');
canvas.style.position = 'fixed';
canvas.style.left = '0px';
canvas.style.top = (window.innerHeight-200)+'px';
canvas.style.backgroundColor = 'rgba(0, 0, 0, 0)';
canvas.style.border = '1px dashed red';

var ctx = canvas.getContext('2d');

var pos = {
    x:0,
    headX:50,
    headY:20,
    bodyX:50,
    bodyY:150,
    leftArmX:25,
    leftArmY:90,
    rightArmX:75,
    rightArmY:90,
    leftLegX:30,
    leftLegY:200,
    rightLegX:70,
    rightLegY:200,
};

var setPos = function(x, y) {
    canvas.style.left = x+'px';
    canvas.style.top = (window.innerHeight-y-200)+'px';
};

var drawMan = function(time) {
    setPos(pos.x, 0);
    ctx.strokeStyle = '#000000';
    ctx.lineWidth = 5;
    ctx.beginPath();
    ctx.arc(pos.headX, pos.headY, 20, 0, Math.PI*2, false);
    ctx.moveTo(pos.headX, pos.headY);
    ctx.lineTo(pos.bodyX, pos.bodyY);
    ctx.lineTo(pos.rightLegX, pos.rightLegY);
    ctx.moveTo(pos.bodyX, pos.bodyY);
    ctx.lineTo(pos.leftLegX, pos.leftLegY);
    ctx.moveTo((pos.bodyX+pos.headX)/2, ((pos.bodyY+pos.headY)/5)*2);
    ctx.lineTo(pos.rightArmX, pos.rightArmY);
    ctx.moveTo((pos.bodyX+pos.headX)/2, ((pos.bodyY+pos.headY)/5)*2);
    ctx.lineTo(pos.leftArmX, pos.leftArmY);
    ctx.stroke();
    ctx.fillStyle = '#888888';
    ctx.beginPath();
    ctx.arc(pos.headX, pos.headY, 20, 0, Math.PI*2, false);
    ctx.fill();
    if(running) {
        window.requestAnimationFrame(drawMan);
    }
};

drawMan();
document.body.appendChild(canvas);

browser.runtime.onMessage.addListener(function(m) {
    if(m === 'End' && running === true) {
        running = false;
        document.body.removeChild(canvas);
    } else if(m === 'Draw' && running === false) {
        running = true;
        document.body.appendChild(canvas);
    }
});

[1: -. 2. , , browser_action, , , .gif. 3: browser_style browser_action manifest.json. Firefox 48. Firefox .]:

stickman demonstration

+1

Source: https://habr.com/ru/post/1652983/


All Articles