diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2020-02-16 22:01:03 -0500 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-02-16 22:01:03 -0500 |
commit | 2ace8d4ffa89d07a4fb07a410134054a1bccc431 (patch) | |
tree | 2da9c4e17b77ce0bf2ba8338e3fe301636667ffb /ext/bg/js/backend.js | |
parent | 1c6ed1d2866d9912b3b65d9e5addf710a6f26b38 (diff) | |
parent | ae4ee9ddee0b791c1039595250db6106e66709fa (diff) |
Merge pull request #367 from toasted-nutbread/defer-content-script-css-injection
Defer content script css injection
Diffstat (limited to 'ext/bg/js/backend.js')
-rw-r--r-- | ext/bg/js/backend.js | 25 |
1 files changed, 18 insertions, 7 deletions
diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index d1a34f82..458ea483 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -499,19 +499,30 @@ class Backend { return Promise.resolve({frameId}); } - _onApiInjectStylesheet({css}, sender) { + _onApiInjectStylesheet({type, value}, sender) { if (!sender.tab) { return Promise.reject(new Error('Invalid tab')); } const tabId = sender.tab.id; const frameId = sender.frameId; - const details = { - code: css, - runAt: 'document_start', - cssOrigin: 'user', - allFrames: false - }; + const details = ( + type === 'file' ? + { + file: value, + runAt: 'document_start', + cssOrigin: 'author', + allFrames: false, + matchAboutBlank: true + } : + { + code: value, + runAt: 'document_start', + cssOrigin: 'user', + allFrames: false, + matchAboutBlank: true + } + ); if (typeof frameId === 'number') { details.frameId = frameId; } |