Chci vytvořit Rozšíření pro Chrome, které by bylo kompatibilní s Manifest Verze 3, ale narazil jsem tady na problém s získání aktuálního uživatele geolokace souřadnice, které pracuje s Manifest Verze 2, ale pro Manifest Verze 3 to hodí, že navigator.geolocation
je nedefinované.
Zde je můj manifest.json a background.js soubory:
manifest.json:
"name": "Chrome Extension MV3",
"description": "Learning all about Chrome Extensions Manifest Version 3!",
"version": "0.1.0",
"manifest_version": 2,
"background": {
"service_worker": "background.js"
},
"permissions": ["geolocation"]
}
background.js:
navigator.geolocation.getCurrentPosition((position) => {
const { latitude, longitude } = position.coords;
console.log(latitude, longitude);
});