-
Notifications
You must be signed in to change notification settings - Fork 0
/
content.js
30 lines (25 loc) · 930 Bytes
/
content.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
// Updated on changed
chrome.runtime.onMessage.addListener(function(req, sender, sendResponse) {
updateThumbnail( req.action );
});
// Check 'display' option onload
chrome.storage.sync.get(['display'], function(result) {
updateThumbnail( result.display );
});
// On user scroll and loads more
document.getElementById('contents').addEventListener('DOMSubtreeModified', function(){
chrome.storage.sync.get(['display'], function(result) {
updateThumbnail( result.display );
});
});
document.getElementById('items').addEventListener('DOMSubtreeModified', function(){
chrome.storage.sync.get(['display'], function(result) {
updateThumbnail( result.display );
});
});
function updateThumbnail( action ) {
let thumbs = document.getElementsByTagName('ytd-thumbnail');
for ( var i = 0; i < thumbs.length; i++ ) {
thumbs[i].style.display = !action ? "none": "block";
}
}