F95 Game Post Only

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

От 06.01.2025. Виж последната версия.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey, Greasemonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Violentmonkey.

За да инсталирате този скрипт, трябва да имате инсталирано разширение като Tampermonkey или Userscripts.

За да инсталирате скрипта, трябва да инсталирате разширение като Tampermonkey.

За да инсталирате този скрипт, трябва да имате инсталиран скриптов мениджър.

(Вече имам скриптов мениджър, искам да го инсталирам!)

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да инсталирате разширение като Stylus.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

За да инсталирате този стил, трябва да имате инсталиран мениджър на потребителски стилове.

(Вече имам инсталиран мениджър на стиловете, искам да го инсталирам!)

// ==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.1
// @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 removeAccountItems(){
    let accIcon = document.querySelector("a.p-navgroup-link--user, .offCanvasMenu");
    await deleteEls(accIcon);
  }

  async function removeReplyItems() {
    let replyForm = document.querySelector('form.js-quickReply');
    await !!replyForm ? deleteEls(replyForm) : null;

    let replyActions = document.querySelectorAll('a.actionBar-action--mq,  a.actionBar-action--reply');
    await !!replyActions ? deleteEls(replyActions) : null;
  }

  async function removeRecomendations() {
    let recomendationSection = document.querySelector('div.block--similarContents');
    await !!recomendationSection ? deleteEls(recomendationSection) : null;
  }

  async function showFirstPostOnly() {
    //Thread Post Container Ref
    let opContainer = document.querySelector("article.message-threadStarterPost").parentNode;
    opContainer.replaceChildren(opContainer.children.item(0));

    let paginations = document.querySelectorAll('.pageNavWrapper--mixed');
    //top pagination
    let topPageContainer = paginations[0].parentNode.parentNode;
    await !!topPageContainer ? deleteEls(topPageContainer) : null;

    //bottom pagination
    let bottomPageContainer = paginations[1].parentNode.parentNode;
    await !!bottomPageContainer ? deleteEls(bottomPageContainer) : null;

    //Scrollbar buttons
    let scrollbarContainer = document.querySelector('div.u-scrollButtons').parentNode;
    await !!scrollbarContainer ? deleteEls(scrollbarContainer) : null;
  }

  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 removeRecomendations();//Removes the similar threads section at the bottom of the page
    await removeReplyItems();//Removes reply related elements from the page
    //await removeAccountItems();
  }

})().catch((err)=> console.error(err));