| Index: lib/content/snippets.js |
| =================================================================== |
| --- a/lib/content/snippets.js |
| +++ b/lib/content/snippets.js |
| @@ -222,8 +222,31 @@ |
| return root; |
| } |
| }); |
| } |
| exports["hide-if-shadow-contains"] = makeInjector(hideIfShadowContains, |
| hideElement); |
| + |
| +/** |
| + * Hides any HTML element if the text content of the element contains a given |
| + * string. |
| + * |
| + * @param {string} search The string to look for in every HTML element. |
| + * @param {string} selector The CSS selector that an HTML element must match |
| + * for it to be hidden. |
| + */ |
| +function hideIfContains(search, selector = "*") |
| +{ |
| + new MutationObserver(() => |
| + { |
| + for (let element of document.querySelectorAll(selector)) |
| + { |
| + if (element.textContent.includes(search)) |
| + hideElement(element); |
| + } |
| + }) |
| + .observe(document, {childList: true, characterData: true, subtree: true}); |
| +} |
| + |
| +exports["hide-if-contains"] = hideIfContains; |