From 28ef5572ba64bc3a5c4e28082d610ed12a43b380 Mon Sep 17 00:00:00 2001 From: tophf Date: Thu, 8 Mar 2018 19:19:23 +0300 Subject: [PATCH] FF: ensure styles are applied to about:blank iframes fixes #215 --- background/background.js | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/background/background.js b/background/background.js index 5b459a20..cbd672ce 100644 --- a/background/background.js +++ b/background/background.js @@ -64,6 +64,12 @@ chrome.runtime.onMessage.addListener(onRuntimeMessage); {hostSuffix: '.githubusercontent.com', urlSuffix: '.user.styl'}, ] }); + // FF misses some about:blank iframes so we inject our content script explicitly + chrome.webNavigation.onDOMContentLoaded.addListener(webNavIframeHelperFF, { + url: [ + {urlEquals: 'about:blank'}, + ] + }); } } @@ -330,6 +336,20 @@ function webNavUsercssInstallerFF(data) { } +function webNavIframeHelperFF({tabId, frameId}) { + if (!frameId) return; + sendMessage({method: 'ping', tabId, frameId}, pong => { + ignoreChromeError(); + if (pong) return; + chrome.tabs.executeScript(tabId, { + frameId, + file: '/content/apply.js', + matchAboutBlank: true, + }, ignoreChromeError); + }); +} + + function updateIcon({tab, styles}) { if (tab.id < 0) { return;