Skip to content

Commit 0cca9cb

Browse files
committed
White list
1 parent b492979 commit 0cca9cb

File tree

5 files changed

+34
-12
lines changed

5 files changed

+34
-12
lines changed

src/assets/css/settings.css

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@ body {
3333
min-height: 150px;
3434
cursor: pointer;
3535
list-style: none;
36-
padding:10px
36+
padding:10px;
37+
max-height: 300px;
38+
overflow: auto;
3739
}
3840

3941
.url-list li{
40-
line-height: 20px;
41-
font-size: 13px;
42+
line-height: 25px;
43+
font-size: 14px;
4244
}
4345

4446
input[type="text"]{

src/assets/icons/delete.png

-301 Bytes
Loading

src/compositions/black-list.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import { Settings } from './settings';
55

66
export async function isInBlackList(url: string): Promise<boolean> {
77
const blackList = (await Settings.getInstance().getSetting(StorageParams.BLACK_LIST)) as string[];
8-
return (
9-
blackList?.find(x => isDomainEquals(extractHostname(x), extractHostname(url))) !== undefined
10-
);
8+
const array = Object.values(blackList);
9+
return array?.find(x => isDomainEquals(extractHostname(x), extractHostname(url))) !== undefined;
1110
}

src/pages/Settings.vue

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,16 @@
8888
Activity and time for these domains will not be tracked
8989
</p>
9090
<ul readonly class="url-list">
91-
<li v-for="(url, i) of whiteList" :key="i">{{ url }}</li>
91+
<li v-for="(url, i) of whiteList" :key="i">
92+
<div>
93+
<img
94+
src="../assets/icons/delete.png"
95+
height="16"
96+
@click="deleteFromWhiteList(url)"
97+
/>
98+
{{ url }}
99+
</div>
100+
</li>
92101
</ul>
93102
<div class="mt-20">
94103
<input
@@ -102,7 +111,7 @@
102111
class="d-inline-block small-btn ml-10"
103112
value="Add Website"
104113
:disabled="newWebsiteForWhiteList == null || newWebsiteForWhiteList == ''"
105-
@click="addWebsite()"
114+
@click="addToWhiteList()"
106115
/>
107116
</div>
108117
</div>
@@ -204,14 +213,14 @@ onMounted(async () => {
204213
StorageParams.BLOCK_DEFERRAL,
205214
BLOCK_DEFERRAL_DEFAULT,
206215
);
207-
whiteList.value = await settingsStorage.getValue(StorageParams.BLACK_LIST, []);
216+
whiteList.value = Object.values(await settingsStorage.getValue(StorageParams.BLACK_LIST, []));
208217
});
209218
210219
async function save(storageParam: StorageParams, value: any) {
211220
if (value != undefined) await settingsStorage.saveValue(storageParam, value);
212221
}
213222
214-
async function addWebsite() {
223+
function addToWhiteList() {
215224
const existingItem = whiteList.value?.find(x =>
216225
isDomainEquals(extractHostname(x), extractHostname(newWebsiteForWhiteList.value!)),
217226
);
@@ -221,12 +230,18 @@ async function addWebsite() {
221230
type: 'error',
222231
});
223232
} else {
224-
whiteList.value?.push(newWebsiteForWhiteList.value!);
233+
const newWebsite = extractHostname(newWebsiteForWhiteList.value!);
234+
whiteList.value?.push(newWebsite);
225235
onChange(StorageParams.BLACK_LIST, whiteList.value);
226236
newWebsiteForWhiteList.value = '';
227237
}
228238
}
229239
240+
function deleteFromWhiteList(url: string) {
241+
whiteList.value = whiteList.value!.filter(x => x != url);
242+
onChange(StorageParams.BLACK_LIST, whiteList.value);
243+
}
244+
230245
function onChange(storageParam: StorageParams, value: any) {
231246
save(storageParam, value);
232247
}
@@ -241,4 +256,10 @@ function onChange(storageParam: StorageParams, value: any) {
241256
margin-bottom: 30px;
242257
display: block;
243258
}
259+
260+
.url-list img {
261+
vertical-align: middle;
262+
margin-right: 10px;
263+
cursor: pointer;
264+
}
244265
</style>

src/tracker.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ async function trackTime() {
5050
useBadge({
5151
tabId: activeTab!.id!,
5252
text: 'n/a',
53-
color: BadgeColor.red,
53+
color: BadgeColor.green,
5454
});
5555
} else {
5656
let tab = repo.getTab(activeDomain);

0 commit comments

Comments
 (0)