Skip to content

Commit

Permalink
Load reddit galleries on mouse over. Fixes #1257
Browse files Browse the repository at this point in the history
  • Loading branch information
extesy committed Jul 6, 2024
1 parent 8726075 commit e2d71fb
Showing 1 changed file with 13 additions and 4 deletions.
17 changes: 13 additions & 4 deletions plugins/reddit.js
Original file line number Diff line number Diff line change
Expand Up @@ -117,32 +117,41 @@ hoverZoomPlugins.push({
if (img.length === 0)
img = post;
hoverZoom.prepareLink(img, src);
post.data().hoverZoomMouseOver = false;
}
}
}

$('div[data-url*="//www.reddit.com/gallery/"]').each(function () {
$('div[data-url*="//www.reddit.com/gallery/"]').one('mouseover', function () {
var post = $(this);
if (post.data().hoverZoomMouseOver) return;
post.data().hoverZoomMouseOver = true;
var link = post.attr('data-url');
var galleryid = link.substring(link.lastIndexOf('/') + 1);
$.get('https://www.reddit.com/by_id/t3_' + galleryid + '.json?raw_json=1', data => processGalleryResponse(post, data));
});

$('a[href*="//www.reddit.com/gallery/"]').each(function () {
$('a[href*="//www.reddit.com/gallery/"]').one('mouseover', function () {
var post = $(this);
if (post.data().hoverZoomMouseOver) return;
post.data().hoverZoomMouseOver = true;
var link = post.attr('href');
var galleryid = link.substring(link.lastIndexOf('/') + 1);
$.get('https://www.reddit.com/by_id/t3_' + galleryid + '.json?raw_json=1', data => processGalleryResponse(post, data));
});

$('div[data-is-gallery=true]').each(function () {
$('div[data-is-gallery=true]').one('mouseover', function () {
var post = $(this);
if (post.data().hoverZoomMouseOver) return;
post.data().hoverZoomMouseOver = true;
var galleryid = post.attr('data-fullname');
$.get('https://www.reddit.com/by_id/' + galleryid + '.json?raw_json=1', data => processGalleryResponse(post, data));
});

$('gallery-carousel').each(function () {
$('gallery-carousel').one('mouseover', function () {
var post = $(this);
if (post.data().hoverZoomMouseOver) return;
post.data().hoverZoomMouseOver = true;
var galleryid = post.attr('post-id');
$.get('https://www.reddit.com/by_id/' + galleryid + '.json?raw_json=1', data => processGalleryResponse(post, data));
});
Expand Down

0 comments on commit e2d71fb

Please sign in to comment.