Allow apiInjectStylesheet to inject a URL

This commit is contained in:
toasted-nutbread 2020-02-16 13:13:04 -05:00
parent 1c6ed1d286
commit 2c3f510010
3 changed files with 19 additions and 10 deletions

View File

@ -499,19 +499,28 @@ 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,
const details = (
type === 'file' ?
{
file: value,
runAt: 'document_start',
cssOrigin: 'author',
allFrames: false
} :
{
code: value,
runAt: 'document_start',
cssOrigin: 'user',
allFrames: false
};
}
);
if (typeof frameId === 'number') {
details.frameId = frameId;
}

View File

@ -167,7 +167,7 @@ class Popup {
} else {
if (!css) { return; }
try {
await apiInjectStylesheet(css);
await apiInjectStylesheet('code', css);
this._stylesheetInjectedViaApi = true;
} catch (e) {
// NOP

View File

@ -89,8 +89,8 @@ function apiFrameInformationGet() {
return _apiInvoke('frameInformationGet');
}
function apiInjectStylesheet(css) {
return _apiInvoke('injectStylesheet', {css});
function apiInjectStylesheet(type, value) {
return _apiInvoke('injectStylesheet', {type, value});
}
function apiGetEnvironmentInfo() {