Skip to content

Instantly share code, notes, and snippets.

@heavyLobster2
Last active January 5, 2021 17:53
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save heavyLobster2/fb8c960748e205c15266 to your computer and use it in GitHub Desktop.
Save heavyLobster2/fb8c960748e205c15266 to your computer and use it in GitHub Desktop.
// ==UserScript==
// @name View Full Size Instagram Photos
// @description Clicking an Instagram photo opens the full size image
// @version 1.0.9
// @author heavyLobster2
// @namespace github.com/heavyLobster2
// @downloadURL https://gist.github.com/heavyLobster2/fb8c960748e205c15266/raw/ViewFullSizeInstagramPhotos.user.js
// @match *://www.instagram.com/*
// @grant none
// ==/UserScript==
(function () {
"use strict";
function procImage(image) {
if (typeof image.dataset.processed === "undefined" && image.src !== "") {
var link = document.createElement("a");
link.href = image.src;
link.className = image.className;
var container = image.parentNode;
container.replaceChild(link, image);
link.appendChild(image);
hideSiblings(container);
image.dataset.processed = "";
} else {
hideSiblings(image.parentNode.parentNode);
}
}
function hideSiblings(element) {
var siblings = element.parentNode.childNodes;
for (var i = 0; i < siblings.length; i++) {
if (siblings[i] !== element && siblings[i] instanceof Element) {
if (siblings[i].style.display !== "none") siblings[i].style.display = "none";
}
}
}
function procImages(images) {
var allImages = document.querySelectorAll("img.FFVAD");
for (var i = 0; i < allImages.length; i++) {
procImage(allImages[i]);
}
}
procImages();
var observer = new MutationObserver(function (mutations) {
procImages();
});
observer.observe(document, { subtree: true, childList: true });
})();
@Korb
Copy link

Korb commented Jan 5, 2021

Firefox 84.0.1 x64, Tampermonkey 4.11.6120 - не работает.

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