let gettingItem = browser.storage.sync.get({commentsRemove: false}); // Retrieves the storage variable to determine whether comments should be removed function setComments(remove) { document.getElementsByTagName("ytd-comments")[0].style.visibility = remove ? "hidden" : "visible"; } 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);