Greasy Fork is available in English.

Hide discussion

try to take over the world!

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey, Greasemonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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

คุณจะต้องติดตั้งส่วนขยาย เช่น Tampermonkey หรือ Violentmonkey เพื่อติดตั้งสคริปต์นี้

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         Hide discussion
// @namespace    http://tampermonkey.net/
// @version      0.1
// @description  try to take over the world!
// @author       You
// @match        https://mangalib.me/*
// @grant        none
// ==/UserScript==

(function() {
    setTimeout(SetEve, 500);
    setTimeout(Go, 1000);

    function SetEve() {
      if (document.querySelector('.f-categories')) {
        document.querySelector('.f-categories').addEventListener("click",function(e) {
	      setTimeout(Go, 500);
        });
      }
    }

    function Go() {
      if (document.querySelector('.f-pagination')) {
        document.querySelector('.f-pagination').addEventListener("click",function(e) {
	      setTimeout(Go, 500);
        });
      }
      hideItems();
      addButtons();
    }

    function hideItems() {
      var discusArr = document.getElementsByClassName('discussion-item');
      for (var i = 0; i < discusArr.length; i++) {
        var disscusId = discusArr[i].querySelector('.link-default').href.match(/\/forum\/discussion\/(.*)/)[1];
        if (localStorage.getItem("hide" + disscusId)) {
          discusArr[i].style.display = 'none';
          console.log("Hide: " + disscusId);
        }
      }
    }

    function addButtons() {
      var discusArr = document.getElementsByClassName('discussion-item');
      for (var i = 0; i < discusArr.length; i++) {
        var button = document.createElement("button");
        button.setAttribute("style", "float: right");
        button.innerHTML = 'X';
        button.onclick = function(e) {
          var id = e.target.parentNode.firstChild.href.match(/\/forum\/discussion\/(.*)/)[1];
          localStorage.setItem("hide" + id, 1);
          console.log("hide" + id);
          e.target.closest('.discussion-item').style.display = 'none';
        };
        discusArr[i].querySelector('h2').setAttribute("style", "margin-right: 0px");
        discusArr[i].querySelector('h2').appendChild(button);
      }
    }

})();