-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtabsets.js
156 lines (153 loc) · 4.28 KB
/
tabsets.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
/**
* Created by Timothy Tocci <timothytocci.com> on 2/16/2017.
*/
// google chrome internal skip names
let internal_titles = [
"Accessibility Internals",
"Application Cache",
"Apps",
"Blob Storage Internals",
"Bluetooth Internals",
"Bookmarks",
"chrome://cache",
"Settings",
"Chrome URLs",
"Components",
"chrome://conflicts",
"Crashes",
"Credits",
"Device Log",
"Devices",
"chrome://dino/",
"About discards",
"About DNS",
"Downloads",
"Extensions",
"chrome://flags",
"chrome://flash",
"GCM Internals",
"chrome://gpu",
"Settings",
"About Histograms",
"History",
"IndexedDB",
"Inspect with Chrome Developer Tools",
"Invalidations",
"Local State Debug Page",
"Media Engagement",
"Media Internals",
"chrome://nacl",
"chrome://net-internals/#events",
"chrome://network-error/",
"Network errors",
"New Tab",
"NTP Tiles Internals",
"Omnibox Debug Page",
"Password Manager Internals",
"Policies",
"Predictors",
"chrome://print",
"chrome://profiler",
"Quota Internals",
"Safe Browsing",
"chrome://serviceworker-internals",
"Settings",
"Signin Internals",
"Site Engagement",
"Suggestions",
"Supervised User Internals",
"Sync Internals",
"About System",
"taskscheduler-internals",
"Google Chrome Terms of Service",
"TopSites Thumbnails",
"chrome://tracing",
"Translate Internals",
"USB Internals",
"User Actions Debug Page",
"About Version",
"chrome://view-http-cache",
"WebRTC Internals",
"WebRTC logs",
"Create Tab Set"
];
$( document ).ready(function() {
$("#tabsetName")[0].value = getCurrentDateString();
$("#tabsetName")[0].select();
let objQueryInfo = {
windowType: "normal"
};
chrome.tabs.query(objQueryInfo, function(tabArray){
$("ul.openurllist").html(function(){
let rethtml = "";
$.each(tabArray, function(index,obj){
let boolUnchecked = false;
for(let title of internal_titles){
if(obj.title === title){
boolUnchecked = true;
}
}
if(boolUnchecked){
rethtml += `<li>
<input type="checkbox" class="openurl" name="${obj.title}" id="${obj.title}">
<label for="${obj.title}">${obj.title}</label>
</li>`
}else{
rethtml += `<li>
<input type="checkbox" class="openurl" name="${obj.title}" id="${obj.title}" checked>
<label for="${obj.title}">${obj.title}</label>
</li>`
}
});
return rethtml;
});
$("#btnSaveTabset").on("click",(evt)=>{
evt.preventDefault();
let tabset_data = {
name: $("#tabsetName")[0].value,
items: []
};
$(".openurl").each((ind,cb)=>{
if(cb.checked){
$.each(tabArray,(idx,tab)=>{
if(tab.title === cb.name){
let item = {
title: tab.title,
url: tab.url
};
tabset_data.items.push(item);
}
});
}
});
chrome.runtime.sendMessage({type: "create_tabset", payload: tabset_data}, function(response) {
// never runs
});
//close() workaround;
chrome.tabs.getCurrent(function (tab) {
chrome.tabs.remove(tab.id);
});
});
});
});
function getCurrentDateString(){
let d = new Date();
let day = d.getDate();
let month = d.getMonth() + 1;
let year = d.getFullYear();
let hour = d.getHours();
let minutes = d.getMinutes();
if (day < 10) {
day = "0" + day;
}
if (month < 10) {
month = "0" + month;
}
if(hour < 10){
hour = "0" + hour;
}
if(minutes < 10){
minutes = "0" + minutes;
}
return year + "-" + month + "-" + day + "-" + hour + ":" + minutes;
}