I was wondering if you could make this:
if(document.getElementsByClassName("whatever")[0]) {
document.getElementsByClassName("whatever")[0].style.display = "none";
}
(It checkes if the element exists, and then only excicutes the code if it is true)
But without the if statment, because it doesn't look like a good practise to dublicate the document.getElementsByClassName("whatever")[0]
, and it makes it more anoying when having to do alot of bug testing with the document.getElementsByClassName.