-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
31 lines (27 loc) · 873 Bytes
/
background.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
function inject() {
function hideElement(selector) {
const element = document.querySelector(selector);
if (element) {
element.style.display = "none";
}
}
const observer = new MutationObserver(() => {
hideElement('[page-subtype="home"]');
hideElement('div#guide-content');
hideElement('#shorts-container');
hideElement('#related');
hideElement('[section-identifier="comment-item-section"]');
});
observer.observe(document.body, { childList: true, subtree: true });
}
chrome.webRequest.onBeforeRequest.addListener(
function(details) {
if (details.tabId !== 'undefined' && details.tabId > 0) {
chrome.scripting.executeScript({
target: { tabId: details.tabId },
func: inject,
});
}
},
{ urls: ["*://www.youtube.com/*"] }
);