Skip to content

Commit

Permalink
Migrate to manifest v3
Browse files Browse the repository at this point in the history
  • Loading branch information
freakitties committed Dec 16, 2021
1 parent a439096 commit 5fef942
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 19 deletions.
6 changes: 6 additions & 0 deletions background.js
Original file line number Diff line number Diff line change
@@ -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();
Expand Down
12 changes: 2 additions & 10 deletions contentScript.js
Original file line number Diff line number Diff line change
Expand Up @@ -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];
}
Expand Down
22 changes: 13 additions & 9 deletions manifest.json
Original file line number Diff line number Diff line change
@@ -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": {
Expand All @@ -20,17 +24,17 @@
}
},
"background": {
"scripts": ["options.js", "lib/web3.min.js", "background.js"],
"persistent": false
"service_worker": "background.js"
},
"content_scripts": [
{
"matches": ["https://marketplace.axieinfinity.com/*"],
"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
}

0 comments on commit 5fef942

Please sign in to comment.