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

293
Views
Browser Extension - Open Background Page on browser_action

I want to create a browser extension, that simply opens the extensions background page, when I press on the extension's icon in the toolbar. The problem is, that when I add the browserAction listener to the toolbar icon in a script on the background page, it gets triggered again when I open the background page, so when I click the icon again, it opens 2 new tabs and so on...

file tree: click to view image

manifest.json

  "manifest_version": 2,
  "name": "Easy Films",
  "version": "1.0",

  "permissions": [
    "tabs"
  ],

  "browser_action": {
    "default_title": "Easy Films",
    "default_icon": "icons/browser_action.png"
  },

  "background": {
    "page": "background/index.html"
  }
}

background/index.html

<html>
  <head>
  </head>
  <body>
    <h1>Content will be added</h1>
    <script src="script.js"></script>
  </body>
</html>

background/script.js

function onStartup() {
  browser.browserAction.onClicked.addListener(onClicked);
}

function onClicked() {
  browser.tabs.create({
    url: location.href
  });
}

browser.runtime.onStartup.addListener(onStartup);
about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

Have you tried using start_url or scope?

"manifest_version": 2,

"name": "Easy Films",

"version": "1.0",

"start_url": "/",

"scope": "/",

about 4 years ago · Juan Pablo Isaza Report
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!