Skip to content

Commit

Permalink
Added discord hover thingy
Browse files Browse the repository at this point in the history
  • Loading branch information
Erallie committed Nov 27, 2024
1 parent eec8541 commit a7da0f9
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ export default class DiscordTimestamps extends Plugin {
let match;
let textSlices: string[] = [];
let timestampSlices: string[] = [];
let timestampHover: string[] = [];
while ((match = /<t:(\d{10}):([dDtTfFR])>/g.exec(text)) !== null) {
let time = moment(match[1], 'X', true);
let format;
Expand Down Expand Up @@ -62,6 +63,7 @@ export default class DiscordTimestamps extends Plugin {
textSlices.push(text.slice(0, text.indexOf(match[0])))
text = text.slice(text.indexOf(match[0]) + match[0].length);
timestampSlices.push(timeParsed);
timestampHover.push(time.format("LLLL"));
// text = text.replace(match[0], timeParsed);
// let newElement = element;

Expand All @@ -77,7 +79,7 @@ export default class DiscordTimestamps extends Plugin {
newEl.appendText(textSlices[i]);
}
if (i < timestampSlices.length) {
newEl.createEl('span', { text: timestampSlices[i], cls: 'discord-timestamps' })
newEl.createEl('span', { text: timestampSlices[i], cls: 'discord-timestamps' }).ariaLabel = timestampHover[i]
}
}

Expand Down

0 comments on commit a7da0f9

Please sign in to comment.