That works like a charm!!!

Thank you so much for that. I had no idea calibre conversion came with a full JS search engine. That's impressive
Having realised that, I was wondering how each page is rendered when converting into PDF.
I've managed now to hide headers for certain sections, but I'm not able to hide them when page has headings with a certain class (e.g.: "chapter"). If heading is relatively big, then the header doesn't look that good.
So far I've managed to check if a class exists with this:
Code:
function header() {
var chapter = document.getElementsByClassName("chapter");
if (chapter != 'undefined' || chapter != null )
{document.getElementById("header").style.display = 'none';}
header()
I can see that the function is working because if I set the conditions to equal, the header shows as normal. However, with this function it looks as if the whole .pdf file is the document. The result is that the header is hidden for all pages and not just the ones with the class "chapter".
Is there a way of checking if class exists in the current page?