Skip to content

Commit

Permalink
last version with catching media url on background.js
Browse files Browse the repository at this point in the history
It's a lot of easier to just fetch all jmuse urls on pupup request + cors issues + skill issue
  • Loading branch information
ingui-n committed Feb 8, 2024
1 parent 49a22e4 commit 07e00a5
Show file tree
Hide file tree
Showing 2 changed files with 169 additions and 150 deletions.
21 changes: 16 additions & 5 deletions src/background/background.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,17 @@ browser.webRequest.onSendHeaders.addListener(

const id = matchMedia[1];
const index = matchMedia[2];
console.log(index)
const type = matchMedia[3];

if (authHeader) {
const token = authHeader.value;

const tab = await updateCurrentTab();
await browser.tabs.sendMessage(tab.id, {scoreData: [`${id}_${type}_${index}`, token]});
if (tab?.id) {
await browser.tabs.sendMessage(tab.id, {
scoreData: [`${id}_${type}_${index}`, token]
});
}
}
}
},
Expand All @@ -38,13 +41,21 @@ browser.webRequest.onSendHeaders.addListener(
date.setSeconds(date.getSeconds() + Number(expires));

const index = matchMedia[1] || 0;
const type = matchMedia[2] === 'png' || 'svg' ? 'img' : matchMedia[2];
const type = matchMedia[2] === 'png' || matchMedia[2] === 'svg' ? 'img' : matchMedia[2];

const tab = await updateCurrentTab();
await browser.tabs.sendMessage(tab.id, {scoreDataUrl: [`${type}_${index}`, {url, expiration: date.toISOString()}]});

if (tab?.id) {
await browser.tabs.sendMessage(tab.id, {
scoreDataUrl: [`${type}_${index}`, {
url,
expiration: date.toISOString()
}]
});
}
}
},
{
urls: ['https://s3.ultimate-guitar.com/musescore.scoredata/g/*/score*']
}
}, ['requestHeaders']
);
Loading

0 comments on commit 07e00a5

Please sign in to comment.