usescript in iframe

This commit is contained in:
Gabe Yuan
2023-08-26 11:43:00 +08:00
parent 19c9335527
commit 3bf0cb2485
3 changed files with 29 additions and 10 deletions

7
src/libs/iframe.js Normal file
View File

@@ -0,0 +1,7 @@
export const isIframe = window.self !== window.top;
export const sendIframeMsg = (action, args) => {
document.querySelectorAll("iframe").forEach((iframe) => {
iframe.contentWindow.postMessage({ action, args }, "*");
});
};