mirror of
https://github.com/gorhill/uBlock.git
synced 2024-09-01 16:49:39 +02:00
This commit is contained in:
parent
9e7fbb857b
commit
d7ff5a523e
@ -621,7 +621,6 @@ vAPI.storage = (function() {
|
|||||||
// This must be executed/setup early.
|
// This must be executed/setup early.
|
||||||
|
|
||||||
var winWatcher = (function() {
|
var winWatcher = (function() {
|
||||||
var chromeWindowType = vAPI.thunderbird ? 'mail:3pane' : 'navigator:browser';
|
|
||||||
var windowToIdMap = new Map();
|
var windowToIdMap = new Map();
|
||||||
var windowIdGenerator = 1;
|
var windowIdGenerator = 1;
|
||||||
var api = {
|
var api = {
|
||||||
@ -629,6 +628,24 @@ var winWatcher = (function() {
|
|||||||
onCloseWindow: null
|
onCloseWindow: null
|
||||||
};
|
};
|
||||||
|
|
||||||
|
// https://github.com/gorhill/uMatrix/issues/586
|
||||||
|
// This is necessary hack because on SeaMonkey 2.40, for unknown reasons
|
||||||
|
// private windows do not have the attribute `windowtype` set to
|
||||||
|
// `navigator:browser`. As a fallback, the code here will also test whether
|
||||||
|
// the id attribute is `main-window`.
|
||||||
|
api.toBrowserWindow = function(win) {
|
||||||
|
var docElement = win && win.document && win.document.documentElement;
|
||||||
|
if ( !docElement ) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
if ( vAPI.thunderbird ) {
|
||||||
|
return docElement.getAttribute('windowtype') === 'mail:3pane' ? win : null;
|
||||||
|
}
|
||||||
|
return docElement.getAttribute('windowtype') === 'navigator:browser' ||
|
||||||
|
docElement.getAttribute('id') === 'main-window' ?
|
||||||
|
win : null;
|
||||||
|
};
|
||||||
|
|
||||||
api.getWindows = function() {
|
api.getWindows = function() {
|
||||||
return windowToIdMap.keys();
|
return windowToIdMap.keys();
|
||||||
};
|
};
|
||||||
@ -638,7 +655,7 @@ var winWatcher = (function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
api.getCurrentWindow = function() {
|
api.getCurrentWindow = function() {
|
||||||
return Services.wm.getMostRecentWindow(chromeWindowType) || null;
|
return this.toBrowserWindow(Services.wm.getMostRecentWindow(null));
|
||||||
};
|
};
|
||||||
|
|
||||||
var addWindow = function(win) {
|
var addWindow = function(win) {
|
||||||
@ -1366,8 +1383,7 @@ var tabWatcher = (function() {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
var docElement = document.documentElement;
|
return winWatcher.toBrowserWindow(window) !== null;
|
||||||
return docElement && docElement.getAttribute('windowtype') === 'navigator:browser';
|
|
||||||
};
|
};
|
||||||
|
|
||||||
var onWindowLoad = function(win) {
|
var onWindowLoad = function(win) {
|
||||||
|
Loading…
Reference in New Issue
Block a user