F95 Game Post Only

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

  1. // ==UserScript==
  2. // @name F95 Game Post Only
  3. // @namespace 1330126-edexal
  4. // @match *://f95zone.to/threads/*
  5. // @grant none
  6. // @icon https://external-content.duckduckgo.com/ip3/f95zone.to.ico
  7. // @license Unlicense
  8. // @version 2.0
  9. // @author Edexal
  10. // @description Display only the 1st post of a game thread. This completely removes all replies (and more) from the thread.
  11. // ==/UserScript==
  12. (()=> {
  13.  
  14. function deleteEls(el){
  15. if (el instanceof NodeList){
  16. el.forEach((curVal,curIndex)=>{
  17. curVal.remove();
  18. });
  19. } else if (el instanceof Element) {
  20. el.remove();
  21. }else{
  22. console.error(`Unable to delete ${el}! Element is of type: ${typeof el}.`);
  23. }
  24. }
  25.  
  26. function removeFooter(){
  27. let footer = document.querySelector("#footer");
  28. deleteEls(footer);
  29. }
  30.  
  31. function removeBreadcrumbs(){
  32. let breadcrumb = document.querySelectorAll(".breadcrumb");
  33. deleteEls(breadcrumb);
  34. }
  35.  
  36. function removeAccountItems(){
  37. let accIcon = document.querySelector("a.p-navgroup-link--user, .offCanvasMenu");
  38. deleteEls(accIcon);
  39. }
  40.  
  41. function removeReplyItems() {
  42. let replyForm = document.querySelector('form.js-quickReply');
  43. !!replyForm ? deleteEls(replyForm) : null;
  44.  
  45. let replyActions = document.querySelectorAll('a.actionBar-action--mq, a.actionBar-action--reply');
  46. !!replyActions ? deleteEls(replyActions) : null;
  47. }
  48.  
  49. function removeRecomendations() {
  50. let recomendationSection = document.querySelector('div.block--similarContents');
  51. !!recomendationSection ? deleteEls(recomendationSection) : null;
  52. }
  53.  
  54. function removePagination() {
  55. let paginations = document.querySelectorAll('.pageNavWrapper--mixed');
  56. if (!!!paginations.length)
  57. return;
  58. //top pagination
  59. let topPageContainer = paginations[0].parentNode.parentNode;
  60. !!topPageContainer ? deleteEls(topPageContainer) : null;
  61.  
  62. //bottom pagination
  63. let bottomPageContainer = paginations[1].parentNode.parentNode;
  64. !!bottomPageContainer ? deleteEls(bottomPageContainer) : null;
  65. }
  66.  
  67. function removeScrollbarBtns(){
  68. let scrollbarContainer = document.querySelector('div.u-scrollButtons').parentNode;
  69. !!scrollbarContainer ? deleteEls(scrollbarContainer) : null;
  70. }
  71.  
  72. function removeNavbar(){
  73. let navbar = document.querySelector('div#top > div:first-child');
  74. deleteEls(navbar);
  75. }
  76.  
  77. function showFirstPostOnly() {
  78. //Thread Post Container Ref
  79. let opContainer = document.querySelector("article.message-threadStarterPost").parentNode;
  80. opContainer.replaceChildren(opContainer.children.item(0));
  81. removePagination();
  82. removeScrollbarBtns();
  83. }
  84.  
  85. function isGameThread(){
  86. let breadcrumbID = document.querySelectorAll("ul.p-breadcrumbs li:nth-of-type(3) a span[itemprop=name]");
  87. let isGame = false;
  88. if (!!breadcrumbID.length){
  89. breadcrumbID.forEach((curVal, curIndex) => {
  90. if (curVal.textContent.toLowerCase() === "Games".toLowerCase()){
  91. isGame = true;
  92. }
  93. });
  94. }
  95. return isGame;
  96. }
  97.  
  98. /*Checks if thread is a GAME type*/
  99. if(isGameThread()){
  100. showFirstPostOnly();//
  101. /*-----------------------(Optional) Delete '//' for each option to activate----------------*/
  102. removeBreadcrumbs();
  103. removeFooter();
  104. removeRecomendations();//Removes the similar threads section at the bottom of the page
  105. removeReplyItems();//Removes reply related elements from the page
  106. //removeAccountItems();
  107. //removeNavbar();//Removes navigation bar at the top of the page
  108. }
  109.  
  110. })();