F95 Game Post Only

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

As of 2024-12-31. See the latest version.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

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

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

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

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

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

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