diff --git a/source/scripts/hide-votes.ts b/source/scripts/hide-votes.ts index 867f230..ce50eae 100644 --- a/source/scripts/hide-votes.ts +++ b/source/scripts/hide-votes.ts @@ -2,16 +2,19 @@ import Settings from '../settings.js'; import {log, querySelectorAll} from '../utilities/exports.js'; export function runHideVotesFeature(settings: Settings) { - hideVotes(settings); - log('Hide Votes: Initialized.'); + const counts = hideVotes(settings); + log(`Hide Votes: Initialized for ${counts} votes.`); } -function hideVotes(settings: Settings) { +function hideVotes(settings: Settings): number { + let count = 0; + if (settings.data.hideVotes.comments) { const commentVotes = querySelectorAll( '.btn-post-action[data-ic-put-to*="/vote"]:not(.trx-votes-hidden)', '.btn-post-action[data-ic-delete-from*="/vote"]:not(.trx-votes-hidden)', ); + count += commentVotes.length; for (const vote of commentVotes) { vote.classList.add('trx-votes-hidden'); @@ -23,7 +26,9 @@ function hideVotes(settings: Settings) { } if (settings.data.hideVotes.ownComments) { - for (const vote of querySelectorAll('.comment-votes')) { + const ownComments = querySelectorAll('.comment-votes'); + count += ownComments.length; + for (const vote of ownComments) { vote.classList.add('trx-hidden'); } } @@ -41,9 +46,13 @@ function hideVotes(settings: Settings) { selectors.push('div > .topic-voting-votes:not(.trx-votes-hidden)'); } - for (const vote of querySelectorAll(...selectors)) { + const topicVotes = querySelectorAll(...selectors); + count += topicVotes.length; + for (const vote of topicVotes) { vote.classList.add('trx-votes-hidden'); vote.textContent = '-'; } } + + return count; } diff --git a/source/scripts/markdown-toolbar.ts b/source/scripts/markdown-toolbar.ts index 420c7a1..b211c93 100644 --- a/source/scripts/markdown-toolbar.ts +++ b/source/scripts/markdown-toolbar.ts @@ -75,15 +75,15 @@ const snippets: MarkdownSnippet[] = [ })); export function runMarkdownToolbarFeature() { - addToolbarsToTextareas(); - log('Markdown Toolbar: Initialized.'); + const count = addToolbarsToTextareas(); + log(`Markdown Toolbar: Initialized for ${count} textareas.`); } -function addToolbarsToTextareas() { +function addToolbarsToTextareas(): number { // Grab all Markdown forms that don't have already have a toolbar. const markdownForms = querySelectorAll('.form-markdown:not(.trx-toolbar)'); if (markdownForms.length === 0) { - return; + return 0; } for (const form of markdownForms) { @@ -118,6 +118,8 @@ function addToolbarsToTextareas() { dropdownPlaceholder, ); } + + return markdownForms.length; } type Props = {