Forked from heavyLobster2/ViewFullSizeInstagramPhotos.user.js
Created
June 12, 2020 08:44
-
-
Save oscargch/6a2d4b2f0a30a79a676e0b351f3d1841 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
// ==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 }); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment