/
tabgroup-elscreenlike.ks.js
181 lines (151 loc) · 5.5 KB
/
tabgroup-elscreenlike.ks.js
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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
var PLUGIN_INFO =
<KeySnailPlugin>
<name>TabGroup ElscreenLike</name>
<name lang="ja">TabGruop ElscreenLike</name>
<description>you can use TabGroupManager like elscreen</description>
<description lang="ja">タブグループマネージャをelscreenのように使用することが出来ます。</description>
<version>0.0.3</version>
<updateURL>http://github.com/shiba-yu36/keysnail-plugin/raw/master/tabgroup-elscreenlike.ks.js</updateURL>
<iconURL></iconURL>
<author mail="shibayu36@gmail.com" homepage="http://d.hatena.ne.jp/shiba_yu36/">shiba_yu36</author>
<license>The MIT License</license>
<license lang="ja">MIT ライセンス</license>
<minVersion>1.0</minVersion>
<include>main</include>
<provides>
<ext>tabgroup-previous</ext>
<ext>tabgroup-next</ext>
<ext>tabgroup-goto</ext>
<ext>tabgroup-create</ext>
<ext>tabgroup-close</ext>
<ext>tabgroup-group-nickname</ext>
<ext>tabgroup-goto-last-selected</ext>
</provides>
<detail lang="ja"><![CDATA[
=== 使い方 ===
このプラグインをインストールすることにより、firefoxのaddonであるタブグループマネージャをelscreenのように使うことができるようになります。
下のリンクからタブグループマネージャをインストールしてから利用してください。
https://addons.mozilla.org/ja/firefox/addon/10254/
]]></detail>
</KeySnailPlugin>;
// ChangeLog : {{{
//
// ==== 0.0.3 (2010 12/30) ====
// fix bug in content focus
//
// ==== 0.0.2 (2010 12/30) ====
// タブグループを閉じるときはダイアログを表示するように
//
// ==== 0.0.1 ====
// リリース
//
// }}}
ext.add("tabgroup-previous", selectPreviousGroup, M({
ja : "左のグループを選択",
en : "select left group"
}));
ext.add("tabgroup-next", selectNextGroup, M({
ja : "右のグループを選択",
en : "select right group"
}));
ext.add("tabgroup-goto", selectNthGroup, M({
ja : "指定した番号のグループへ移動",
en : "select group of entered number"
}));
ext.add("tabgroup-create", openNewGroup, M({
ja : "新しいグループを開く",
en : "open new group"
}));
ext.add("tabgroup-close", closeCurrentGroup, M({
ja : "現在のグループを閉じる",
en : "close current group"
}));
ext.add("tabgroup-group-nickname", renameCurrentGroup, M({
ja : "現在のグループの名前を変更する",
en : "rename current group"
}));
ext.add("tabgroup-goto-last-selected", gotoLastSelectedGroup, M({
ja : "直前のグループに移動",
en : "rename current group"
}));
let last_selected_group_index;
function selectPreviousGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
saveCurrentGroupIndex();
TabGroupsManager.allGroups.selectNthGroup(getLeftGroupIndex());
}
function selectNextGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
saveCurrentGroupIndex();
TabGroupsManager.allGroups.selectNthGroup(getRightGroupIndex());
}
function selectNthGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
prompt.read("goto group number: ", function (group_index) {
if (!group_index.match("\\d+"))
return;
saveCurrentGroupIndex();
TabGroupsManager.allGroups.selectNthGroup(group_index);
});
}
function openNewGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
saveCurrentGroupIndex();
TabGroupsManager.command.OpenNewGroupActive();
}
function closeCurrentGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
if (window.confirm(L("このグループを閉じてもよいですか?"))) {
TabGroupsManager.command.CloseActiveGroup();
}
}
function renameCurrentGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
var current_group = TabGroupsManager.allGroups.selectedGroup;
prompt.read("set group title to: ", function (group_name) {
current_group.renameByText(group_name);
});
}
function gotoLastSelectedGroup () {
if (KeySnail.windowType != "navigator:browser" || !("TabGroupsManager" in window))
return;
let current_index = TabGroupsManager.allGroups.groupbar.selectedIndex;
let last_index = getLastSelectedGroup();
TabGroupsManager.command.SelectNthGroup(last_index);
setLastSelectedGroup(current_index);
}
function saveCurrentGroupIndex () {
last_selected_group_index = TabGroupsManager.allGroups.groupbar.selectedIndex;
}
function getRightGroupIndex () {
var group_count = TabGroupsManager.allGroups.groupbar.itemCount;
var current_index = TabGroupsManager.allGroups.groupbar.selectedIndex;
if (current_index == group_count - 1) {
return 0;
}
else {
return current_index + 1;
}
}
function getLeftGroupIndex () {
var group_count = TabGroupsManager.allGroups.groupbar.itemCount;
var current_index = TabGroupsManager.allGroups.groupbar.selectedIndex;
if (current_index == 0) {
return group_count - 1;
}
else {
return current_index - 1;
}
}
function getLastSelectedGroup() {
return last_selected_group_index;
}
function setLastSelectedGroup(index) {
last_selected_group_index = index;
}