Created
May 28, 2017 18:44
-
-
Save vitqst/eae87a0637d5c28b10790831521bbb09 to your computer and use it in GitHub Desktop.
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
$(document).ready(function(){ | |
const regex = /(.*)(?=in)/g; | |
var nowUrl = window.location.href; | |
if(nowUrl.indexOf('/sizes/')){ | |
$('#allsizes-photo').children('div').remove(); | |
$('#allsizes-photo').children('img').each(function(){ | |
var $this = $(this); | |
$this.wrap('<a href="' + $this.attr('src') + '" download />') | |
}); | |
} | |
if(nowUrl.indexOf('/in/') > 0){ | |
let m; | |
while ((m = regex.exec(nowUrl)) !== null) { | |
// This is necessary to avoid infinite loops with zero-width matches | |
if (m.index === regex.lastIndex) { | |
regex.lastIndex++; | |
} | |
m.forEach((match, groupIndex) => { | |
if(match.length>0){ | |
openInNewTab(match+'sizes'); | |
} | |
}); | |
} | |
} | |
function openInNewTab(url) { | |
var win = window.open(url, '_blank'); | |
win.focus(); | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment