diff --git a/background.js b/background.js index 83b6141..2b3f130 100644 --- a/background.js +++ b/background.js @@ -1,5 +1,11 @@ +try { + importScripts("options.js"); +} catch (e) { + console.log(e); +} chrome.runtime.onInstalled.addListener(function() { +console.log("Installed"); getOptions((response) => { if (Object.keys(response).length == 0) { resetOptions(); diff --git a/contentScript.js b/contentScript.js index 48cdc2d..015db9b 100644 --- a/contentScript.js +++ b/contentScript.js @@ -121,16 +121,8 @@ debugLog("mutationsList", mutationsList); var bodyPartsMap = {}; async function getBodyParts() { - let parts = await fetch('https://axieinfinity.com/api/v2/body-parts?r=freak'). - then(res => res.json()). - catch(async (err) => { - console.log("Failed to get body parts from the API"); - //API is unreliable. fall back to hard-coded local copy. - let parts = await fetch(chrome.extension.getURL('body-parts.json')).then(res => res.json()); - for (let i in parts) { - bodyPartsMap[parts[i].partId] = parts[i]; - } - }); + //TODO: find the new way parts are listed + let parts = await fetch(chrome.runtime.getURL('body-parts.json')).then(res => res.json()); for (let i in parts) { bodyPartsMap[parts[i].partId] = parts[i]; } diff --git a/manifest.json b/manifest.json index 58bfd79..dd5211f 100644 --- a/manifest.json +++ b/manifest.json @@ -1,15 +1,19 @@ { "name": "Freak's Axie Extension", - "version": "1.5.4", + "version": "1.6.0", "description": "An extension to help play Axie Infinity.", - "permissions": ["activeTab", "declarativeContent", "storage", "https://marketplace.axieinfinity.com/*", "https://axieinfinity.com/*"], + "permissions": ["activeTab", "declarativeContent", "storage"], + "host_permissions": [ + "https://marketplace.axieinfinity.com/*", + "https://axieinfinity.com/*" + ], "icons": { "16": "images/rep_icon16.png", "32": "images/rep_icon32.png", "48": "images/rep_icon48.png", "128": "images/rep_icon128.png" }, - "browser_action": { + "action": { "default_popup": "popup.html", "default_title": "Freak's Axie Extension", "default_icon": { @@ -20,8 +24,7 @@ } }, "background": { - "scripts": ["options.js", "lib/web3.min.js", "background.js"], - "persistent": false + "service_worker": "background.js" }, "content_scripts": [ { @@ -29,8 +32,9 @@ "js": ["options.js", "traitmapping.js", "contentScript.js"] } ], - "web_accessible_resources": [ - "body-parts.json" - ], - "manifest_version": 2 + "web_accessible_resources": [{ + "resources": ["body-parts.json"], + "matches": ["https://marketplace.axieinfinity.com/*"] + }], + "manifest_version": 3 }