Skip to content

Instantly share code, notes, and snippets.

@MrDOS
Created January 26, 2017 13:20
Show Gist options
  • Select an option

  • Save MrDOS/19e2972ec0943ee78c8857dd08a38f07 to your computer and use it in GitHub Desktop.

Select an option

Save MrDOS/19e2972ec0943ee78c8857dd08a38f07 to your computer and use it in GitHub Desktop.
Make Kijiji use higher-resolution listing images.
// ==UserScript==
// @name Embiggen Kijiji
// @description Make Kijiji use higher-resolution listing images.
// @namespace ca.seenet.userscripts
// @author Samuel Coleman
// @version 2017-01-18
// @match http://www.kijiji.ca/*
// @grant none
// ==/UserScript==
/* The lightbox images are initialized via an inline function call toward the
* bottom of the page. We'll monkeypatch the function to filter the input. */
Kj.Vip.initImageLightBoxDisplayAdBase = Kj.Vip.initImageLightBoxDisplayAd;
Kj.Vip.initImageLightBoxDisplayAd = function (options) {
options.items.forEach(function (item) {
/* All Kijiji/eBay images have a "$_dd.JPG" parameter on the end of them
* (where "dd" is a number from -1-140) which controls the size/crop.
* "27" is the default large size (up to 640x480); "57" is the largest
* (I've seen 1600x1200 on eBay, although it's usually at most 800x800
* on Kijiji). */
item.src = item.src.replace(/\/\$_27.JPG$/, '/$_57.JPG');
});
return Kj.Vip.initImageLightBoxDisplayAdBase(options);
}
var style = document.createElement('style');
style.innerHTML = `
/* Prevent the larger images from unnecessarily lengthening the page. */
div.mfp-content {
top: 30%;
}
/* The lightbox <img> tags are styled to limit their size. Override it. */
img.mfp-img {
max-height: 100%;
max-width: none;
}
`;
document.body.appendChild(style);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment