Skip to content

Commit ec9c600

Browse files
committed
1.0-alpha.3
1 parent ef807d1 commit ec9c600

File tree

13 files changed

+764
-522
lines changed

13 files changed

+764
-522
lines changed

_locales/en/messages.json

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,23 @@
11
{
2-
"domain": {
3-
"message": "Domain"
4-
},
5-
"visitCount": {
6-
"message": "Visit count"
7-
},
8-
"title": {
9-
"message": "Title"
10-
},
11-
"url": {
12-
"message": "URL"
13-
},
14-
"tags": {
15-
"message": "Tags"
16-
},
17-
"compactMode": {
18-
"message": "Compact mode"
19-
}
2+
"compactMode": {
3+
"message": "Compact mode"
4+
},
5+
"domain": {
6+
"message": "Domain"
7+
},
8+
"language": {
9+
"message": "Language"
10+
},
11+
"tags": {
12+
"message": "Tags"
13+
},
14+
"title": {
15+
"message": "Title"
16+
},
17+
"url": {
18+
"message": "URL"
19+
},
20+
"visits": {
21+
"message": "Visits"
22+
}
2023
}

_locales/ru/messages.json

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"compactMode": {
3+
"message": "Компактный режим"
4+
},
5+
"domain": {
6+
"message": "Домен"
7+
},
8+
"language": {
9+
"message": "Язык"
10+
},
11+
"tags": {
12+
"message": "Теги"
13+
},
14+
"title": {
15+
"message": "Заголовок"
16+
},
17+
"url": {
18+
"message": "URL"
19+
},
20+
"visits": {
21+
"message": "Посещения"
22+
}
23+
}

background.js

