Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Script to replace cropped animations with originals in Newscoop
// Encapsulate script code
(function($) {
// Select all images in 'ad' articles
$("a.section-ad.layoutbgimage, img.image-link").each(function() {
asBgImage = typeof $(this).attr('src') === "undefined";
// Obtain current url(..) path to the image
u = asBgImage ? : this.src;
// Apply additional criteria to ensure target crop format
if (u.indexOf('/cache/')<0 || u.indexOf('.gif')<0) return;
// Use a regular expression to trim the crop path out
re = /cache\/[0-9]+x[0-9]+\/(crop[_0-9]*|fit)\/+images%7C/
v = u.replace(re, '');
// For debugging, output the result
// Set the new path to the original image
if (asBgImage) { = v;
} else {
this.src = v;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.