Skip to content

Instantly share code, notes, and snippets.

@erorus
Created December 29, 2021 17:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save erorus/94ccd0488a914d71ef9d23491ae1a325 to your computer and use it in GitHub Desktop.
Save erorus/94ccd0488a914d71ef9d23491ae1a325 to your computer and use it in GitHub Desktop.
Hide API Forum Posts
// ==UserScript==
// @name Hide API Forum Posts
// @version 1
// @grant GM.setValue
// @grant GM.getValue
// @include https://us.forums.blizzard.com/en/blizzard/*
// ==/UserScript==
(async function () {
let data = JSON.parse(await GM.getValue('hidden', '[]'));
(new MutationObserver(function (mutationsList) {
mutationsList.forEach(mutation => {
mutation.addedNodes.forEach(tr => {
if (tr.nodeName !== 'TR' || !tr.classList.contains('topic-list-item')) {
return;
}
let id = tr.dataset.topicId;
if (data.includes(id)) {
tr.parentNode.removeChild(tr);
return;
}
let span = tr.querySelector('.link-top-line');
if (!span) {
return;
}
let a = document.createElement('a');
span.appendChild(a);
a.style.marginLeft = '1em';
a.style.fontSize = '75%';
a.href = 'javascript:';
a.appendChild(document.createTextNode('(Hide)'));
a.addEventListener('click', function (event) {
event.preventDefault();
event.stopPropagation();
tr.style.display = 'none';
data.push(id);
GM.setValue('hidden', JSON.stringify(data));
}, {capture: true});
});
});
})).observe(document.body, {childList: true, subtree: true});
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment