Skip to content

Commit 47306e4

Browse files
committed
Add welcome page
1 parent b0192bc commit 47306e4

File tree

13 files changed

+165
-15
lines changed

13 files changed

+165
-15
lines changed

src/assets/icons/extension.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/icons/icon.png

871 Bytes
Loading

src/assets/icons/pin.svg

Lines changed: 1 addition & 0 deletions
Loading

src/assets/initial.jpg

75.9 KB
Loading

src/assets/pin-tutorial.png

15.3 KB
Loading

src/background.ts

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,16 @@ Browser.storage.onChanged.addListener((changes, namespace) => {
2828

2929
Browser.runtime.setUninstallURL('https://webtracker.online/goodbye.html');
3030

31+
Browser.runtime.onInstalled.addListener(async details => {
32+
if (details.reason == 'install') {
33+
const initialPageUrl = Browser.runtime.getURL('src/welcome.html');
34+
await Browser.tabs.create({
35+
url: initialPageUrl,
36+
active: true,
37+
});
38+
}
39+
});
40+
3141
Browser.runtime.onStartup.addListener(() => {
3242
logger.log(`onStartup event`);
3343
});

src/compositions/set-badge.ts

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import Browser from 'webextension-polyfill';
22

33
export interface BadgeState {
44
color: BadgeColor;
5-
tabId: number;
5+
tabId: number | undefined;
66
text: string;
77
}
88

@@ -13,10 +13,12 @@ export enum BadgeColor {
1313
none = '#000',
1414
}
1515

16-
export function useBadge(badge: BadgeState): void {
17-
Browser.action.setBadgeBackgroundColor({ color: badge.color });
18-
Browser.action.setBadgeText({
19-
tabId: badge.tabId,
20-
text: badge.text,
21-
});
16+
export async function useBadge(badge: BadgeState): Promise<void> {
17+
if (badge.tabId != undefined) {
18+
await Browser.action.setBadgeBackgroundColor({ color: badge.color });
19+
await Browser.action.setBadgeText({
20+
tabId: badge.tabId,
21+
text: badge.text,
22+
});
23+
}
2224
}

src/pages/Popup.vue

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
<p class="header">Web Activity Time Tracker</p>
66
</div>
77
<div class="icons-block">
8-
<!-- <img height="17" src="../assets/icons/dark-mode.svg" /> -->
98
<a @click="openPage(SettingsTab.Dashboard)"
109
>{{ t('dashboard.message') }}<img height="22" src="../assets/icons/dashboard.svg"
1110
/></a>

src/pages/Welcome.vue

Lines changed: 117 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,117 @@
1+
<template>
2+
<div class="main">
3+
<p class="header">Welcome to Web Activity Time Tracker</p>
4+
<p class="description">
5+
Web Activity Time Tracker is <span>open-sourse</span>, <span>free</span> and
6+
<span>no ads</span> extension, which can help you track the time you spent on browsing
7+
websites and the count of visit.
8+
</p>
9+
<img class="img" src="../assets/initial.jpg" height="250" />
10+
<div class="steps">
11+
<p class="header">Get started</p>
12+
<p class="description">You can quicly start using the extension in just 3 easy steps</p>
13+
<p class="step">1. Pin the icon</p>
14+
<p class="description">
15+
To use this extension more conviently, you can pin the icon to toolbar. Click the icon
16+
<img src="../assets/icons/extension.svg" height="25" /> and then click the pin icon
17+
<img src="../assets/icons/pin.svg" height="25" />
18+
</p>
19+
<img class="img" src="../assets/pin-tutorial.png" height="250" />
20+
<p class="step">2. Browse any websites</p>
21+
<p class="description">
22+
Browse any websites and you will see that time is beating on the icon, just like this
23+
<img src="../assets/icons/icon.png" height="35" />
24+
</p>
25+
<p class="step">3. Read data in the popup page and on dashboard</p>
26+
<p class="description mt-20">
27+
Click on the extension icon to open a popup page and you will be able to read the data
28+
visualized using a pie chart, for today, for all time, or by day. In the popup window, you
29+
can open the dashboard and it will show you today's time by hour. And you can set a daily
30+
time limit for any websites, notifications for websites, or export data to CSV.
31+
</p>
32+
<div class="btn-block">
33+
<button class="close" @click="close()">Close</button>
34+
<button @click="openDashboard()">Use the extension</button>
35+
</div>
36+
</div>
37+
</div>
38+
</template>
39+
40+
<script lang="ts" setup>
41+
import { useI18n } from 'vue-i18n';
42+
import Browser from 'webextension-polyfill';
43+
44+
async function close() {
45+
const currentTab = await Browser.tabs.getCurrent();
46+
await Browser.tabs.remove(currentTab.id!);
47+
}
48+
49+
async function openDashboard() {
50+
const url = Browser.runtime.getURL('src/dashboard.html?tab=dashboard');
51+
const tab = await Browser.tabs.query({ currentWindow: true, active: true });
52+
Browser.tabs.update(tab[0].id, { url: url });
53+
}
54+
</script>
55+
56+
<style scoped>
57+
.main {
58+
margin: auto;
59+
text-align: center;
60+
margin-top: 20px;
61+
width: 80%;
62+
height: 100%;
63+
}
64+
65+
.header {
66+
font-size: 26px;
67+
font-weight: 600;
68+
}
69+
.img {
70+
margin: 20px 0 0 0;
71+
}
72+
.description {
73+
font-size: 18px;
74+
}
75+
.description span {
76+
font-weight: 600;
77+
}
78+
.description img {
79+
margin: 0 10px;
80+
}
81+
.steps .step {
82+
text-align: left;
83+
font-size: 24px;
84+
font-weight: 700;
85+
}
86+
.steps .step {
87+
margin: 30px;
88+
}
89+
90+
.steps .description {
91+
margin: 20px;
92+
}
93+
94+
button.close {
95+
background: #c5c5c5;
96+
color: rgb(0, 0, 0);
97+
}
98+
99+
button {
100+
display: inline-block;
101+
background: #428bff;
102+
color: #fff;
103+
border-radius: 5px;
104+
height: 36px;
105+
line-height: 35px;
106+
padding: 0 10px;
107+
border: 0;
108+
font-size: 14px;
109+
cursor: pointer;
110+
text-align: center;
111+
width: 200px;
112+
margin: 0 10px;
113+
}
114+
.btn-block {
115+
margin: 25px;
116+
}
117+
</style>

src/tracker.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,8 @@ async function trackTime() {
4141
const activeDomain = extractHostname(activeTab!.url);
4242

4343
if (await isInBlackList(activeDomain)) {
44-
useBadge({
45-
tabId: activeTab!.id!,
44+
await useBadge({
45+
tabId: activeTab?.id,
4646
text: 'n/a',
4747
color: BadgeColor.green,
4848
});
@@ -128,14 +128,14 @@ async function mainTracker(
128128
const viewInBadge = await Settings.getInstance().getSetting(StorageParams.VIEW_TIME_IN_BADGE);
129129

130130
if (viewInBadge)
131-
useBadge({
132-
tabId: activeTab!.id!,
131+
await useBadge({
132+
tabId: activeTab?.id,
133133
text: convertSummaryTimeToBadgeString(tab.days.at(-1)!.summary),
134134
color: BadgeColor.blue,
135135
});
136136
else
137-
useBadge({
138-
tabId: activeTab!.id!,
137+
await useBadge({
138+
tabId: activeTab?.id,
139139
text: '',
140140
color: BadgeColor.red,
141141
});

0 commit comments

Comments
 (0)