Hello !
How do I retrieve the URL of the tab from which I open a popup window by clicking on the extension button?
I’ve try this, read on this forum, but it don’t work:
console.log((await browser.tabs.query({ active: true, lastFocusedWindow: true }))[0].url)
le manifest:
{
"manifest_version": 2,
"name": "parameters",
"version": "1.0",
"description": "Ajoute des paramètres à la page Web active",
"permissions": [
"activeTab",
"tabs"
],
"browser_action": {
"default_icon": {
"32": "icons/test.svg"
},
"default_title": "parameters",
"default_popup": "popup/choose_parameters.html"
}
}
Le popup:
<!--[if lt IE 7]> <html class="no-js lt-ie9 lt-ie8 lt-ie7"> <![endif]-->
<!--[if IE 7]> <html class="no-js lt-ie9 lt-ie8"> <![endif]-->
<!--[if IE 8]> <html class="no-js lt-ie9"> <![endif]-->
<!--[if gt IE 8]> <html class="no-js"> <!--<![endif]-->
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title></title>
<meta name="description" content="">
<meta name="viewport" content="width=device-width, initial-scale=1">
</head>
<body>
<form name="formulaire">
<div class="ppc">
<div class="did">
<p>Catégorie</p>
<select name="category">
<option class="opt" value="2">Voiture</option>
<option class="opt" value="3">Moto</option>
</select>
</div>
<div class="did">
<p>Marque</p>
<select name="brand">
<option class="opt" value="honda">Honda</option>
<option class="opt" value="yamaha">Yamaha</option>
<option class="opt" value="Citroen">Citroën</option>
</select>
<a href="#" class = "envoi" target="_blank" title="Envoi !"><img src="" class="img-0" alt="envoi"></a>
</div>
</div>
</form>
<script src="choose_parameters.js"></script>
</body>
</html>
le .js:
console.log((await browser.tabs.query({ active: true, lastFocusedWindow: true }))[0].url)
I dont retrieve the URL in the console.
Who know ?