diff options
author | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-09 21:56:47 -0500 |
---|---|---|
committer | toasted-nutbread <toasted-nutbread@users.noreply.github.com> | 2019-12-13 23:11:56 -0500 |
commit | f78671346696ddac23e9f858f567e5db065effec (patch) | |
tree | 0aa45d7de633bacb58041f5e03da43f96456c683 | |
parent | 01a343262702d2c8641c7a4f990d439f38b90cb0 (diff) |
Move apiInjectStylesheet implementation into Backend
-rw-r--r-- | ext/bg/js/api.js | 27 | ||||
-rw-r--r-- | ext/bg/js/backend.js | 27 |
2 files changed, 27 insertions, 27 deletions
diff --git a/ext/bg/js/api.js b/ext/bg/js/api.js index ff5c8abf..82166007 100644 --- a/ext/bg/js/api.js +++ b/ext/bg/js/api.js @@ -86,32 +86,7 @@ function apiFrameInformationGet(sender) { } function apiInjectStylesheet(css, 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 - }; - if (typeof frameId === 'number') { - details.frameId = frameId; - } - - return new Promise((resolve, reject) => { - chrome.tabs.insertCSS(tabId, details, () => { - const e = chrome.runtime.lastError; - if (e) { - reject(new Error(e.message)); - } else { - resolve(); - } - }); - }); + return utilBackend()._onApiInjectStylesheet({css}, sender); } async function apiGetEnvironmentInfo() { diff --git a/ext/bg/js/backend.js b/ext/bg/js/backend.js index 4b94d073..df021ea2 100644 --- a/ext/bg/js/backend.js +++ b/ext/bg/js/backend.js @@ -436,7 +436,32 @@ class Backend { } _onApiInjectStylesheet({css}, sender) { - return apiInjectStylesheet(css, 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 + }; + if (typeof frameId === 'number') { + details.frameId = frameId; + } + + return new Promise((resolve, reject) => { + chrome.tabs.insertCSS(tabId, details, () => { + const e = chrome.runtime.lastError; + if (e) { + reject(new Error(e.message)); + } else { + resolve(); + } + }); + }); } _onApiGetEnvironmentInfo() { |