2020-01-03 12:48:26 +01:00
|
|
|
let gettingItem = browser.storage.sync.get({commentsRemove: false});
|
|
|
|
// Retrieves the storage variable to determine whether comments should be removed
|
|
|
|
|
|
|
|
function setComments(remove) {
|
2020-01-16 21:35:32 +01:00
|
|
|
if (!remove)
|
|
|
|
return;
|
|
|
|
var commentStyle = document.createElement('style');
|
|
|
|
document.head.appendChild(commentStyle);
|
|
|
|
|
|
|
|
commentStyle.sheet.insertRule("ytd-comments {visibility: hidden !important}");
|
2020-01-03 12:48:26 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
function onGot(result) {
|
|
|
|
var remove = result.commentsRemove;
|
|
|
|
setComments(remove);
|
|
|
|
// Sets the visibility of the comments section depending on the storage vairable
|
|
|
|
}
|
|
|
|
function onFailure(error) {
|
|
|
|
alert(`Error: ${error}`);
|
|
|
|
}
|
|
|
|
|
|
|
|
gettingItem.then(onGot, onFailure);
|