From 868c0d7d80865b57ff67289c1fb16465b9a03ca5 Mon Sep 17 00:00:00 2001 From: Fenrir784 Date: Thu, 9 Jul 2026 22:44:50 +0300 Subject: [PATCH 1/6] Category exclusions --- static/css/style.css | 39 +++++++++++++++++++++++++++++++++++++++ static/js/script.js | 42 +++++++++++++++++++++++++++++++++++++++--- templates/index.html | 1 + 3 files changed, 79 insertions(+), 3 deletions(-) diff --git a/static/css/style.css b/static/css/style.css index 1f1889a..ee5a238 100644 --- a/static/css/style.css +++ b/static/css/style.css @@ -595,6 +595,45 @@ h1 { color: var(--confident-bg); text-transform: uppercase; } +.category-header-actions { + display: flex; + align-items: center; + gap: 0.3rem; + margin-left: auto; +} +.category-toggle-btn { + background: none; + border: none; + cursor: pointer; + font-size: 0.8rem; + color: var(--low-text); + padding: 0.1rem 0.3rem; + border-radius: 4px; + opacity: 0.4; + transition: opacity 0.2s; + touch-action: manipulation; + line-height: 1; +} +.category-toggle-btn:hover { opacity: 1; } +.category-always-hide { + font-size: 0.7rem; + color: var(--low-text); + cursor: pointer; + opacity: 0.6; + white-space: nowrap; + transition: opacity 0.2s, color 0.2s; +} +.category-always-hide:hover { opacity: 1; } +.category-always-hide.active { + color: var(--confident-bg); + opacity: 1; +} +.category-block.category-hidden { + opacity: 0.35; +} +.category-block.category-hidden .tag { + pointer-events: none; +} .category-tags { display: flex; flex-wrap: wrap; gap: 0.27rem; } .tag { diff --git a/static/js/script.js b/static/js/script.js index 61fd7dd..1b82fde 100644 --- a/static/js/script.js +++ b/static/js/script.js @@ -56,6 +56,8 @@ document.addEventListener('DOMContentLoaded', () => { let maxTags = 200; let autoMetaTagSet = new Set(); let perTagAutoDisable = new Set(); + let hiddenCategories = new Set(); + let alwaysHiddenCategories = new Set(); const tagDescriptionCache = new Map(); let currentPopup = null; @@ -83,6 +85,7 @@ document.addEventListener('DOMContentLoaded', () => { activePreset = settings.activePreset ?? 'standard'; maxTags = settings.maxTags ?? 200; if (!ALLOWED_MAX_TAGS.includes(maxTags)) maxTags = 200; + alwaysHiddenCategories = new Set(settings.alwaysHiddenCategories || []); document.querySelectorAll('#themeToggle .theme-option').forEach(btn => { btn.classList.toggle('active', btn.dataset.value === currentTheme); @@ -111,7 +114,8 @@ document.addEventListener('DOMContentLoaded', () => { function saveSettings() { localStorage.setItem('e621tagger-settings', JSON.stringify({ allThreshold, confidentThreshold, defaultFormat: savedFormat, - theme: currentTheme, activePreset, maxTags + theme: currentTheme, activePreset, maxTags, + alwaysHiddenCategories: [...alwaysHiddenCategories] })); } @@ -435,7 +439,7 @@ function refreshTagClasses() { } function filterTags(threshold) { - return allTags.filter(t => !ratingTags.has(t.tag) && isTagIncluded(t, threshold)); + return allTags.filter(t => !ratingTags.has(t.tag) && !hiddenCategories.has(t.category) && isTagIncluded(t, threshold)); } function formatTags(tags) { @@ -587,11 +591,17 @@ function refreshTagClasses() { return a.localeCompare(b); }).forEach(cat => { const catTags = grouped[cat]; + const isHidden = hiddenCategories.has(cat); + const isAlways = alwaysHiddenCategories.has(cat); const catDiv = document.createElement('div'); - catDiv.className = 'category-block'; + catDiv.className = 'category-block' + (isHidden ? ' category-hidden' : ''); catDiv.innerHTML = `
${escapeHtml(cat)} +
+ ${isAlways ? '✓ Always hide' : 'Always hide'} + +
`; @@ -616,6 +626,28 @@ function refreshTagClasses() { attachTagEvents(tagEl, item); tagsContainer.appendChild(tagEl); }); + const toggleBtn = catDiv.querySelector('.category-toggle-btn'); + toggleBtn.addEventListener('click', (e) => { + e.stopPropagation(); + if (hiddenCategories.has(cat)) { + hiddenCategories.delete(cat); + } else { + hiddenCategories.add(cat); + } + displayTags(allTags); + }); + const alwaysHideEl = catDiv.querySelector('.category-always-hide'); + alwaysHideEl.addEventListener('click', (e) => { + e.stopPropagation(); + if (alwaysHiddenCategories.has(cat)) { + alwaysHiddenCategories.delete(cat); + } else { + alwaysHiddenCategories.add(cat); + hiddenCategories.add(cat); + } + saveSettings(); + displayTags(allTags); + }); categoriesContainer.appendChild(catDiv); }); } @@ -691,6 +723,7 @@ function refreshTagClasses() { autoMetaTagSet = new Set(autoMeta); addedTags.clear(); removedTags.clear(); + hiddenCategories = new Set(alwaysHiddenCategories); currentFormat = savedFormat; updateLocalFormatUI(); displayTags(allTags); @@ -760,6 +793,8 @@ function refreshTagClasses() { attachHammerTap(resetBtn, () => { allThreshold = 0.60; confidentThreshold = 0.70; savedFormat = 'e621'; currentFormat = savedFormat; currentTheme = 'system'; activePreset = 'standard'; maxTags = 200; + alwaysHiddenCategories.clear(); + hiddenCategories.clear(); document.querySelectorAll('#themeToggle .theme-option').forEach(btn => { btn.classList.toggle('active', btn.dataset.value === 'system'); @@ -774,6 +809,7 @@ function refreshTagClasses() { updateTheme('system'); applyThresholds(); saveSettings(); + if (allTags.length) displayTags(allTags); }); presetBtns.forEach(btn => { diff --git a/templates/index.html b/templates/index.html index b7bd401..95972f1 100644 --- a/templates/index.html +++ b/templates/index.html @@ -209,6 +209,7 @@

💡 Extra features
• PWA: Install the app via the browser's "Install" button for quick access.
+ • Category toggle: Click ✕ on any category header to gray it out and exclude those tags from copying. Click ✓ to reveal. While hidden, tap "Always hide" to save the preference permanently.
• Privacy: All processing is done locally on the server and no data is sent to third parties.