I have little to no coding experience, just basic HTML and CSS. This was generated entirely by ChatGPT with me giving the prompts. It took some trial and error but we got there:<p>// ==UserScript==
// @name Block GPT Posts on Hacker News
// @namespace http://tampermonkey.net/
// @version 0.1
// @description Block posts containing the term "GPT" on news.ycombinator.com and renumber the remaining posts
// @author You
// @match https://news.ycombinator.com/*
// @grant none
// ==/UserScript==<p>(function() {
'use strict';<p><pre><code> function getStartingNumber() {
const firstRankSpan = document.querySelector('span.rank');
if (firstRankSpan) {
const number = parseInt(firstRankSpan.textContent, 10);
return isNaN(number) ? 1 : number;
}
return 1;
}
function blockGPTPosts() {
const searchTerm = /GPT/i;
const titleLines = document.querySelectorAll('span.titleline');
const rankSpans = document.querySelectorAll('span.rank');
const startingNumber = getStartingNumber();
let visiblePosts = [];
titleLines.forEach((titleLine, index) => {
const postLink = titleLine.querySelector('a');
if (postLink && searchTerm.test(postLink.textContent)) {
const athingRow = titleLine.closest('tr.athing');
if (athingRow) {
athingRow.style.display = 'none';
const subtextRow = athingRow.nextElementSibling;
if (subtextRow && subtextRow.querySelector('td.subtext')) {
subtextRow.style.display = 'none';
}
}
} else {
visiblePosts.push(index);
}
});
visiblePosts.forEach((visiblePostIndex, index) => {
const postNumber = startingNumber + index;
if (rankSpans[visiblePostIndex]) {
rankSpans[visiblePostIndex].textContent = `${postNumber}.`;
}
});
}
// Wait for the content to load before executing the function
window.addEventListener('load', blockGPTPosts);</code></pre>
})();