Skip to content

Commit 7ffd7f7

Browse files
committed
Mitigate x-load protection affecting file:// documents load times (issue #455, thanks Meludall for patch).
1 parent 95c4abc commit 7ffd7f7

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/content/eventsHook.js

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -170,15 +170,18 @@ if (location.protocol == "file:") {
170170
};
171171

172172
const watch = watching => {
173+
if (!(watching instanceof Element)) {
174+
return false;
175+
}
173176
checkSrc(watching);
174177
if (watchList.has(watching)) {
175178
return;
176179
}
177-
observer.observe(watching, mutOpts);
178180
watchList.add(watching);
179181
for (const eventType of EVENTS) {
180182
watching.addEventListener(eventType, suppress, true);
181183
}
184+
return true;
182185
};
183186

184187
const mutOpts = {
@@ -193,8 +196,9 @@ if (location.protocol == "file:") {
193196
case "childList":
194197
[...r.addedNodes].forEach(watch);
195198
[...r.removedNodes].forEach(removed => {
196-
watch(removed);
197-
observer.observe(removed, mutOpts);
199+
if (watch(removed)) {
200+
observer.observe(removed, mutOpts);
201+
}
198202
});
199203
break;
200204
case "attributes":

0 commit comments

Comments
 (0)