Created
December 29, 2021 17:47
-
-
Save erorus/94ccd0488a914d71ef9d23491ae1a325 to your computer and use it in GitHub Desktop.
Hide API Forum Posts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==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