forked from Stigmatoz/web-activity-time-tracker
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPromoClearYouTube.vue
More file actions
84 lines (74 loc) · 2.14 KB
/
PromoClearYouTube.vue
File metadata and controls
84 lines (74 loc) · 2.14 KB
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
<template>
<div class="review-block" v-if="showReview && canShowPromo">
<p>{{ t('promoClearYoutube.message') }}</p>
<div class="btn-block">
<img height="15" src="../assets/icons/close.svg" @click="closeBlock()" />
<input type="button" :value="t('promoClearYoutube.description')" @click="openStore()" />
</div>
</div>
</template>
<script lang="ts">
export default {
name: 'PromoClearYouTube',
};
</script>
<script lang="ts" setup>
import { ref } from 'vue';
import { useI18n } from 'vue-i18n';
import { injecStorage } from '../storage/inject-storage';
import { StorageParams } from '../storage/storage-params';
import { CHROME_STORE_CLEAR_YOUTUBE_URL } from '../utils/chrome-url';
import { usePromoExtension } from '../compositions/usePromoExtension';
import { computedAsync } from '@vueuse/core';
import { useExtensionPage } from '../compositions/useExtensionPage';
const { t } = useI18n();
const settingsStorage = injecStorage();
const extensionPage = useExtensionPage();
const showReview = ref<boolean>(true);
const canShowPromo = computedAsync(async () => await usePromoExtension());
async function closeBlock() {
showReview.value = false;
await saveValue();
}
async function openStore() {
showReview.value = false;
window.open(CHROME_STORE_CLEAR_YOUTUBE_URL, '_blank');
await saveValue();
}
async function saveValue() {
let param: StorageParams | undefined = undefined;
if (extensionPage.isBlockPage.value) param = StorageParams.PROMO_CLEAR_YOUTUBE_ON_BLOCK;
if (extensionPage.isLimitPage.value) param = StorageParams.PROMO_CLEAR_YOUTUBE_ON_LIMITS;
if (param) await settingsStorage.saveValue(param, true);
}
</script>
<style scoped>
.review-block {
margin: 20px 0 20px 0;
padding: 10px;
font-size: 14px;
background-color: #efefef;
border-radius: 10px;
min-width: 655px;
}
.review-block .btn-block {
margin: 8px 5px 0 0;
vertical-align: top;
float: right;
}
.review-block input[type='button'] {
float: right;
width: auto;
}
.review-block p {
display: inline-block;
margin: 0 10px;
font-size: 16px;
width: 70%;
}
.review-block img {
margin-left: 8px;
cursor: pointer;
float: right;
}
</style>