Skip to content

Commit a13b841

Browse files
committed
fix(work codes): run in iframes again
1 parent 5f53627 commit a13b841

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

src/mb_work_code_toolbox/index.ts

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import { GMdeleteValue, GMgetValue, GMinfo, GMsetValue } from '@lib/compat';
22
import { difference, groupBy, intersect } from '@lib/util/array';
33
import { logFailure } from '@lib/util/async';
4+
import { onWindowLoaded } from '@lib/util/dom';
45

56
import { agencyNameToID, validateCode, VERSION as CODES_VERSION } from './identifiers';
67
import { validateCodes } from './validate';
@@ -548,9 +549,13 @@ function handleMB(): void {
548549
// FIXME: We should check the changes in more detail before querying.
549550
const workForms: Array<[HTMLFormElement, boolean]> = [...document.querySelectorAll<HTMLFormElement>(editWorkFormQuery)].map((f) => [f, false]);
550551
document.querySelectorAll('iframe').forEach((iframe) => {
551-
iframe.contentWindow?.document
552-
.querySelectorAll<HTMLFormElement>('editWorkFormQuery')
553-
.forEach((form) => workForms.push([form, true]));
552+
if (!iframe.contentWindow) return;
553+
554+
onWindowLoaded(() => {
555+
iframe.contentWindow!.document
556+
.querySelectorAll<HTMLFormElement>(editWorkFormQuery)
557+
.forEach((form) => workForms.push([form, true]));
558+
}, iframe.contentWindow);
554559
});
555560

556561
workForms

0 commit comments

Comments
 (0)