Browse Source

Replace emojicodes with emojis in subject.

tags/0.2.0^0
tastytea 1 year ago
parent
commit
d5ffb1669a
Signed by: tastytea GPG Key ID: CFC39497F1B26E07
1 changed files with 14 additions and 8 deletions
  1. +14
    -8
      mastodon-api-comments.js

+ 14
- 8
mastodon-api-comments.js View File

@@ -43,13 +43,7 @@ function write_comments(root, data)
{
for (const status of data.descendants)
{
let content = status.content;
for (const emoji of status.emojis)
{
content = content.replace(
':' + emoji.shortcode + ':',
'<img class="mastodon-api-comment-emoji" src="' + emoji.url + '">');
}
const content = add_emojis(status.content, status.emojis);

const div = document.createElement("div");
div.setAttribute("class", "mastodon-api-comment");
@@ -66,6 +60,18 @@ function write_comments(root, data)
}
}

function add_emojis(text, emojis)
{
for (const emoji of emojis)
{
text = text.replace(
':' + emoji.shortcode + ':',
'<img class="mastodon-api-comment-emoji" src="' + emoji.url + '">');
}

return text;
}

function author_html(status)
{
const p = document.createElement("p");
@@ -92,7 +98,7 @@ function subject_html(status)
const p = document.createElement("p");
p.setAttribute("class", "mastodon-api-comment-subject");
const subject = document.createElement("strong");
subject.appendChild(document.createTextNode(status.spoiler_text));
subject.innerHTML += add_emojis(status.spoiler_text, status.emojis);
p.appendChild(subject);
return p;
}


Loading…
Cancel
Save