This commit is contained in:
gorhill 2017-09-02 18:27:03 -04:00
parent 937e8a048d
commit 867eeebc19
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
1 changed files with 29 additions and 13 deletions

View File

@ -47,6 +47,22 @@ var noopFunc = function(){};
/******************************************************************************/
if (
typeof browser === 'object' &&
browser !== null &&
browser.runtime instanceof Object &&
typeof browser.runtime.getBrowserInfo === 'function'
) {
browser.runtime.getBrowserInfo().then(function(info) {
vAPI.supportsUserStylesheets =
info.name === 'Firefox' &&
parseInt(info.version, 10) > 52;
});
}
/******************************************************************************/
vAPI.app = {
name: manifest.name,
version: manifest.version
@ -807,22 +823,22 @@ vAPI.messaging.onPortMessage = (function() {
if ( !tabId ) { return; }
switch ( msg.what ) {
case 'userCSS':
var details = {
code: undefined,
frameId: sender.frameId,
matchAboutBlank: true
};
if ( vAPI.supportsUserStylesheets === true ) {
details.cssOrigin = 'user';
}
if ( msg.toRemove ) {
chrome.tabs.removeCSS(tabId, {
code: msg.toRemove,
cssOrigin: 'user',
frameId: sender.frameId,
matchAboutBlank: true
});
details.code = msg.toRemove;
chrome.tabs.removeCSS(tabId, details);
}
if ( msg.toAdd ) {
chrome.tabs.insertCSS(tabId, {
code: msg.toAdd,
cssOrigin: 'user',
frameId: sender.frameId,
matchAboutBlank: true,
runAt: 'document_start'
});
details.code = msg.toAdd;
details.runAt = 'document_start';
chrome.tabs.insertCSS(tabId, details);
}
break;
}