-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbackground.js
48 lines (44 loc) · 1.27 KB
/
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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
chrome.runtime.onInstalled.addListener(function(details) {
if (details.reason == 'install') {
chrome.storage.sync.set({ on: true })
console.log('initiallise')
}
})
// chrome.browserAction.onClicked.addListener(function(tab) {
// chrome.storage.sync.get('on', data => {
// chrome.storage.sync.set({ on: !data.on })
// injectCSS()
// })
// })
chrome.storage.sync.set({ on: true })
chrome.tabs.onActivated.addListener(function() {
injectCSS()
})
chrome.tabs.onUpdated.addListener(function(tabId, info) {
if (info.status === 'complete') {
injectCSS()
}
})
function injectCSS() {
chrome.storage.sync.get('on', data => {
if (data.on) {
chrome.tabs.insertCSS(null, {
code:
'#items.ytd-watch-next-secondary-results-renderer {visibility: hidden;} !important'
})
chrome.tabs.insertCSS(null, {
code:
'#dismissable.style-scope.ytd-shelf-renderer {visibility: hidden;} !important'
})
} else {
chrome.tabs.insertCSS(null, {
code:
'#items.ytd-watch-next-secondary-results-renderer {visibility: visible;} !important'
})
chrome.tabs.insertCSS(null, {
code:
'#dismissable.style-scope.ytd-shelf-renderer {visibility: visible;} !important'
})
}
})
}