在chrome扩展中解析HTML

I have a chrome extension where i need to get favicons of the user's top sites (with topSites optional permission). I saw a few services that get the favicon like duckduckgo and google but they're not so reliable. for example this - https://www.google.com/s2/favicons?domain=www.github.com doesn't work. So I want to get the HTML of a url and parse it to find the link tag with shortcut icon. The problem is with the fetch and CORS. I tried with fetch inside the content-script and also with sendMessage in content-script and onMessage.addListener in background script. Both give me this CORS ERROR:

Access to fetch at 'http://localhost:1989/' from origin 'chrome-extension://efphmimdjjdjhnhnbfnloeaihppimfni' has been blocked by CORS policy: No 'Access-Control-Allow-Origin' header is present on the requested resource. If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.

我该怎么做才能克服这个问题? 我使用的是javascript,必须提及的是,除了真正需要的内容之外,我不想向扩展名添加任何权限。

感谢您的任何帮助。

评论