F95 Game Post Only

Display only the 1st post of a game thread. This completely removes all replies (and more) from the thread.

Versione datata 31/12/2024. Vedi la nuova versione l'ultima versione.

Dovrai installare un'estensione come Tampermonkey, Greasemonkey o Violentmonkey per installare questo script.

You will need to install an extension such as Tampermonkey to install this script.

Dovrai installare un'estensione come Tampermonkey o Violentmonkey per installare questo script.

Dovrai installare un'estensione come Tampermonkey o Userscripts per installare questo script.

Dovrai installare un'estensione come ad esempio Tampermonkey per installare questo script.

Dovrai installare un gestore di script utente per installare questo script.

(Ho già un gestore di script utente, lasciamelo installare!)

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione come ad esempio Stylus per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

Dovrai installare un'estensione per la gestione degli stili utente per installare questo stile.

(Ho già un gestore di stile utente, lasciamelo installare!)

// ==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));