// ==UserScript== // @name Auto Select Deleted Threads // @namespace http://tampermonkey.net/ // @version 1.0.0 // @description Auto select deleted threads based on user preference. // @author Ryahn // @match https://f95zone.to/forums/* // @grant GM.setValue // @grant GM.getValue // ==/UserScript== (function() { 'use strict'; function createSettingsBar() { const settingsBar = document.createElement('div'); settingsBar.style.float = 'right'; settingsBar.style.marginRight = '10px'; const selectLabel = document.createElement('label'); selectLabel.textContent = 'Auto Select Deleted: '; const select = document.createElement('select'); const optionYes = document.createElement('option'); optionYes.value = 'yes'; optionYes.textContent = 'Yes'; const optionNo = document.createElement('option'); optionNo.value = 'no'; optionNo.textContent = 'No'; select.appendChild(optionYes); select.appendChild(optionNo); settingsBar.appendChild(selectLabel); settingsBar.appendChild(select); const targetDiv = document.querySelector('#top > div.uix_headerContainer > div.breadcrumb.block > div'); if (targetDiv) { targetDiv.appendChild(settingsBar); } GM.getValue('autoSelectDeleted', 'no').then(value => { select.value = value; }); select.addEventListener('change', function() { GM.setValue('autoSelectDeleted', this.value); applyAutoSelect(); }); } function triggerEvent(element, eventType) { const event = new Event(eventType, { bubbles: true }); element.dispatchEvent(event); } function applyAutoSelect() { GM.getValue('autoSelectDeleted', 'no').then(value => { const deletedThreads = document.querySelectorAll('.is-deleted input[type="checkbox"]'); deletedThreads.forEach(checkbox => { if (value === 'yes') { checkbox.checked = true; triggerEvent(checkbox, 'click'); triggerEvent(checkbox, 'change'); } else { checkbox.checked = false; triggerEvent(checkbox, 'click'); triggerEvent(checkbox, 'change'); } }); }); } window.addEventListener('load', function() { createSettingsBar(); applyAutoSelect(); }); })();