sanyabeast / instaclear

// ==UserScript==
// @name         instaclear
// @namespace    sanyabeat.instaclear
// @version      1.2
// @description  Lightweight script that monitors your instagram-journey and kills annoying overlays at real-time mode. It let you save photos just using default context-menu.
// @author       sanyabeast <a.gvrnsk@gmail.com>
// @match        https://www.instagram.com/
// @match        https://www.instagram.com/*
// @match        https://www.instagram.com/*/*
// @license      MIT
// @grant        none
// ==/UserScript==

(function() {
    'use strict';
    console.log("%cinstacler works", "color: green")

    function clear_instagram () {
        let cleared_count = 0
        let o = document.querySelectorAll("div + div");
        for (let i=0;i<o.length;i++){
            let e = o[i]
            if (e.children.length === 0 && e.style.zIndex !== "-1") {
                cleared_count++
                e.style.zIndex = "-1"
            }
        }

        if (cleared_count > 0){
             console.log(`%cjust cleared ${cleared_count} emptyboxes`, "color: orange")
        }
    }

    let target = document.body

    const config = {
        attributes: true,
        childList: true,
        subtree: true
    };

    const callback = function(mutationsList, observer) {
        setTimeout(clear_instagram, 250);
    };

    const observer = new MutationObserver(callback);
    observer.observe(target, config);
    // Your code here...
})();