-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.ts
38 lines (33 loc) · 1.26 KB
/
main.ts
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
import './style.css'
function setParentStyle(selector: string, callback?: (style: CSSStyleDeclaration) => void) {
const style = document.querySelector(selector)?.parentElement?.style
style && callback?.(style)
}
function setBasicStyle() {
setParentStyle('#switchTab', s => s.width = '255px')
setParentStyle('#tagYadsListTop', s => s.display = 'none')
setParentStyle('#tagYadsSideColumn', s => s.display = 'none')
setParentStyle('#tagYadsDetail', s => s.display = 'none')
}
function setTwimgStyle(el: HTMLIFrameElement) {
setTimeout(() => {
const d = el.contentWindow?.document
if (!d) return
const avatar = d.querySelector('img[src^="https://pbs.twimg.com/profile_images"')
if (!avatar) return
const tds = d.querySelectorAll('td[background^="https://pbs.twimg.com/media"]')
for (const item of tds) {
const bg = item.getAttribute('background')?.replace(':mosaic', '')
bg && item.querySelector('img')?.setAttribute('src', bg)
}
}, 200)
}
function doClean() {
const selector = 'div[data-cy="mailPreviewArea"]'
document.arrive(selector, el => {
setBasicStyle()
el.arrive('iframe', ifr => setTwimgStyle(ifr as HTMLIFrameElement))
document.unbindArrive(selector)
})
}
addEventListener('load', () => { doClean() })