Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

86
Visualizações
How to access the html of a page from a Firefox extension?

I am trying to develop a Firefox extension. The trouble is I cannot figure out how to access the html of the activetab when the toolbar button is pressed. I have not added the toolbar button yet, I will do that once I get the function getHTML working.

This is the manifest file.

{
  "manifest_version": 2,
  "name" : "Example",
  "version": "1.0",

  "description": "Example extension",

  "content_scripts": [
    {
      "matches": ["<all_urls>"],
      "js": ["js/content.js"]
    }
  ],

  "background": {
    "scripts": ["example.js"]
  },

  "permissions": [
    "tabs",
    "storage",
    "activeTab",
    "webRequest",
    ]
}

This is the background script example.js:

function getHTML() {
    browser.tabs.query({
        active: true,
        lastFocusedWindow: true
    }, function(tabs) {
        // and use that tab to fill in out title and url
        var tab = tabs[0];
        var tabId = tab.id;
        browser.tabs.executeScript(tabId, {
            code : "console.log(document.body.innerHTML)"
        })})};

getHTML()

What am I doing wrong?

Thanks in advance.

about 4 years ago · Juan Pablo Isaza
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda