From 25081c382eeecd887d0de8e2907b8b5c88635eb8 Mon Sep 17 00:00:00 2001 From: Infocatcher Date: Sun, 10 Nov 2013 01:54:22 +0400 Subject: [PATCH] Correctly reload styles, if opened only private windows in SeaMonkey (#116) --- bootstrap.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/bootstrap.js b/bootstrap.js index 97840ad..cfad89a 100644 --- a/bootstrap.js +++ b/bootstrap.js @@ -463,6 +463,20 @@ var windowsObserver = { } return windows; }, + getMostRecentBrowserWindow: function() { + var window = Services.wm.getMostRecentWindow("navigator:browser"); + if(window) + return window; + if(this.isSeaMonkey) { + var ws = Services.wm.getEnumerator(null); + while(ws.hasMoreElements()) { + window = ws.getNext(); + if(this.isTargetWindow(window)) + return window; + } + } + return null; + }, isTargetWindow: function(window) { // Note: we can't touch document.documentElement in not yet loaded window // (to check "windowtype"), see https://github.com/Infocatcher/Private_Tab/issues/61 @@ -3086,9 +3100,8 @@ var windowsObserver = { sss.unregisterSheet(this.cssURI, sss.USER_SHEET); }, reloadStyles: function(window) { - window = window - || Services.wm.getMostRecentWindow("navigator:browser") - || Services.wm.getMostRecentWindow("navigator:private"); // SeaMonkey >= 2.19a1 (2013-03-27) + if(!window) + window = this.getMostRecentBrowserWindow(); this.unloadStyles(); if(window) this.loadStyles(window);