Lines changed: 69 additions & 101 deletions
Original file line numberDiff line numberDiff line change
@@ -52,84 +52,7 @@ function parseHistory(item, result) {
5252
2.0 EXTENSION INSTALLED
5353
---------------------------------------------------------------*/
5454

55-
/*chrome.runtime.onInstalled.addListener(function() {
56-
console.time();
57-
58-
chrome.history.search({
59-
text: '',
60-
startTime: 0,
61-
maxResults: 999999999
62-
}, function(items) {
63-
var all = {
64-
domains: {},
65-
pages: {},
66-
params: {}
67-
},
68-
top = {
69-
domains: {},
70-
pages: {},
71-
params: {}
72-
},
73-
cache = {
74-
domains: [],
75-
pages: [],
76-
params: []
77-
};
78-
79-
for (var i = 0, l = items.length; i < l; i++) {
80-
parseHistory(items[i], all);
81-
}
82-
83-
// TODO: IMPROVE ALGORITHM
84-
for (var key in all.domains) {
85-
cache.domains.push(all.domains[key]);
86-
}
87-
88-
for (var key in all.pages) {
89-
cache.pages.push(all.pages[key]);
90-
}
91-
92-
for (var key in all.params) {
93-
cache.params.push(all.params[key]);
94-
}
95-
96-
cache.domains = cache.domains.sort(function(a, b) {
97-
return b.visitCount - a.visitCount;
98-
});
99-
100-
cache.pages = cache.pages.sort(function(a, b) {
101-
return b.visitCount - a.visitCount;
102-
});
103-
104-
cache.params = cache.params.sort(function(a, b) {
105-
return b.visitCount - a.visitCount;
106-
});
107-
108-
var keys = [
109-
Object.keys(all.domains),
110-
Object.keys(all.pages),
111-
Object.keys(all.params)
112-
];
113-
114-
for (var i = 0; i < 100; i++) {
115-
top.domains[keys[0][i]] = all.domains[keys[0][i]];
116-
top.pages[keys[1][i]] = all.pages[keys[1][i]];
117-
top.params[keys[2][i]] = all.params[keys[2][i]];
118-
}
119-
// END
120-
121-
chrome.storage.local.set({
122-
'all': all,
123-
'top': top
124-
}, function() {
125-
console.timeEnd();
126-
});
127-
});
128-
});*/
129-
13055
chrome.runtime.onInstalled.addListener(function() {
131-
console.time();
132-
13356
chrome.history.search({
13457
text: '',
13558
startTime: 0,
@@ -138,12 +61,14 @@ chrome.runtime.onInstalled.addListener(function() {
13861
var storage = {
13962
_all: {
14063
domains: {},
141-
pages: {}
64+
pages: {},
65+
params: {}
14266
},
14367
_top: {
14468
domains: {},
14569
pages: {},
146-
length: [0, 0]
70+
params: {},
71+
length: [0, 0, 0]
14772
}
14873
};
14974

@@ -156,7 +81,6 @@ chrome.runtime.onInstalled.addListener(function() {
15681
path = url.match(/\w(\/.*)/)[1],
15782
q = url.match(/[?&]q=[^&]+/) || [];
15883

159-
16084
// DOMAINS
16185
if (!storage[domain]) {
16286
storage[domain] = {};
@@ -167,49 +91,60 @@ chrome.runtime.onInstalled.addListener(function() {
16791
visitCount: visit_count,
16892
params: q[0]
16993
};
170-
94+
17195
if (storage._all.domains[domain]) {
17296
storage._all.domains[domain] += visit_count;
17397
} else {
17498
storage._all.domains[domain] = visit_count;
17599
}
176-
177-
100+
178101
// PAGES
179102
storage._all.pages[url] = {
180103
title: title,
181104
visitCount: visit_count,
182105
star: 0,
183106
tags: ''
184107
};
108+
109+
// PARAMS
110+
if (q && q[0] && !storage._all.params[domain]) {
111+
storage._all.params[domain] = visit_count;
112+
}
113+
114+
if (storage._all.params[domain]) {
115+
storage._all.params[domain] += visit_count;
116+
}
185117
}
186-
187-
118+
119+
188120
// TOP
189121
var domains = Object.keys(storage._all.domains).map((key) => [key, storage._all.domains[key]]).sort(function(a, b) {
190122
return b[1] - a[1];
191123
}),
192124
pages = Object.keys(storage._all.pages).map((key) => [key, storage._all.pages[key]]).sort(function(a, b) {
193125
return b[1].visitCount - a[1].visitCount;
126+
}),
127+
params = Object.keys(storage._all.params).map((key) => [key, storage._all.params[key]]).sort(function(a, b) {
128+
return b[1] - a[1];
194129
});
195-
130+
196131
for (var i = 0; i < Math.min(100, domains.length); i++) {
197132
storage._top.domains[domains[i][0]] = domains[i][1];
198133
}
199-
134+
200135
for (var i = 0; i < Math.min(100, pages.length); i++) {
201136
storage._top.pages[pages[i][0]] = pages[i][1];
202137
}
203-
138+
139+
for (var i = 0; i < Math.min(100, params.length); i++) {
140+
storage._top.params[params[i][0]] = params[i][1];
141+
}
142+
204143
storage._top.length[0] = Object.keys(storage._all.domains).length;
205144
storage._top.length[1] = Object.keys(storage._all.pages).length;
206-
145+
storage._top.length[2] = Object.keys(storage._all.params).length;
207146

208-
chrome.storage.local.set(storage, function() {
209-
console.timeEnd();
210-
211-
console.log(storage);
212-
});
147+
chrome.storage.local.set(storage);
213148
});
214149
});
215150

@@ -219,15 +154,48 @@ chrome.runtime.onInstalled.addListener(function() {
219154
---------------------------------------------------------------*/
220155

221156
chrome.history.onVisited.addListener(function(item) {
222-
chrome.storage.local.get('new', function(items) {
223-
var items = items.new || {
224-
domains: {},
225-
pages: {},
226-
params: {}
227-
};
157+
chrome.storage.local.get('_new', function(items) {
158+
var storage = items._new || {
159+
domains: {},
160+
pages: {},
161+
params: {}
162+
},
163+
title = item.title,
164+
url = item.url,
165+
domain = url.split('/')[2],
166+
path = url.match(/\w(\/.*)/)[1],
167+
q = url.match(/[?&]q=[^&]+/) || [];
168+
169+
// DOMAINS
170+
if (storage.domains[domain]) {
171+
storage.domains[domain] += 1;
172+
} else {
173+
storage.domains[domain] = 1;
174+
}
175+
176+
// PAGES
177+
if (storage.pages[url]) {
178+
storage.pages[url].visitCount += 1;
179+
} else {
180+
storage.pages[url] = {
181+
title: title,
182+
visitCount: 1,
183+
star: 0,
184+
tags: ''
185+
};
186+
}
187+
188+
// PARAMS
189+
if (url.indexOf(/[?&]+q=/)) {
190+
if (storage.params[domain]) {
191+
storage.params[domain] += 1;
192+
} else {
193+
storage.params[domain] = 1;
194+
}
195+
}
228196

229197
chrome.storage.local.set({
230-
'new': parseHistory(item, items)
198+
_new: storage
231199
});
232200
});
233201
});

manifest.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
"manifest_version": 2,
33
"name": "History Manager",
44
"version": "1.0",
5-
"version_name": "1.0-alpha.2",
5+
"version_name": "1.0-alpha.3",
66

77
"default_locale": "en",
88

popup.css

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,13 @@ body[data-compact-mode="true"] .satus-header__text-field
333333
text-overflow: unset;
334334
}
335335

336+
.satus-table--toolbar .satus-button {
337+
padding: 0 8px;
338+
width: auto;
339+
margin: 0 8px 0 0;
340+
font-weight: 700;
341+
}
342+
336343

337344

338345

@@ -544,6 +551,38 @@ body[data-compact-mode="true"] .satus-header__text-field
544551
background-color: #f6b465;
545552
box-shadow: none;
546553
}
554+
555+
556+
557+
558+
559+
560+
561+
562+
563+
564+
565+
566+
567+
568+
569+
570+
571+
body.loading::after {
572+
content: '...';
573+
display: flex;
574+
justify-content: center;
575+
align-items: center;
576+
position: fixed;
577+
font-size: 64px;
578+
color: rgba(255,255,255,.8);
579+
left: 0;
580+
top: 0;
581+
width: 100vw;
582+
height: 100vh;
583+
background: rgba(0,0,0,.8);
584+
z-index: 9999;
585+
}
547586

548587
/*---------------------------------------------------------------
549588
>>> TABLES

0 commit comments

Comments
 (0)