Use:
.class-of-this-element{display: none}; // elem.style.display = 'none'
or
let observer = new MutationObserver(mutationRecords => {
mutationRecords.forEach( (record)=>{
record.addedNodes( (node)=> {
if (node.classList.includes('your-element-class')) node.parentNode.removeChild(node);
} )
} )
});
observer.observe(document, {
childList: true,
subtree: true
});
NEVER use setInterval like this
Use:
Thank you for your replay.
What I mean is that to forbid auto-add '(2 new messages)' in the title from some site, instead of delete some element of a website.
If you want to forbid the auto adding, I think you need to redefine appendChild method of the parent node (it will work only if this element adding to parent by this method).
element.parentNode.appendChild = function(){}
用每100ms检查标题去掉的办法,会不停的闪,不能完全去除