-
Notifications
You must be signed in to change notification settings - Fork 1
/
content.tsx
100 lines (87 loc) · 3.06 KB
/
content.tsx
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
import css from "data-text:~styles.css"
import type { PlasmoContentScript } from "plasmo"
import { useState } from "react"
import { useDeathClock } from "~useDeathClock"
export const config: PlasmoContentScript = {
matches: [
"https://twitter.com/*",
"https://www.facebook.com/*",
"https://www.youtube.com/*",
"https://www.instagram.com/*",
"https://www.reddit.com/*",
"https://www.linkedin.com/*",
"https://vk.com/*"
]
}
const injectStyles = () => {
const style = document.createElement("style")
style.textContent = css
document.body.insertAdjacentElement("beforebegin", style)
}
const injectContainer = () => {
const container = document.createElement("div")
container.classList.add("smdc")
container.style.cssText = "z-index: 99999999999;"
document.body.insertAdjacentElement("afterbegin", container)
}
export const getRootContainer = async () => {
injectStyles()
injectContainer()
return document.querySelector(".smdc")
}
const DeathClockBanner = () => {
const [showBanner, setShowBanner] = useState(true)
const { birthdate, timeLeft } = useDeathClock()
return (
<div className="fixed bottom-0 m-4 font-sans flex items-center z-[999999999]">
{showBanner && (
<>
<div className="p-6 pr-8 bg-yellow-300 text-black font-bold border-solid border-2 border-black uppercase">
{!birthdate && <div className="text-2xl">Set your birthdate</div>}
{timeLeft && (
<div>
<div className="tracking-widest text-xs mb-2">Time Left</div>
<div className="flex space-x-6 text-center">
<div>
<div className="text-2xl">{timeLeft.yearsLeft}</div>
<div className="text-xs">years</div>
</div>
<div>
<div className="text-2xl">{timeLeft.daysLeft}</div>
<div className="text-xs">days</div>
</div>
<div>
<div className="text-2xl">{timeLeft.hoursLeft}</div>
<div className="text-xs">hours</div>
</div>
<div>
<div className="text-2xl">{timeLeft.minutesLeft}</div>
<div className="text-xs">minutes</div>
</div>
<div>
<div className="text-2xl">{timeLeft.secondsLeft}</div>
<div className="text-xs">seconds</div>
</div>
</div>
<div></div>
</div>
)}
</div>
<div
className="font-bold text-yellow-300 bg-black p-2 -ml-4 hover:cursor-pointer"
onClick={() => setShowBanner(false)}>
<
</div>
</>
)}
{!showBanner && (
<div
className="font-bold bg-yellow-300 p-2 border-solid border-2 border-black hover:cursor-pointer"
onClick={() => setShowBanner(true)}>
>
</div>
)}
</div>
)
}
export default DeathClockBanner