I need to hide a section from an html page:
Required:
@run-at: document-start in userscript metablock.
// ==UserScript==
..............
// @run-at document-start
..............
// ==/UserScript==
Now with the above your options are:
Simply inject a style that hides the logo:
(document.head || document.documentElement).insertAdjacentHTML('beforeend',
'<style>h1.logo.floatLeft { display: none!important; }</style>');
Use MutationObserver to detect and delete the element immediately after it's added into DOM.
new MutationObserver(function(mutations) {
// check at least two H1 exist using the extremely fast getElementsByTagName
// which is faster than enumerating all the added nodes in mutations
if (document.getElementsByTagName('h1')[1]) {
var ibmlogo = document.querySelectorAll('h1.logo.floatLeft')[1];
if (ibmlogo) {
ibmlogo.remove();
this.disconnect(); // disconnect the observer
}
}
}).observe(document, {childList: true, subtree: true});
// the above observes added/removed nodes on all descendants recursively