mirror of https://github.com/gorhill/uBlock.git
as per last commit, local messaging listener not needed anymore
This commit is contained in:
parent
aeba71790f
commit
8305b8990a
|
@ -435,16 +435,8 @@ var currentTabId = function() {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var cancelPollTimer = function() {
|
var fetchDOMAsync = (function() {
|
||||||
if ( pollTimer !== null ) {
|
var onFetched = function(response) {
|
||||||
clearTimeout(pollTimer);
|
|
||||||
pollTimer = null;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
var onDOMFetched = function(response) {
|
|
||||||
if ( !response || currentTabId() !== inspectedTabId ) {
|
if ( !response || currentTabId() !== inspectedTabId ) {
|
||||||
shutdownInspector();
|
shutdownInspector();
|
||||||
injectInspectorAsync(250);
|
injectInspectorAsync(250);
|
||||||
|
@ -473,9 +465,8 @@ var onDOMFetched = function(response) {
|
||||||
fetchDOMAsync();
|
fetchDOMAsync();
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
var onTimeout = function() {
|
||||||
|
pollTimer = null;
|
||||||
var fetchDOM = function() {
|
|
||||||
messager.sendTo(
|
messager.sendTo(
|
||||||
{
|
{
|
||||||
what: 'domLayout',
|
what: 'domLayout',
|
||||||
|
@ -483,21 +474,17 @@ var fetchDOM = function() {
|
||||||
},
|
},
|
||||||
inspectedTabId,
|
inspectedTabId,
|
||||||
'dom-inspector.js',
|
'dom-inspector.js',
|
||||||
onDOMFetched
|
onFetched
|
||||||
);
|
);
|
||||||
};
|
};
|
||||||
|
|
||||||
/******************************************************************************/
|
// Poll for DOM layout data every ~2 seconds at most
|
||||||
|
return function(delay) {
|
||||||
var fetchDOMAsync = function(delay) {
|
if ( pollTimer === null ) {
|
||||||
if ( pollTimer !== null ) {
|
pollTimer = vAPI.setTimeout(onTimeout, delay || 2003);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
pollTimer = vAPI.setTimeout(function() {
|
|
||||||
pollTimer = null;
|
|
||||||
fetchDOM();
|
|
||||||
}, delay || 2003);
|
|
||||||
};
|
};
|
||||||
|
})();
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
@ -540,7 +527,10 @@ var shutdownInspector = function() {
|
||||||
messager.sendTo({ what: 'shutdown' }, inspectedTabId, 'dom-inspector.js');
|
messager.sendTo({ what: 'shutdown' }, inspectedTabId, 'dom-inspector.js');
|
||||||
}
|
}
|
||||||
logger.removeAllChildren(domTree);
|
logger.removeAllChildren(domTree);
|
||||||
cancelPollTimer();
|
if ( pollTimer !== null ) {
|
||||||
|
clearTimeout(pollTimer);
|
||||||
|
pollTimer = null;
|
||||||
|
}
|
||||||
inspectedTabId = '';
|
inspectedTabId = '';
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -581,20 +571,6 @@ var revert = function() {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var onMessage = function(request) {
|
|
||||||
switch ( request.what ) {
|
|
||||||
case 'domLayout':
|
|
||||||
cancelPollTimer();
|
|
||||||
onDOMFetched(request);
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
var toggleOn = function() {
|
var toggleOn = function() {
|
||||||
window.addEventListener('beforeunload', toggleOff);
|
window.addEventListener('beforeunload', toggleOff);
|
||||||
tabSelector.addEventListener('change', onTabIdChanged);
|
tabSelector.addEventListener('change', onTabIdChanged);
|
||||||
|
@ -604,7 +580,6 @@ var toggleOn = function() {
|
||||||
uDom.nodeFromSelector('#domInspector .permatoolbar .revert').addEventListener('click', revert);
|
uDom.nodeFromSelector('#domInspector .permatoolbar .revert').addEventListener('click', revert);
|
||||||
uDom.nodeFromSelector('#domInspector .permatoolbar .commit').addEventListener('click', startDialog);
|
uDom.nodeFromSelector('#domInspector .permatoolbar .commit').addEventListener('click', startDialog);
|
||||||
inspector.classList.add('enabled');
|
inspector.classList.add('enabled');
|
||||||
messager.addListener(onMessage);
|
|
||||||
injectInspector();
|
injectInspector();
|
||||||
// Adjust tree view for toolbar height
|
// Adjust tree view for toolbar height
|
||||||
domTree.style.setProperty(
|
domTree.style.setProperty(
|
||||||
|
@ -616,8 +591,6 @@ var toggleOn = function() {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var toggleOff = function() {
|
var toggleOff = function() {
|
||||||
messager.removeListener(onMessage);
|
|
||||||
cancelPollTimer();
|
|
||||||
shutdownInspector();
|
shutdownInspector();
|
||||||
window.removeEventListener('beforeunload', toggleOff);
|
window.removeEventListener('beforeunload', toggleOff);
|
||||||
tabSelector.removeEventListener('change', onTabIdChanged);
|
tabSelector.removeEventListener('change', onTabIdChanged);
|
||||||
|
|
Loading…
Reference in New Issue