How to remove an id with double colon?
<li role="treeitem" aria-selected="false" aria-level="2" aria-labelledby="Vendor_Name::users_anchor" aria-expanded="true" id="Vendor_Name::users" class="jstree-node jstree-open">
What I tried:
$('[id*="Vendor_Name::users"]').remove();
$("#Vendor_Name\\:\\:users").remove();
$(document.getElementById("Vendor_Name::users")).remove();
$('li[id*="Vendor_Name::users"]').remove();
$('[id="Vendor_Name::users"]').remove();
$("li#Vendor_Name\\:\\:users").remove();
Nothing works. Removing other elements are working, so it has to do with ::
I can remove it via CSS, though, but I want to remove the element completely from DOM.
#Vendor_Name\:\:users {
display: none;
}
EDIT: Got it working with MutationObserver. In case anybody needs it:
const DEL_SELECTOR = '#Vendor_Name\\:\\:users';
const mo = new MutationObserver(onMutation);
// in case the content script was injected after the page is partially loaded
onMutation([{addedNodes: [document.documentElement]}]);
observe();
function onMutation(mutations) {
const toRemove = [];
for (const {addedNodes} of mutations) {
for (const n of addedNodes) {
if (n.tagName) {
if (n.matches(DEL_SELECTOR)) {
toRemove.push(n);
} else if (n.firstElementChild && n.querySelector(DEL_SELECTOR)) {
toRemove.push(...n.querySelectorAll(DEL_SELECTOR));
}
}
}
}
if (toRemove.length) {
mo.disconnect();
for (const el of toRemove) el.remove();
observe();
}
}
function observe() {
mo.observe(document, {
subtree: true,
childList: true,
});
}