idolpx / Instagram Media Deprotect

// ==UserScript==
// @namespace    https://gist.github.com/idolpx
// @name         Instagram Media Deprotect
// @version      1.0.5
// @description  Removes elements protecting images & videos from download
// @downloadURL  https://openuserjs.org/install/idolpx/Instagram_Media_Deprotect.user.js
// @updateURL    https://openuserjs.org/meta/idolpx/Instagram_Media_Deprotect.meta.js
// @author       Jaime Idolpx
// @copyright    2020, idolpx (https://openuserjs.org/users/idolpx)
// @license      MIT
// @match        https://www.instagram.com/*
// @require      http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js
// @grant        none
// ==/UserScript==

function remove_protection() {
    $('article:visible').each(function() {
        $(this).find('img').parent().next().remove();

        if($(this).find('video').length > 0 && $(this).find('div.dl').length == 0) {
            var src = $(this).find('video').attr('src');
            var name = $(this).find('h2').first().text() + '-' + src.split("/").pop();
            var html = '<div class="dl" style="text-align: center;font-size: large;font-weight: 900;"><a href="' + src + '" target="_blank" download="' + name + '">>>> Download Video <<<</a></div>';
            $(this).find('header').next().after(html);
        }
    });
}

(function() {
    'use strict';

    remove_protection();
    $('body').on("click",function(){
        remove_protection();
    });

    $(window).scroll(function() {
        clearTimeout($.data(this, 'scrollTimer'));
        $.data(this, 'scrollTimer', setTimeout(function() {
            remove_protection();
        }, 250));
    });
})();