Emojis for old reddit

Enables subreddit specific emoji display on old reddit.

< Opinie na Emojis for old reddit

Ocena: OK - skrypt działa, ale ma błędy

§
Napisano: 10-11-2022

works really good. however it messes with reddit new embedded images in comments feature. see: https://old.reddit.com/r/forsen/comments/yr9hzh/bags_images_in_comments_are_now_enabled/

auxermenAutor
§
Napisano: 29-11-2022

Thanks for the report, I'll see if I can fix it.

§
Napisano: 10-01-2023

I was able to get it to work by modifying the following code on line 76:

if (emojiIDArr[0] !== "emote" || emojiIDArr[1] == "free_emotes_pack") {
        // not a subreddit emoji (gifs are already displayed on old reddit)
        continue
}

to

if (emojiIDArr.length == 1){
    // reddit picture
    // replace img link text with <span><img> with max 200px height
    var pcs = commentData.html.split(emoji.s.u)
    var lastPc = pcs.pop()
    commentData.html = pcs.join((emoji.s.u)) + `<span style="display: inline-block; vertical-align: middle; line-height: 100%; margin: 0 2px;">
     <img src="${(emoji.s.u)}" height="${Math.min(emoji.s.y, 200)}" /></span>` + lastPc
    continue
} else if (emojiIDArr[0] !== "emote" || emojiIDArr[1] == "free_emotes_pack") {
    // not a subreddit emoji (gifs are already displayed on old reddit)
    continue
}

Not really the most elegant way, but it worked for me. You can make the max height larger than 200, that's just the size that worked for me

§
Napisano: 30-05-2023
Edytowano: 30-05-2023

I was able to get it to work by modifying the following code on line 76:
snip to
snip Not really the most elegant way, but it worked for me. You can make the max height larger than 200, that's just the size that worked for me

I was trying to get this to work with RES, and noticed that this didn't work with animated images, such as here. It seems that there is not emoji.s.u field in animated images, but there is a .gif field that we can use:

let url = emoji.s.u;
if (!url) {
    url = emoji.s.gif;
}
var pcs = commentData.html.split(url)
var lastPc = pcs.pop()
commentData.html = pcs.join((url)) + `<span style="display: inline-block; vertical-align: middle; line-height: 100%; margin: 0 2px;"><img src="${(url)}" height="${Math.min(emoji.s.y, 200)}" /></span>` + lastPc

Although it does get override the RES collapsible image feature on those images... (RES shows <image> with a collapsible without this extension)

auxermenAutor
§
Napisano: 15-10-2023

Thanks for the help, I included those fixes in latest release.

Odpowiedz

Zaloguj się, by odpowiedzieć.