I have a style sheet which is injected into a page. The style sheet has:
@font-face {
font-family: 'Roboto';
font-style: normal;
font-weight: 100;
src: url(fonts/KFOkCnqEu92Fr1MmgVxIIzQ.woff) format('woff');
}
The problem I have is I need it to look at the fonts in my local (Chrome extension) resources. I have this working for JS files I include by using chrome.extension.getURL(src)
but I can't do that for the html content I've injected into the page.
I have the same issue with images as well as the img tag is on the page as <img src="img/some-image.png" />
so again, it's looking for the img on the website the html is injected into.
Any ideas how I can get around this?
Note: The html content I'm injecting into a page is a VueJS SPA so it's not individual image tags etc.
Edit: For now, I have a nasty work around:
loadScript('www/app.js', () => {
let images = document.getElementsByTagName('img')
for (let i = 0, l = images.length; i < l; i++) {
images[i].src = chrome.extension.getURL('www' + '/' + images[i].src.substring(images[i].src.indexOf('img/')))
}
})