Display only the 1st post of a game thread. This completely removes all replies (and more) from the thread.
اعتبارا من
// ==UserScript==
// @name F95 Game Post Only
// @namespace 1330126-edexal
// @match http*://f95zone.to/threads/*
// @grant none
// @icon https://external-content.duckduckgo.com/ip3/f95zone.to.ico
// @license Unlicense
// @version 1.0
// @author Edexal
// @description Display only the 1st post of a game thread. This completely removes all replies (and more) from the thread.
// ==/UserScript==
(async function(){
function deleteEls(el){
if (el instanceof NodeList){
el.forEach((curVal,curIndex)=>{
curVal.remove();
});
} else if (el instanceof Element) {
el.remove();
}else{
console.error(`Unable to delete ${el}! Element is of type: ${typeof el}.`);
}
}
async function removeFooter(){
let footer = document.querySelector("#footer");
await deleteEls(footer);
}
async function removeBreadcrumbs(){
let breadcrumb = document.querySelectorAll(".breadcrumb");
await deleteEls(breadcrumb);
}
async function removeAccountIcon(){
let accIcon = document.querySelector("div.p-account .p-navgroup-link--user");
await !!accIcon ? deleteEls(accIcon) : undefined;
}
async function showFirstPostOnly() {
//Original Post Ref
let op = document.querySelector("article:first-of-type .message-cell--main");
//Holds all posts and replies in the game thread Ref
let postsDiv = document.querySelector("div.p-body-pageContent");
postsDiv.replaceWith(op);
}
function isGameThread(){
let breadcrumbID = document.querySelectorAll("ul.p-breadcrumbs li:nth-of-type(3) a span[itemprop=name]");
let isGame = false;
if (!!breadcrumbID.length){
breadcrumbID.forEach((curVal, curIndex) => {
if (curVal.textContent.toLowerCase() === "Games".toLowerCase()){
isGame = true;
}
});
}
return isGame;
}
/*Checks if thread is a GAME type*/
if(isGameThread()){
await showFirstPostOnly();//
/*-----------------------(Optional) Delete '//' for each option to activate----------------*/
//await removeBreadcrumbs();
await removeFooter();
//await removeAccountIcon();
}
})().catch((err)=> console.error(err));