Greasy Fork is available in English.

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

§
Posted: 2022.10.01.

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.

§
Posted: 2022.10.03.
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();
  }
}
§
Posted: 2022.10.05.

Thanks for the answer, but the script doesn't work correctly, it deletes everything that is on the page.

§
Posted: 2022.10.05.

For me, this would be the best result.

§
Posted: 2022.10.06.
Edited: 2022.10.06.

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?

§
Posted: 2022.10.06.

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.

§
Posted: 2022.10.06.
Edited: 2022.10.06.

If the entire answer code is removed, then the delete and skip button will also be removed. I can't do without it.

Post reply

Sign in to post a reply.