Chrome 扩展具有更高的权限,可以直接访问不同源的资源,而不受同源策略的限制案例
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === "fetchAccounts") {
fetch('https://****.asia/')
.then(response => response.text())
.then(html => sendResponse({html: html}))
.catch(error => sendResponse({error: error.toString()}));
return true; // 保持消息通道开放
}
});