Gerne teile ich mein überarbeitetes UserScript.
Update: auf vielfachen Wunsch einer einzelnen Person wurde jetzt auch der Selbst- und Fremdbeweihräucherungsmodus eliminiert.
// ==UserScript==
// @name Unshow PuF hecklers
// @namespace https://tampermonkey.net/
// @match https://www.pilotundflugzeug.de/forum/*
// @match https://www.pilotundflugzeug.de/artikel/*
// @version 1.0
// @description Deletes the two subsequent <tr> if the previous <tr> contains any specified name.
// @grant none
// ==/UserScript==
(function() {
'use strict';
// Multi-line string of names to check for
var namesToCheckString = `
Statler
Waldorf
`;
// Convert the multi-line string into an array, trimming each line to remove any extra spaces
var namesToCheck = namesToCheckString.trim().split('\n').map(function(name) {
return name.trim();
});
// Get all <tr> elements in the document
var trs = document.querySelectorAll('tr');
// Iterate through the <tr> elements
for (var i = 0; i < trs.length - 1; i++) {
// Check if the current <tr> contains "Von"
var containsVon = trs[i].innerText.includes("Von");
// Check if the current <tr> contains any name from the array, and that it is not preceded by "an"
var containsName = namesToCheck.some(function(name) {
var nameIndex = trs[i].innerText.indexOf(name);
// Ensure the name is not preceded by "an"
var precededByAn = false;
if (nameIndex > 0) {
var textBeforeName = trs[i].innerText.substring(0, nameIndex).trim();
precededByAn = textBeforeName.endsWith("an");
}
return nameIndex !== -1 && !precededByAn;
});
// If "Von" is found and a name is found without being preceded by "an", remove the next two <tr> elements
if (containsVon && containsName) {
// Remove the span containing "Bewertung: " in the current <tr>
var spans = trs[i].querySelectorAll('span');
spans.forEach(function(span) {
if (span.innerText.includes("Bewertung: ")) {
span.remove();
}
});
if (i + 1 < trs.length) trs[i + 1].remove();
if (i + 2 < trs.length) trs[i + 2].remove();
}
}
})();