// ==UserScript==
// @name        Make Sure Quick Reply is Cleared on 8chanmoe
// @namespace   pcgia
// @description Make sure quick reply is cleared on 8chanmoe
// @match       https://8chan.moe/*/res/*
// @match       https://8chan.se/*/res/*
// @version     1
// @grant       none
// @run-at      document-end
// @author      Starknight
// @version     1.0.0
// ==/UserScript==
const qreply = document.getElementById('quick-reply');
if (!qreply) {
  console.error('I can\'t find Quick Reply... :(');
  return;
}

const btn = qreply.querySelector('table > tbody th > a.close-btn');
if (!btn) {
  console.error('I can\'t find the close button... :(');
  return;
}

const textarea = qreply.querySelector('table > tbody tr td > textarea');
if (!textarea) {
  console.error('I can\'t find the Quick Reply text area... :(');
  return;
}

btn.addEventListener('click', function (_e) {
  const visible = Array.from(document.querySelectorAll('.postCell'))
                       .filter((e) => (e.getBoundingClientRect().y > 0));
  const offsets = visible.map((e) => (e.offsetTop));
  const last = (offsets.length > 0) ? offsets[0] : document.body.scrollHeight;
  location.hash = '';
  window.scrollTo(0, last);
  textarea.value = '';
});
Edit Report
Pub: 21 Apr 2025 00:24 UTC
Views: 29