Instagram Downloader

Adds a download button for Instagram posts online.

You will need to install an extension such as Tampermonkey, Greasemonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install an extension such as Tampermonkey or Violentmonkey to install this script.

You will need to install an extension such as Tampermonkey or Userscripts to install this script.

You will need to install an extension such as Tampermonkey to install this script.

You will need to install a user script manager extension to install this script.

(I already have a user script manager, let me install it!)

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install an extension such as Stylus to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

You will need to install a user style manager extension to install this style.

(I already have a user style manager, let me install it!)

// ==UserScript==
// @name         Instagram Downloader
// @namespace    https://6869net.tk/
// @version      0.1
// @description  Adds a download button for Instagram posts online.
// @author       The 6869net Team
// @match        https://www.instagram.com/p/*
// @grant        none
// ==/UserScript==

(function() {
    // If you like my code and want to use it in your creation, feel free -- just cite my website link within your creation somewhere: https://6869net.tk/
    // (A developer's gotta eat! :D)
    function instagramDownloaderCode() {
        var img = document.querySelector("#react-root > section > main > div > div > article > div > div > div > div > img")
        var srcset = img.getAttribute("srcset");
        console.log(srcset);
        var splitsrcset = srcset.split(",");
        var splitsrc = splitsrcset[splitsrcset.length - 1].split(" ");
        var correctsrc = splitsrc[0];
        console.log(correctsrc);
        var downloadbutton = document.createElement("button");
        downloadbutton.setAttribute("onclick", "var link = document.createElement('a');link.download = 'instadl.jpg';link.href = '" + correctsrc + "';document.body.appendChild(link);link.click();document.body.removeChild(link);delete link;");
        downloadbutton.setAttribute("width", "40");
        downloadbutton.setAttribute("height", "40");
        var downloadtextnode = document.createTextNode("DL");
        downloadbutton.appendChild(downloadtextnode);
        var buttonspan = document.querySelector("#react-root > section > main > div > div > article > div > section > span");
        buttonspan.appendChild(downloadbutton);
    }
    // don't run the code until after a second -- until after the page has loaded
    setTimeout(instagramDownloaderCode, 1000);
})();