Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

90
Views
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
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!