From 7d54d908a2dceec556d5df03560eff991844e1da Mon Sep 17 00:00:00 2001 From: tophf Date: Fri, 30 Jul 2021 16:53:15 +0300 Subject: [PATCH] `source` may be null --- content/install-hook-userstylesworld.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/content/install-hook-userstylesworld.js b/content/install-hook-userstylesworld.js index 4552f75c..66801e12 100644 --- a/content/install-hook-userstylesworld.js +++ b/content/install-hook-userstylesworld.js @@ -29,9 +29,9 @@ }, }); - window.addEventListener('message', ({data, source}) => { - // Accepting events only from this page. - if (data && source === window) { + window.addEventListener('message', ({data, source, origin}) => { + // Some browser don't reveal `source` to extensions e.g. Firefox + if (data && (source ? source === window : origin === ORIGIN)) { const fn = HANDLERS[data.type]; if (fn) fn(data); }