BR75
BR75

Reputation: 667

Porting Add-on SDK to Webextension

I hope someone can help me with webextensions in Firefox 57. Im trying to port an plugin from Add-on SDK to Webextension.

All I have is this following code

Package.json

{
  "name": "myPlugin",
  "title": "Grafic",
  "id": "myID",
  "main": "lib/main.js",
  "description": "myDescription",
  "author": "",
  "license": "MPL 2.0",
  "version": "1.0.1"
}

and the main.js

Upvotes: 0

Views: 50

Answers (2)

Forivin
Forivin

Reputation: 15538

To get the URL of a page when it becomes active, you could use:

document.addEventListener("visibilitychange", function () {
  if (!document.hidden) {
      console.log('URL: ' + location.href);
  }
}, false);

Upvotes: 1

Smile4ever
Smile4ever

Reputation: 3704

browser.tabs.getCurrent is indeed only for background scripts. What you want is simply window.location.href.

Upvotes: 2

Related Questions