Skip to content

Instantly share code, notes, and snippets.

@wappenull
Last active January 11, 2023 13:56
Show Gist options
  • Save wappenull/817499134bdb28bef0fbd70c47264447 to your computer and use it in GitHub Desktop.
Save wappenull/817499134bdb28bef0fbd70c47264447 to your computer and use it in GitHub Desktop.
(TamperMonkey) View full resolution images on Instagram
// ==UserScript==
// @name IG Fullsize (mod by Wappen)
// @version 0.7
// @description View full resolution images on Instagram
// @match https://www.instagram.com/*
// @require https://gist.githubusercontent.com/realies/2fece0cd3e197cf6b31ca1316431a2a4/raw/debc0e6d4d537ac228d1d71f44b1162979a5278c/waitForKeyElements.js
// @author realies, mod by Wappen
// ==/UserScript==
(() => {
waitForKeyElements("div._aagu", clickBox => {
clickBox.style.cursor = "zoom-in";
clickBox.onclick = () => _OnOpenJumbo( clickBox );
}, false);
})();
function _OnOpenJumbo( aagu )
{
let a = aagu.querySelector("img");
if( a == null )
return;
// Default is using src image
let url = a.src;
// Access biggest image in srcset
if( a.srcset != null && a.srcset.length > 0 )
{
// https://stackoverflow.com/questions/36541892/how-to-determine-highest-resolution-image-from-srcset
var biggestImage = "";
var highestPixelDensity = 1;
for (var descriptor of a.srcset.split(/,/))
{
var parts = descriptor.trim().split(/ /);
// Here we check only for pixel density, see later for
// width descriptor but code is straightforward
var pixelDensity = parseFloat(parts[1].substring(-1));
if (pixelDensity > highestPixelDensity)
{
biggestImage = parts[0];
highestPixelDensity = pixelDensity;
}
}
if( biggestImage != null )
url = biggestImage;
}
window.open( url );
}
@wappenull
Copy link
Author

Update 0.7

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment