mirror of https://github.com/gorhill/uBlock.git
Firefox: vAPI.tabs.onNavigation() for about: pages
This commit is contained in:
parent
3d0eb2f928
commit
d24263aa17
|
@ -252,19 +252,6 @@ vAPI.storage = {
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var windowWatcher = {
|
var windowWatcher = {
|
||||||
onTabClose: function(e) {
|
|
||||||
var tabId = vAPI.tabs.getTabId(e.target);
|
|
||||||
vAPI.tabs.onClosed(tabId);
|
|
||||||
delete vAPI.toolbarButton.tabs[tabId];
|
|
||||||
},
|
|
||||||
|
|
||||||
onTabSelect: function(e) {
|
|
||||||
vAPI.setIcon(
|
|
||||||
vAPI.tabs.getTabId(e.target),
|
|
||||||
e.target.ownerDocument.defaultView
|
|
||||||
);
|
|
||||||
},
|
|
||||||
|
|
||||||
onReady: function(e) {
|
onReady: function(e) {
|
||||||
if ( e ) {
|
if ( e ) {
|
||||||
this.removeEventListener(e.type, windowWatcher.onReady);
|
this.removeEventListener(e.type, windowWatcher.onReady);
|
||||||
|
@ -282,9 +269,9 @@ var windowWatcher = {
|
||||||
|
|
||||||
var tC = this.gBrowser.tabContainer;
|
var tC = this.gBrowser.tabContainer;
|
||||||
|
|
||||||
this.gBrowser.addTabsProgressListener(tabsProgressListener);
|
this.gBrowser.addTabsProgressListener(tabWatcher);
|
||||||
tC.addEventListener('TabClose', windowWatcher.onTabClose);
|
tC.addEventListener('TabClose', tabWatcher.onTabClose);
|
||||||
tC.addEventListener('TabSelect', windowWatcher.onTabSelect);
|
tC.addEventListener('TabSelect', tabWatcher.onTabSelect);
|
||||||
|
|
||||||
vAPI.contextMenu.register(this.document);
|
vAPI.contextMenu.register(this.document);
|
||||||
|
|
||||||
|
@ -300,7 +287,30 @@ var windowWatcher = {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
var tabsProgressListener = {
|
var tabWatcher = {
|
||||||
|
onTabClose: function({target: tab}) {
|
||||||
|
var tabId = vAPI.tabs.getTabId(tab);
|
||||||
|
vAPI.tabs.onClosed(tabId);
|
||||||
|
delete vAPI.toolbarButton.tabs[tabId];
|
||||||
|
},
|
||||||
|
|
||||||
|
onTabSelect: function({target: tab}) {
|
||||||
|
var URI = tab.linkedBrowser.currentURI;
|
||||||
|
var aboutPath = URI.schemeIs('about') && URI.path;
|
||||||
|
var tabId = vAPI.tabs.getTabId(tab);
|
||||||
|
|
||||||
|
if ( !aboutPath || (aboutPath !== 'blank' && aboutPath !== 'newtab') ) {
|
||||||
|
vAPI.setIcon(tabId, tab.ownerDocument.defaultView);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
vAPI.tabs.onNavigation({
|
||||||
|
frameId: 0,
|
||||||
|
tabId: tabId,
|
||||||
|
url: URI.asciiSpec
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
onLocationChange: function(browser, webProgress, request, location, flags) {
|
onLocationChange: function(browser, webProgress, request, location, flags) {
|
||||||
if ( !webProgress.isTopLevel ) {
|
if ( !webProgress.isTopLevel ) {
|
||||||
return;
|
return;
|
||||||
|
@ -330,10 +340,6 @@ var tabsProgressListener = {
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.tabs = {};
|
|
||||||
|
|
||||||
/******************************************************************************/
|
|
||||||
|
|
||||||
vAPI.isNoTabId = function(tabId) {
|
vAPI.isNoTabId = function(tabId) {
|
||||||
return tabId.toString() === '-1';
|
return tabId.toString() === '-1';
|
||||||
};
|
};
|
||||||
|
@ -342,10 +348,14 @@ vAPI.noTabId = '-1';
|
||||||
|
|
||||||
/******************************************************************************/
|
/******************************************************************************/
|
||||||
|
|
||||||
|
vAPI.tabs = {};
|
||||||
|
|
||||||
|
/******************************************************************************/
|
||||||
|
|
||||||
vAPI.tabs.registerListeners = function() {
|
vAPI.tabs.registerListeners = function() {
|
||||||
// onNavigation and onUpdated handled with tabsProgressListener
|
// onNavigation and onUpdated handled with tabWatcher.onLocationChange
|
||||||
// onClosed - handled in windowWatcher.onTabClose
|
// onClosed - handled in tabWatcher.onTabClose
|
||||||
// onPopup ?
|
// onPopup - handled in httpObserver.handlePopup
|
||||||
|
|
||||||
for ( var win of this.getWindows() ) {
|
for ( var win of this.getWindows() ) {
|
||||||
windowWatcher.onReady.call(win);
|
windowWatcher.onReady.call(win);
|
||||||
|
@ -360,11 +370,11 @@ vAPI.tabs.registerListeners = function() {
|
||||||
vAPI.contextMenu.unregister(win.document);
|
vAPI.contextMenu.unregister(win.document);
|
||||||
|
|
||||||
win.removeEventListener('DOMContentLoaded', windowWatcher.onReady);
|
win.removeEventListener('DOMContentLoaded', windowWatcher.onReady);
|
||||||
win.gBrowser.removeTabsProgressListener(tabsProgressListener);
|
win.gBrowser.removeTabsProgressListener(tabWatcher);
|
||||||
|
|
||||||
var tC = win.gBrowser.tabContainer;
|
var tC = win.gBrowser.tabContainer;
|
||||||
tC.removeEventListener('TabClose', windowWatcher.onTabClose);
|
tC.removeEventListener('TabClose', tabWatcher.onTabClose);
|
||||||
tC.removeEventListener('TabSelect', windowWatcher.onTabSelect);
|
tC.removeEventListener('TabSelect', tabWatcher.onTabSelect);
|
||||||
|
|
||||||
// close extension tabs
|
// close extension tabs
|
||||||
for ( var tab of win.gBrowser.tabs ) {
|
for ( var tab of win.gBrowser.tabs ) {
|
||||||
|
@ -636,10 +646,7 @@ vAPI.setIcon = function(tabId, iconStatus, badge) {
|
||||||
if ( tabId === undefined ) {
|
if ( tabId === undefined ) {
|
||||||
tabId = curTabId;
|
tabId = curTabId;
|
||||||
} else if ( badge !== undefined ) {
|
} else if ( badge !== undefined ) {
|
||||||
tb.tabs[tabId] = {
|
tb.tabs[tabId] = { badge: badge, img: iconStatus === 'on' };
|
||||||
badge: badge,
|
|
||||||
img: iconStatus === 'on'
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( tabId !== curTabId ) {
|
if ( tabId !== curTabId ) {
|
||||||
|
|
Loading…
Reference in New Issue