Greasy Fork

Greasy Fork is available in English.

Memeflag hider v2

hides memeflag threads and replies, updated 4th Jan 2022

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Memeflag hider v2
// @version      2.0
// @description  hides memeflag threads and replies, updated 4th Jan 2022
// @author       beige
// @grant        none
// @include      http*://*.4chan.org/pol/*
// @run-at       document-idle
// @namespace    http://greasyfork.icu/en/scripts/438016-memeflag-hider-v2
// @license      ayyylmao
// ==/UserScript==

// forked from http://greasyfork.icu/users/250780 -- 4th Jan 2022

// uses the built in thread hiding mechanism from the 4chan ext. except in catalog where we just nuke things from a global object. 


(function () {
  "use strict";

  let HIDE_MEMEFLAG_THREADS = true;
  let HIDE_MEMEFLAG_REPLIES = true;

  // hide memeflag threads in catalog
  if (window.location.href.indexOf("pol/catalog") > -1) {
    // catalog is a global
    // memeflag thread countries are "undefined" in /catalog  -- 4th Jan 2022
    let memeflaggotthreads = [];
    Object.keys(catalog.threads).map(function (key, index) {
      if (catalog.threads[key].country === undefined) {
        memeflaggotthreads.push(key);
      }
    });

    memeflaggotthreads.forEach(
      (t) => {
        delete catalog.threads[t]
      }
    );
    // trigger thread list redraw without changing sort order
    document.querySelector('#order-ctrl').dispatchEvent(new Event('change'));

    let hidenum = document.createElement('span');
    hidenum.innerHTML = ` [${memeflaggotthreads.length} memeflags hidden]`;
    document.querySelector('.navLinks')?.appendChild(hidenum);

  } else {
    let hiddencnt = 0;
    if (HIDE_MEMEFLAG_THREADS && window.location.href.indexOf("pol/thread/") === -1) {
      var posts = document.getElementsByClassName("postContainer opContainer");
      for (var currentPostNumber = 0; currentPostNumber < posts.length; currentPostNumber++) {
        if (posts[currentPostNumber].getElementsByClassName("bfl").length || posts[currentPostNumber].getElementsByClassName("flag").length === 0) {
          ThreadHiding.hide(posts[currentPostNumber].id.substr(2));
          hiddencnt++;
        }
      }

    }
    if (HIDE_MEMEFLAG_REPLIES) {
      var replies = document.getElementsByClassName("postContainer replyContainer");
      for (var currentPostNumber = 0; currentPostNumber < replies.length; currentPostNumber++) {
        if (replies[currentPostNumber].getElementsByClassName("bfl").length || replies[currentPostNumber].getElementsByClassName("flag").length === 0) {
          ReplyHiding.hide(replies[currentPostNumber].id.substr(2));
          hiddencnt++;
        }
      }

    }

    let hidenumd = document.createElement('div');
    hidenumd.className = 'thread-stats';
    hidenumd.innerHTML = ` ${hiddencnt} memeflags hidden / `;
    document.querySelector('.navLinks.desktop')?.appendChild(hidenumd);
    document.querySelector('#ctrl-top.desktop')?.appendChild(hidenumd);

  }

})();