-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathts.js
51 lines (51 loc) · 1.79 KB
/
ts.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
chrome.runtime.onInstalled.addListener(function () {
chrome.storage.local.set({ size: 'maximized' }, function () {
console.log("TabSplit successfully installed");
});
});
chrome.runtime.onStartup.addListener(function () {
chrome.windows.getCurrent({}, function (window) {
chrome.storage.local.get(['size'], function (result) {
if (typeof result.size == 'undefined') {
result.size = 'maximized';
}
chrome.windows.update(window.id, { top: 0, left: 0 }, function (window) {
chrome.windows.update(window.id, { state: result.size }, function (window) {
chrome.windows.getAll(null, function (w) {
finwin = w[w.length - 1].id;
offset = 1 + w[w.length - 1].width
chrome.tabs.query({ windowId: finwin }, function (tabs) {
if (tabs.length > 1) {
cnt = 1;
while (cnt < tabs.length) {
chrome.windows.create({ tabId: tabs[cnt].id, left: offset, top: 0 }, function (window) {
if(chrome.runtime.lastError){
console.warn("No more monitors available, adding tab to last window");
}
if (window) {
chrome.windows.update(window.id, { state: result.size }, function (w) { });
} else {
chrome.windows.getAll(null, function (w) {
chrome.tabs.query({ windowId: w[0].id }, function (tabs) {
for (i = 1; i < tabs.length; i++) {
chrome.tabs.move(tabs[i].id, { index: -1, windowId: finwin }, function () {
});
}
});
});
}
});
offset += tabs[cnt].width;
chrome.windows.getAll(null, function (w) {
finwin = w[w.length - 1].id;
});
cnt++;
};
};
});
});
});
});
});
});
});