Emojis for old reddit

Enables subreddit specific emoji display on old reddit.

< 腳本Emojis for old reddit的回應

評論:OK - script works, but has bugs

§
發表於:2022-11-10

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/

auxermen作者
§
發表於:2022-11-29

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

§
發表於:2023-01-10

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

§
發表於:2023-05-30
編輯:2023-05-30

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)

auxermen作者
§
發表於:2023-10-15

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

發表回覆

登入以回復