⎗ ✓ 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39// ==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 = ''; });