Skip to content

Instantly share code, notes, and snippets.

@Drag13
Created August 16, 2022 15:05
Show Gist options
  • Select an option

  • Save Drag13/ceb6821cf519c277f17bef0c91bb570f to your computer and use it in GitHub Desktop.

Select an option

Save Drag13/ceb6821cf519c277f17bef0c91bb570f to your computer and use it in GitHub Desktop.
(function clean() {
const allowed = [];
const container = document.querySelector("section");
const $allTopicsRaw = [...container.querySelectorAll("[role=button]")];
const $allTopics = $allTopicsRaw.reduce((acc, el, i) => {
const isTopic = i % 2 === 0;
isTopic ? acc.push({ topic: el }): acc[acc.length - 1].cancel = el
return acc;
}, []);
const $filtered = $allTopics.filter(($topic) => {
const topic = $topic.topic.querySelector("span").innerText.trim().toLocaleLowerCase();
const isAllowed = allowed.includes(topic);
return !isAllowed;
});
$filtered.forEach((el) => el.cancel?.click());
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment