27 lines
841 B
JavaScript
27 lines
841 B
JavaScript
// Add this line to "Create Custom Filters" box:
|
|
// x.com##+js(fuck-twitter-promote-buttons.js)
|
|
|
|
const callback = (mutationList, observer) => {
|
|
const walker = document.createTreeWalker(
|
|
document.documentElement,
|
|
NodeFilter.SHOW_TEXT, null, false);
|
|
let node;
|
|
|
|
while (node = walker.nextNode()) {
|
|
if (node.nodeValue.includes("Promote")) {
|
|
let ancestor = node.parentNode;
|
|
while (ancestor && ancestor.tagName !== 'A') {
|
|
ancestor = ancestor.parentNode;
|
|
}
|
|
|
|
if (ancestor && ancestor.tagName === 'A') {
|
|
ancestor.remove();
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
const targetNode = document.documentElement;
|
|
const observer = new MutationObserver(callback);
|
|
observer.observe(targetNode, { attributes: false, childList: true, subtree: true });
|