-
Notifications
You must be signed in to change notification settings - Fork 0
/
content_script.js
81 lines (70 loc) · 3.18 KB
/
content_script.js
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
chrome.runtime.onMessage.addListener((request, sender, sendResponse) => {
if (request.action === 'changeColor') {
if (request.value) {
const main = document.querySelector('main')
if (main) {
chrome.storage.local.get(['switch', 'img'], (result) => {
const bg = new Image()
bg.className = 'bg'
bg.src = result.img
bg.style.width = '100%'
bg.style.height = '100%'
bg.style.position = 'absolute'
bg.style.filter = 'brightness(50%)'
bg.style.objectFit = 'cover'
main.prepend(bg)
})
window.location.reload()
}
} else {
document.querySelector('main > img').remove()
window.location.reload()
}
}
})
// Init
chrome.storage.local.get(['switch', 'img'], (result) => {
if (result.switch !== undefined) {
if (result.switch) {
const main = document.querySelector('main')
if (main) {
const bg = new Image()
bg.className = 'bg'
bg.src = result.img
bg.style.width = '100%'
bg.style.height = '100%'
bg.style.position = 'absolute'
bg.style.filter = 'brightness(50%)'
bg.style.objectFit = 'cover'
main.prepend(bg)
}
setInterval(() => {
const navContainer = document.querySelector('#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.flex-1.overflow-hidden > div > div > div')
const nav = document.querySelector('#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.flex-1.overflow-hidden > div > div > div > div')
const nav2 = document.querySelector('main > div[role="presentation"] > div > div > div > div')
const textarea = document.querySelector('main > div[role="presentation"] > .w-full > form > div > div.flex.w-full.items-center > div')
const spans = document.querySelectorAll('#__next > div.relative.z-0.flex.h-full.w-full.overflow-hidden > div.relative.flex.h-full.max-w-full.flex-1.flex-col.overflow-hidden > main > div.flex.h-full.flex-col > div.w-full.pt-2 > form > div > div > div > div > div > div > div > span > button')
nav.style.transition = 'all .5s'
nav.style.backgroundColor = 'transparent'
nav.style.backdropFilter = 'blur(5px)'
nav2.style.transition = 'all .5s'
nav2.style.transition = 'all .5s'
nav2.style.backgroundColor = 'transparent'
nav2.style.backdropFilter = 'blur(5px)'
textarea.style.transition = 'all .5s'
textarea.style.backgroundColor = 'rgb(52, 53, 65, .6)'
textarea.style.border = 'none'
textarea.style.backdropFilter = 'blur(5px)'
spans.forEach(el => {
el.style.transition = 'all .5s'
el.style.backgroundColor = 'rgb(52, 53, 65, .6)'
el.style.border = 'none'
el.style.backdropFilter = 'blur(5px)'
})
navContainer.style.backdropFilter = 'none'
}, 1000)
} else {
document.querySelector('main > img').remove()
}
}
})