podivilov
Pollux Looks like I has found the correct solution:
document.getElementById("header-secondary").remove();
This removes the the whole node including the options to register and log in (if not already logged in). If you want to get rid of those too, that seems like a good solution.
If you, however, still want to remove only the search option, you could try to remove the <li class="item-search"> node alone:
document.getElementById("header-secondary").firstChild.firstChild.remove();
That's a bit risky, because it assumes, that <li class="item-search"> will always be the first child of the first child of <div id="header-secondary">, but it should work for the time being.
podivilov
It works when I execute code from developer console, but didn't work anymore when I add same code to Custom header section in admin panel. Probably Custom header function can't interact with site contents?
I suspect, that <div id="header-secondary"> doesn't exist at the time, the javascript injected into the header is executed. Your solution of an window.onload function guaranties the existence of <div id="header-secondary"> at the time of execution. My CSS solution should work too this way.
The disadvantage of this solution might be, that the search option could become visible for a short moment until the window.onload function hides it. If this should be the case and bother you, you could try a modification: Hide the search by default via CSS and use the window.onload function to make it visible in case the browser is not Kiosk.
A third (and probably most elegant) solution would act on the <body> element instead of the <div id="header-secondary"> node. The body should be there from the beginning, so you wouldn't need to act on window.onload:
<script type="text/javascript">
var ua = window.navigator.userAgent;
var isKiosk = ua.indexOf("Kiosk/1.0") >= 0;
if (isKiosk) {
document.body.classList.add("Is-Kiosk");
}
</script>
and:
body.Is-Kiosk .Search-input {
display: none;
}
PS:
podivilov Should the space be here?
[...] Is-Kiosk .Search-input [...]
Yes. The space means that .Search-input is a descendant of .Is-Kiosk, a child, a grand child or any other descendent. That's why the body element holding the .Is-Kiosk works too.