chrome.webNavigation.getAllFrames({ tabId: sender.tab.id }, async (frames) => {
const frame = frames.find((frame) => frame.url === data.pageUrl);
if (frame) {
await chrome.scripting.executeScript({
target: {
tabId: sender.tab.id,
documentIds: [frame.documentId],
// frameIds: [ frame.frameId ],
},
world: 'MAIN',
injectImmediately: true,
func: () => {
console.log('location.href', location.href, window.localStorage);
window.localStorage.clear();
},
});
sendResponse({ success: true, data: 'clear storage success' });
}
});
}