forked from alice0775/userChrome.js
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcloseBlankTabOnCloseGreasemonkeyInstall.uc.js
More file actions
43 lines (43 loc) · 2.03 KB
/
closeBlankTabOnCloseGreasemonkeyInstall.uc.js
File metadata and controls
43 lines (43 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
// ==UserScript==
// @name closeBlankTabOnCloseGreasemonkeyInstall.uc.js
// @namespace http://space.geocities.yahoo.co.jp/gl/alice0775
// @description ダウンロードをした際に、空白のタブを自動で閉じる
// @include chrome://greasemonkey/content/install.xul
// @author Alice0775
// @compatibility 4.0b8pre
// @version 2012/01/31 11:00 by Alice0775 12.0a1 about:newtab
// @version 2010/10/12 11:00 by Alice0775 4.0b8pre
// @version 2009/04/29 00:00 空白タブを削除する前にもう一度チェック
// ==/UserScript==
// @Note
// @version 2007/07/26 03:00
(function() {
//ブラウザ
const WINMAN = Components.classes['@mozilla.org/appshell/window-mediator;1']
.getService(Components.interfaces.nsIWindowMediator);
if('tablib' in WINMAN.getMostRecentWindow(null)) return;
function closeBlankTabOnCloseGreasemonkeyInstall(event){
//ブラウザ
var wm = Components.classes["@mozilla.org/appshell/window-mediator;1"]
.getService(Components.interfaces.nsIWindowMediator);
var browserWindow = wm.getMostRecentWindow("navigator:browser");
var tab = browserWindow.getBrowser().mTabs;
var max = tab.length;
if(max <= 1) return;
for(var i = max -1 ;i > -1 ; i--) {
var aTab = tab[i];
if ( aTab.hasAttribute('busy')
|| aTab.linkedBrowser.docShell.busyFlags
|| aTab.linkedBrowser.docShell.restoringDocument
|| !aTab.linkedBrowser.webNavigation.currentURI
|| ("isBlankPageURL" in window ? !isBlankPageURL(aTab.linkedBrowser.currentURI.spec) : aTab.linkedBrowser.currentURI.spec != "about:blank")
|| aTab.getAttribute('ontap') == 'true') {
continue;
}
aTab.ownerDocument.defaultView.gBrowser.removeTab(aTab);
return;
}
window.removeEventListener('unload',function(event){closeBlankTabOnCloseGreasemonkeyInstall(event);},false);
}
window.addEventListener('unload',function(event){closeBlankTabOnCloseGreasemonkeyInstall(event);},false);
})();