-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcontent.ts
35 lines (29 loc) · 819 Bytes
/
content.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
import type { PlasmoCSConfig } from "plasmo"
export const config: PlasmoCSConfig = {
matches: ["https://*.youtube.com/*"],
world: "MAIN"
}
let initialized = false
const removeShorts = () => {
const shorts = document.querySelectorAll('a[href^="/shorts"]')
shorts.forEach((n) => n.closest("ytd-grid-video-renderer")?.remove())
}
const observer = new MutationObserver(removeShorts)
const callback = () => {
removeShorts()
const subscriptions = document.querySelector(
'ytd-section-list-renderer[page-subtype="subscriptions"] div#contents'
)
if (subscriptions) {
initialized = true
}
observer.observe(subscriptions, {
childList: true,
subtree: false
})
}
window.addEventListener("yt-navigate-finish", callback)
setInterval(() => {
if (initialized) return
callback()
}, 1000)