-
Notifications
You must be signed in to change notification settings - Fork 178
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This fix addresses cover-protection in order to let users save full-size images.
- Loading branch information
1 parent
5564b96
commit 7bd9d26
Showing
1 changed file
with
24 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,27 +1,32 @@ | ||
var hoverZoomPlugins = hoverZoomPlugins || []; | ||
hoverZoomPlugins.push( { | ||
name: 'shein', | ||
version: '1.0', | ||
version: '1.1', | ||
favicon:'shein.ico', | ||
prepareImgLinks: function(callback) { | ||
var res = []; | ||
|
||
// sample: https://img.ltwebstatic.com/images3_pi/2022/01/06/164143298217b45c1da8a1c07351af19a5ff72327e_thumbnail_220x293.webp | ||
// fullsize: https://img.ltwebstatic.com/images3_pi/2022/01/06/164143298217b45c1da8a1c07351af19a5ff72327e.webp | ||
hoverZoom.urlReplace(res, | ||
'img[src],div', | ||
/_thumbnail.*\./, | ||
'.', | ||
'a' | ||
); | ||
|
||
// sample: https://img.ltwebstatic.com/images3_pi/2022/01/06/164143298217b45c1da8a1c07351af19a5ff72327e_thumbnail_220x293.webp | ||
// fullsize: https://img.ltwebstatic.com/images3_pi/2022/01/06/164143298217b45c1da8a1c07351af19a5ff72327e.webp | ||
hoverZoom.urlReplace(res, | ||
'img[src],div', | ||
/_thumbnail.*\./, | ||
'.' | ||
); | ||
$('img[data-src], img[src*="_thumbnail"]').one('mouseover', function() { | ||
const src = this.dataset.src || this.src; | ||
const link = $(this); | ||
const largeUrl = src.replace(/_thumbnail.*\./, '.'); | ||
link.data().hoverZoomSrc = [largeUrl]; | ||
link.addClass('hoverZoomLink'); | ||
callback(link, this.name); | ||
hoverZoom.displayPicFromElement(link); | ||
}); | ||
|
||
// deals with cover-protection (#1203) | ||
$('.cover-frame').one('mouseover', function() { | ||
const link = $(this); | ||
if (link.siblings('img:not(.lazyload)').length != 1) return; | ||
const img = link.siblings('img:not(.lazyload)')[0]; | ||
const src = img.dataset.src || img.src; | ||
const largeUrl = src.replace(/_thumbnail.*\./, '.'); | ||
link.data().hoverZoomSrc = [largeUrl]; | ||
link.addClass('hoverZoomLink'); | ||
callback(link, this.name); | ||
hoverZoom.displayPicFromElement(link); | ||
}); | ||
|
||
callback($(res), this.name); | ||
} | ||
}); |