diff --git a/shaarli-pro/js/script.js b/shaarli-pro/js/script.js index 81156e8..e6e6036 100644 --- a/shaarli-pro/js/script.js +++ b/shaarli-pro/js/script.js @@ -129,14 +129,23 @@ document.addEventListener('DOMContentLoaded', () => { function fetchTags() { if (cachedTags) return cachedTags; try { - const tagElements = document.querySelectorAll('.link-tag, .tag-link, [class*="tag"]'); const tagsSet = new Set(); - tagElements.forEach(el => { - const tagText = el.textContent.trim(); - if (tagText && tagText.length > 0 && !tagText.includes('•')) { - tagsSet.add(tagText); - } + const addTag = (value) => { + if (typeof value !== 'string') return; + const cleaned = value.trim(); + if (!cleaned || cleaned.includes('•')) return; + tagsSet.add(cleaned); + }; + + // Prefer explicit tag data attributes to avoid polluted text values (e.g. remove buttons) + document.querySelectorAll('.link-tag[data-tag], .tag-item[data-tag], [data-tag-name]').forEach((el) => { + addTag(el.getAttribute('data-tag') || el.getAttribute('data-tag-name')); + }); + + // Fallback selectors with reliable text content + document.querySelectorAll('.link-tag-link, .tag-link, .cloud-tag').forEach((el) => { + addTag(el.textContent); }); // Convert to array and sort alphabetically @@ -428,6 +437,13 @@ document.addEventListener('DOMContentLoaded', () => { e.preventDefault(); openSearch(); } + + // T to open search directly in tags mode (when not typing) + if (!isTyping && !e.ctrlKey && !e.metaKey && !e.altKey && (e.key === 't' || e.key === 'T')) { + e.preventDefault(); + openSearch(); + setSearchMode('tags'); + } }); // ===== Filter Panel ===== diff --git a/shaarli-pro/page.header.html b/shaarli-pro/page.header.html index c812c5f..6881c74 100644 --- a/shaarli-pro/page.header.html +++ b/shaarli-pro/page.header.html @@ -286,6 +286,7 @@ Bookmarklet detection logic