Reddit expand media and comments

Shows pictures and some videos right after the link, loads and expands comment threads.

< Feedback on Reddit expand media and comments

Review: Good - script works

§
Posted: 2020-10-03

Hi, thanks for making this script! Just wondering if you accept new rules? I added imgshare.io, freeimage.host, pasteall.org, and also added imgur links that are just 7 alphanumeric characters with no file extension. Most of them use that og:image meta property attribute.


  u: 'imgur.com/',
  r: /.com\/[a-zA-Z0-9]{7}$/,
  q: 'meta[property="og:image"]',
}, {
  u: '//imgshare.io/image/',
  r: /\.io\/image\/.+/,
  q: 'meta[property="og:image"]',
  xhr: true,
}, {
  u: '//pasteall.org/',
  r: /.org\/.+/,
  q: doc => {
    // Note: work-around because the img src attribute begins with a "/",
    // and will get expanded to reddit.com rather than pasteall.org.
    const img = doc.querySelector('.center-fit');
    return img && "https://pasteall.org/" + img.getAttribute("src");
  },
}, {
  u: '//freeimage.host/i/',
  r: /\.host\/i\/.+/,
  q: 'meta[property="og:image"]',
  xhr: true,
}, {

Also, had to add these @connects:


// @connect        imgshare.io
// @connect        freeimage.host
// @connect        iili.io
// @connect        pasteall.org

Note: freeimage.host uses iili.io for the images, and it seemed they were both needed.

Sorry, I don't have any test links, but I often find these random image hosting sites on /r/Daily3D (a subreddit for 3D modeling prompts), and /r/blenderhelp (subreddit for help with Blender)

wOxxOmAuthor
§
Posted: 2020-10-03
Edited: 2020-10-03

Thanks.

  • I think the new imgur rule can be integrated in the existing one if you add , meta[property="og:image"] to the end of its q.
  • The src attribute workaround is not needed anymore, I've added a proper fix in expandRemoteFromSelector, hopefully

Since I don't have examples of those images, could you verify this updated script works?

wOxxOmAuthor
§
Posted: 2020-10-03

Now there's no need for r rule like \.com/.+ for the sole purpose of indicating that something should follow the part matched by u.

I've published the updated script, everything seems to work.

§
Posted: 2020-10-03

Thanks for adding those rules. It looks like they all work except the pasteall.org one. The problem with that one is that the tag it finds basically looks like <img src="/media/image.jpg">, and since the script is still running on reddit.com, when you use el.src (line 373) to get the URL, it changes to reddit.com/media/image.jpg. In my work-around function, I just got the exact string of the src attribute and prefixed it with "pasteall.org".

If you want to test, I made a reddit post with some image links I found in my history:

wOxxOmAuthor
§
Posted: 2020-10-04

Thanks. That fix was wrong, 0.4.8 is now using the proper fix via <base> element.

§
Posted: 2020-10-04

Excellent! Confirmed everything is working properly now. Much appreciated :)

§
Posted: 2020-10-22

Found another image host called postimg.cc that uses og:image meta. Just need to add '//postimg.cc/' to the rule with META_OG_IMG and no xhr, and of course add a @connect for postimg.cc. I updated the reddit sandbox post, so you can test it.

wOxxOmAuthor
§
Posted: 2020-10-22

Thanks, added.

Post reply

Sign in to post a reply.