Skip to content

Commit

Permalink
Fix removeUnintentionalBlank option (#36, #38, #43)
Browse files Browse the repository at this point in the history
  • Loading branch information
ithinc committed Mar 20, 2014
1 parent 0fa793c commit 8402398
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
34 changes: 31 additions & 3 deletions chrome/content/tabutils.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,12 +586,40 @@ tabutils._tabOpeningOptions = function() {
&& aStatus == 0
&& TU_getPref("extensions.tabutils.removeUnintentionalBlank", true)) {
let win = aWebProgress.DOMWindow;
win._closeTimer = win.setTimeout(function(self) {
self.mTabBrowser.isBlankTab(self.mTab) && self.mTabBrowser.removeTab(self.mTab);
}, 250, this);
win._closeTimer = win.setTimeout(function() {
this.mTabBrowser.isBlankTab(this.mTab) && this.mTabBrowser.removeTab(this.mTab);
}.bind(this), 750);
}
});

let tmp = {};
Cu.import("resource://gre/modules/DownloadLastDir.jsm", tmp);

if (tmp.DownloadLastDir && // Bug 722995 [Fx19]
tmp.DownloadLastDir.prototype.getFileAsync && // Bug 854299 [Fx23]
tmp.DownloadLastDir.prototype.getFileAsync.name != "TU_getFileAsync")
tmp.DownloadLastDir.prototype.getFileAsync = (function() {
let getFileAsync = tmp.DownloadLastDir.prototype.getFileAsync;
return function TU_getFileAsync(aURI, aCallback) {
let win = this.window;
if (win._closeTimer) {
win.clearTimeout(win._closeTimer);
win._closeTimer = null;

aCallback = (function() {
let lastDirCallback = aCallback;
return function TU_LastDirCallback(lastDir) {
lastDirCallback(lastDir);
if (!win.closed) {
win.setTimeout(win.close, 250);
}
};
})();
}
getFileAsync.apply(this, arguments);
};
})();

//在当前标签页的右侧打开新标签页
//连续打开后台标签时保持原有顺序
TU_hookCode("gBrowser.addTab",
Expand Down
3 changes: 2 additions & 1 deletion chrome/content/unknownContentType.xul
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
if (win && win._closeTimer) {
win.clearTimeout(win._closeTimer);
window.addEventListener("unload", function() {
win && win.setTimeout(function() {this.close();}, 250);
if (win._closeTimer && !win.closed)
win._closeTimer = win.setTimeout(win.close, 250);
}, false);
}
]]>
Expand Down

0 comments on commit 8402398

Please sign in to comment.