mirror of
https://github.com/gorhill/uBlock.git
synced 2024-10-06 09:37:12 +02:00
fix #1856
This commit is contained in:
parent
2b8f960d32
commit
6bd356dd2c
@ -22,12 +22,12 @@
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
// Default handler
|
// Default handler
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -192,8 +192,6 @@ vAPI.messaging.setup(onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -356,30 +354,17 @@ var popupDataFromRequest = function(request, callback) {
|
|||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var getPopupDataLazy = function(tabId, callback) {
|
|
||||||
var r = {
|
|
||||||
hiddenElementCount: ''
|
|
||||||
};
|
|
||||||
var pageStore = µb.pageStoreFromTabId(tabId);
|
|
||||||
|
|
||||||
if ( !pageStore ) {
|
|
||||||
callback(r);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
µb.scriptlets.inject(tabId, 'cosmetic-survey', function() {
|
|
||||||
r.hiddenElementCount = pageStore.hiddenElementCount;
|
|
||||||
callback(r);
|
|
||||||
});
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
var onMessage = function(request, sender, callback) {
|
var onMessage = function(request, sender, callback) {
|
||||||
|
var pageStore;
|
||||||
|
|
||||||
// Async
|
// Async
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
case 'getPopupDataLazy':
|
case 'getPopupLazyData':
|
||||||
getPopupDataLazy(request.tabId, callback);
|
pageStore = µb.pageStoreFromTabId(request.tabId);
|
||||||
|
if ( pageStore !== null ) {
|
||||||
|
pageStore.hiddenElementCount = 0;
|
||||||
|
µb.scriptlets.injectDeep(request.tabId, 'cosmetic-survey');
|
||||||
|
}
|
||||||
return;
|
return;
|
||||||
|
|
||||||
case 'getPopupData':
|
case 'getPopupData':
|
||||||
@ -391,7 +376,6 @@ var onMessage = function(request, sender, callback) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
var pageStore;
|
|
||||||
var response;
|
var response;
|
||||||
|
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
@ -454,8 +438,6 @@ vAPI.messaging.listen('popupPanel', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -585,8 +567,6 @@ vAPI.messaging.listen('contentscript', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -665,8 +645,6 @@ vAPI.messaging.listen('elementPicker', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -727,8 +705,6 @@ vAPI.messaging.listen('cloudWidget', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -1031,8 +1007,6 @@ vAPI.messaging.listen('dashboard', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
@ -1146,8 +1120,6 @@ vAPI.messaging.listen('loggerUI', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onMessage = function(request, sender, callback) {
|
var onMessage = function(request, sender, callback) {
|
||||||
@ -1185,11 +1157,27 @@ vAPI.messaging.listen('documentBlocked', onMessage);
|
|||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var µb = µBlock;
|
var µb = µBlock;
|
||||||
|
var broadcastTimers = Object.create(null);
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
|
var cosmeticallyFilteredElementCountChanged = function(tabId) {
|
||||||
|
delete broadcastTimers[tabId + '-cosmeticallyFilteredElementCountChanged'];
|
||||||
|
|
||||||
|
var pageStore = µb.pageStoreFromTabId(tabId);
|
||||||
|
if ( pageStore === null ) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vAPI.messaging.broadcast({
|
||||||
|
what: 'cosmeticallyFilteredElementCountChanged',
|
||||||
|
tabId: tabId,
|
||||||
|
count: pageStore.hiddenElementCount
|
||||||
|
});
|
||||||
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
@ -1231,9 +1219,16 @@ var onMessage = function(request, sender, callback) {
|
|||||||
var response;
|
var response;
|
||||||
|
|
||||||
switch ( request.what ) {
|
switch ( request.what ) {
|
||||||
case 'liveCosmeticFilteringData':
|
case 'cosmeticallyFilteredElementCount':
|
||||||
if ( pageStore !== null ) {
|
if ( pageStore !== null && request.filteredElementCount ) {
|
||||||
pageStore.hiddenElementCount = request.filteredElementCount;
|
pageStore.hiddenElementCount += request.filteredElementCount;
|
||||||
|
var broadcastKey = tabId + '-cosmeticallyFilteredElementCountChanged';
|
||||||
|
if ( broadcastTimers[broadcastKey] === undefined ) {
|
||||||
|
broadcastTimers[broadcastKey] = vAPI.setTimeout(
|
||||||
|
cosmeticallyFilteredElementCountChanged.bind(null, tabId),
|
||||||
|
250
|
||||||
|
);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
@ -21,12 +21,12 @@
|
|||||||
|
|
||||||
/* global punycode, uDom */
|
/* global punycode, uDom */
|
||||||
|
|
||||||
|
'use strict';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
(function() {
|
(function() {
|
||||||
|
|
||||||
'use strict';
|
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
// Ensure the popup is properly sized as soon as possible. It is assume the DOM
|
// Ensure the popup is properly sized as soon as possible. It is assume the DOM
|
||||||
@ -507,23 +507,24 @@ var renderPopup = function() {
|
|||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var renderPopupLazy = function() {
|
var renderPopupLazy = function() {
|
||||||
var onDataReady = function(data) {
|
messaging.send('popupPanel', { what: 'getPopupLazyData', tabId: popupData.tabId });
|
||||||
if ( !data ) { return; }
|
};
|
||||||
var v = data.hiddenElementCount || '';
|
|
||||||
|
var onPopupMessage = function(data) {
|
||||||
|
if ( !data ) { return; }
|
||||||
|
if ( data.tabId !== popupData.tabId ) { return; }
|
||||||
|
|
||||||
|
switch ( data.what ) {
|
||||||
|
case 'cosmeticallyFilteredElementCountChanged':
|
||||||
|
var v = data.count || '';
|
||||||
uDom.nodeFromSelector('#no-cosmetic-filtering > span.badge')
|
uDom.nodeFromSelector('#no-cosmetic-filtering > span.badge')
|
||||||
.textContent = typeof v === 'number' ? v.toLocaleString() : v;
|
.textContent = typeof v === 'number' ? v.toLocaleString() : v;
|
||||||
};
|
break;
|
||||||
|
}
|
||||||
messaging.send(
|
|
||||||
'popupPanel',
|
|
||||||
{
|
|
||||||
what: 'getPopupDataLazy',
|
|
||||||
tabId: popupData.tabId
|
|
||||||
},
|
|
||||||
onDataReady
|
|
||||||
);
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
messaging.addChannelListener('popup', onPopupMessage);
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var toggleNetFilteringSwitch = function(ev) {
|
var toggleNetFilteringSwitch = function(ev) {
|
||||||
|
@ -39,7 +39,7 @@
|
|||||||
vAPI.messaging.send(
|
vAPI.messaging.send(
|
||||||
'scriptlets',
|
'scriptlets',
|
||||||
{
|
{
|
||||||
what: 'liveCosmeticFilteringData',
|
what: 'cosmeticallyFilteredElementCount',
|
||||||
pageURL: window.location.href,
|
pageURL: window.location.href,
|
||||||
filteredElementCount: xpr && xpr.numberValue || 0
|
filteredElementCount: xpr && xpr.numberValue || 0
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user