Add: styleViaAPI updateCount
This commit is contained in:
parent
39d21c3d29
commit
ff3bf6f52d
|
@ -1,4 +1,4 @@
|
||||||
/* global API_METHODS styleManager CHROME prefs */
|
/* global API_METHODS styleManager CHROME prefs updateIconBadge */
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
API_METHODS.styleViaAPI = !CHROME && (() => {
|
API_METHODS.styleViaAPI = !CHROME && (() => {
|
||||||
|
@ -9,6 +9,7 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
|
||||||
styleAdded,
|
styleAdded,
|
||||||
styleReplaceAll,
|
styleReplaceAll,
|
||||||
prefChanged,
|
prefChanged,
|
||||||
|
updateCount,
|
||||||
};
|
};
|
||||||
const NOP = Promise.resolve(new Error('NOP'));
|
const NOP = Promise.resolve(new Error('NOP'));
|
||||||
const onError = () => {};
|
const onError = () => {};
|
||||||
|
@ -30,6 +31,14 @@ API_METHODS.styleViaAPI = !CHROME && (() => {
|
||||||
.then(maybeToggleObserver);
|
.then(maybeToggleObserver);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
function updateCount(request, {tab, frameId}) {
|
||||||
|
if (frameId) {
|
||||||
|
throw new Error('we do not count styles for frames');
|
||||||
|
}
|
||||||
|
const {frameStyles} = getCachedData(tab.id, frameId);
|
||||||
|
updateIconBadge(tab.id, Object.keys(frameStyles).length);
|
||||||
|
}
|
||||||
|
|
||||||
function styleApply({id = null, ignoreUrlCheck = false}, {tab, frameId, url}) {
|
function styleApply({id = null, ignoreUrlCheck = false}, {tab, frameId, url}) {
|
||||||
if (prefs.get('disableAll')) {
|
if (prefs.get('disableAll')) {
|
||||||
return NOP;
|
return NOP;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user