....for Chrome.
It doesn't only hide the blocked user's posts forever, but also hide any posts that contain quotes from the blocked user.
Demonstration: https://www.youtube.com/watch?v=B-zITW9 ... el=cupcake
And at the button you can find an unblock list; to unblock those that you may have accidentally blocked.
Code:
// ==UserScript==
// @name Block people.
// @namespace https://wrongplanet.net
// @version 0.1
// @description try to take over the world! Muhahaha
// @author The_Face_of_Boo
// @match https://wrongplanet.net/*
// @grant GM.getValue
// @grant GM.setValue
// ==/UserScript==
(async () => {
'use strict';
let stringBlockList = await GM.getValue('stringBlockList');
let blockList = stringBlockList ? stringBlockList.split(',') : [];
let blockDiv = document.createElement("div");
let unblockButton = document.createElement("button");
document.body.appendChild(blockDiv);
document.body.appendChild(unblockButton);
//Create and append select list
var selectList = document.createElement("select");
selectList.size = "5";
selectList.id = "mySelect";
unblockButton.innerText = 'Unblock';
blockDiv.appendChild(selectList);
unblockButton.addEventListener("click", unblockMe, false);
//Create and append the options
blockList.forEach(blockedUser => {
var option = document.createElement("option");
option.value = blockedUser;
option.text = blockedUser;
selectList.appendChild(option);
})
console.log(blockList);
let elements = document.querySelectorAll('div.row');
let blockButtonHtml = `<button class="myButton" style='background:darkred'>Block</button>`;
function blockMe(evt) {
blockList.push(evt.currentTarget.user);
GM.setValue('stringBlockList', blockList.toString());
window.alert(evt.currentTarget.user + " is blocked");
location.reload();
}
function unblockMe() {
let select = document.getElementById("mySelect");
let user = select.options[select.selectedIndex].value;
let index = blockList.findIndex(e => e == user);
let newlist = removeItemWithSlice(index, blockList);
GM.setValue('stringBlockList', newlist.toString());
window.alert(user + " is unblocked");
location.reload();
}
function removeItemWithSlice(index, arr) {
return [...arr.slice(0, index), ...arr.slice(index + 1)]
}
elements.forEach((element, index) => {
let user = element.querySelector('.user-col').querySelector('p').querySelector('a').innerText;
///adding the block button for each post in page
let buttonsRow = element.querySelector('.action-bar');
buttonsRow.insertAdjacentHTML('beforeend', blockButtonHtml);
let blockButton = buttonsRow.querySelector('.myButton');
if (blockButton) {
blockButton.addEventListener("click", blockMe, false);
blockButton.user = user;
}
if (blockList.includes(user)) {
elements[index].remove();
}
///Removing posts with blocked people's quotes.
let quoteElements = element.querySelectorAll('.quotetitle') || [];
quoteElements.forEach(el => {
let trimmed = el.textContent.trim();
let replaced = trimmed.replace('wrote:', '').trim();
if (blockList.includes(replaced)) {
elements[index].remove();
}
});
});
})();
That someone else's video shows how to add the script:
https://www.youtube.com/watch?v=RpjvLpy ... nel=JayJay