Discussions » Creation Requests
How to write a script for one site that only hides answers and comments from a specific profile? For example from this https://sprashivalka.com/8051423/answers
const blackList = [
8051423,
];
for (const id of blackList) {
const answers = document.querySelectorAll(`div.a > [href="/${id}"]`);
const comments = document.querySelectorAll(`div.c > [href="/${id}"]`);
for (const answer of answers) {
if (answer.parentElement.parentElement.matches('article.qa')) {
answer.parentElement.parentElement.remove();
}
}
for (const comment of comments) {
comment.parentElement.remove();
}
}
Thanks for the answer, but the script doesn't work correctly, it deletes everything that is on the page.
I don't get that
This link (from your OP) leads to all the answers of a specific user posted throughout the website: https://sprashivalka.com/8051423/answers
My code is intended to delete answers and comments from the questions pages, because I thought you need to hide answers from the questions pages like this: https://sprashivalka.com/questions/58003fa3
Otherwise, what's the point to hide answers of a user from the pages where there are could be only answers of this user and nobody elses?
For example, I may receive an answer to a question. But at the same time, I want the answers from a certain user to be hidden, but not completely, only to hide the text.
If the entire answer code is removed, then the delete and skip button will also be removed. I can't do without it.
I already tried to write myself, and asked for help. I tried
document.querySelectorAll("div > [href='/8051423'] > p[style] > p").forEach(function(elem) {
elem.remove();
})
but didn't work.