Mozilla Firefox extension

Asked

Viewed 38 times

0

I have a problem, my extension does not work at all, first of all, I will explain to you what it serves:

This extension when active makes the insertion of data in a form of a given web site, receiving this data through a socket of an application made in java.

Google Chrome works perfectly, with a 2-second delay for every item added to the form (this started happening recently, I don’t know why), so with all the tests I’ve done, it’s because of some update of its version.

But changing from water to wine, I did not come for Chrome but for Mozilla, I will provide the extension and I am waiting for help.

Manifest:

{
    "name": "SGIR - Extensão",
    "manifest_version": 2,
    "version": "1.1",
    "description": "Preencher formulários",
    "browser_action": {
        "default_popup": "popup.html"
    },
    "permissions": [
        "contextMenus",
        "//Determinado site da web"
    ],
    "content_scripts": [{
        "js": ["funcao.js"],
        "matches": ["//Determinado site da web"]
    }]
}

Function:

var ws = new WebSocket("ws://localhost:30000");
var itens = [];

ws.onopen = function ()
{
    ws.send("");
   // alert("Mensagem enviada...");
};

ws.onmessage = function (evt)
{
    var received_msg = evt.data;
    itens.push(received_msg);

    var ni = document.getElementById("NI");
    ni.value = itens[0].toString();

    var codigoacesso = document.getElementById("CodigoAcesso");
    codigoacesso.value = itens[1].toString();

    var senha = document.getElementById("Senha");
    senha.value = itens[2].toString();

    itens.splice(0,itens.length);
};

ws.onclose = function ()
{
    // websocket is closed.
    //alert("Conexão fechada...");
};

window.onbeforeunload = function (event) {
    socket.close();
};

Scriptjs:

/* global browser */

browser.tabs.query({
    active: true,
    windowType: "normal",
    currentWindow: true
}, function (tab) {
    browser.tabs.executeScript(tab[0].id, {
        "file": "funcao.js"
    });
});

Popup:

<!doctype html>
<html>
    <head>
        <script src="scriptjs.js"></script>
    </head>
    <body>

        Programa criado por @netoschneider

    </body>
</html>
  • What are the symptoms?

  • The extension does not work at all in Mozilla, and in google Chrome, I’m having a delay of 3, 2 seconds for the information to appear in the form @Pabloalmeida

  • Okay, but it doesn’t work because? What’s the mistake?

  • So that’s exactly what I want to find out. I do not see problems in the code, in Chrome it works, but generates delay and it came out of nowhere, I did not make any changes in the code, and in Mozilla I do not know why the extension does not work.

  • Have you looked at the browser console?

  • Can you guide me? How to debbug Mozilla to see the extension error?

  • Press F12 to open the console. There will appear the errors and also have a tab with a debugger if you want to follow the execution step-by-step.

  • In google Chrome it generates an exception: "Uncaught Typeerror: Cannot read Property 'toString' of Undefined at Websocket.ws.onmessage ", but nothing that compromises execution in the form, with delay as I said, and in Mozilla generates nothing, it just doesn’t work. @Pabloalmeida

  • In Mozilla the extension works, what does not work is the websocket connection, simply does not connect to the server, through Chrome the same extension connects, but with Mozilla does not.

Show 4 more comments
No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.