Sleazy Fork is available in English.

Purge E(x)Hentai Chinese Comments

Purge shitty Chinese comments.

// ==UserScript==
// @name         Purge E(x)Hentai Chinese Comments
// @namespace    https://ehentai.example.invalid/
// @version      0.2
// @description  Purge shitty Chinese comments.
// @author       SomeRandomieLone
// @license      MIT
// @match        https://*e-hentai.org/g/*
// @match        https://exhentai.org/g/*
// @icon         https://e-hentai.org/favicon.ico
// @grant        none
// ==/UserScript==
(function(){
// deno-fmt-ignore-file
// deno-lint-ignore-file
// This code was bundled using `deno bundle` and it's not recommended to edit it manually

const Tweaks = Object.freeze({
    ChineseThreshold: 0.15,
    HideUploaderComment: false
});
function IsLikelyChinese(text) {
    const chn_chars = Array.from(text).filter((c)=>"\u4E00" <= c && c <= "\u9FFF");
    return chn_chars.length / text.length >= Tweaks.ChineseThreshold;
}
function SelectComments() {
    const elems = document.querySelectorAll(`div#cdiv.gm > div.c1`);
    return Array.from(elems).map((e)=>new CommentBlock(e));
}
class CommentBlock {
    element;
    constructor(element){
        this.element = element;
    }
    content() {
        return this.element.querySelector(`div[id^="comment_"]`)?.innerText ?? "";
    }
    is_chinese() {
        return IsLikelyChinese(this.content());
    }
    is_uploader() {
        return this.element.querySelector(`a[name='ulcomment']`) != null;
    }
    hide() {
        this.element.style.display = "none";
    }
}
let purge_counter = 0;
for (const comment of SelectComments()){
    if (!comment.is_chinese()) continue;
    if (comment.is_uploader() && !Tweaks.HideUploaderComment) continue;
    comment.hide();
    purge_counter++;
}
console.log(`Hide ${purge_counter} Chinese comment(s)`);

})()