2022-02-23 13:52:06 +00:00
|
|
|
import Settings from '../settings.js';
|
|
|
|
import {log, querySelectorAll} from '../utilities/exports.js';
|
2020-10-10 23:32:27 +00:00
|
|
|
|
|
|
|
export function runHideVotesFeature(settings: Settings) {
|
|
|
|
hideVotes(settings);
|
|
|
|
log('Hide Votes: Initialized.');
|
|
|
|
}
|
|
|
|
|
|
|
|
function hideVotes(settings: Settings) {
|
|
|
|
if (settings.data.hideVotes.comments) {
|
|
|
|
const commentVotes = querySelectorAll(
|
|
|
|
'.btn-post-action[data-ic-put-to*="/vote"]:not(.trx-votes-hidden)',
|
2022-02-23 13:52:06 +00:00
|
|
|
'.btn-post-action[data-ic-delete-from*="/vote"]:not(.trx-votes-hidden)',
|
2020-10-10 23:32:27 +00:00
|
|
|
);
|
|
|
|
|
|
|
|
for (const vote of commentVotes) {
|
|
|
|
vote.classList.add('trx-votes-hidden');
|
|
|
|
vote.textContent = vote.textContent!.slice(
|
|
|
|
0,
|
2022-02-23 13:52:06 +00:00
|
|
|
vote.textContent!.indexOf(' '),
|
2020-10-10 23:32:27 +00:00
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.data.hideVotes.ownComments) {
|
|
|
|
for (const vote of querySelectorAll('.comment-votes')) {
|
|
|
|
vote.classList.add('trx-hidden');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (settings.data.hideVotes.topics || settings.data.hideVotes.ownTopics) {
|
|
|
|
const selectors: string[] = [];
|
|
|
|
|
|
|
|
// Topics by other people will be encapsulated with a `<button>`.
|
|
|
|
if (settings.data.hideVotes.topics) {
|
|
|
|
selectors.push('button > .topic-voting-votes:not(.trx-votes-hidden)');
|
|
|
|
}
|
|
|
|
|
|
|
|
// Topics by yourself will be encapsulated with a `<div>`.
|
|
|
|
if (settings.data.hideVotes.ownTopics) {
|
|
|
|
selectors.push('div > .topic-voting-votes:not(.trx-votes-hidden)');
|
|
|
|
}
|
|
|
|
|
|
|
|
for (const vote of querySelectorAll(...selectors)) {
|
|
|
|
vote.classList.add('trx-votes-hidden');
|
|
|
|
vote.textContent = '-';
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|