instagram_ex

enable save instagram images

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey, Greasemonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey किंवा Violentmonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

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

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला Tampermonkey यासारखे एक्स्टेंशन इंस्टॉल करावे लागेल..

ही स्क्रिप्ट इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्क्रिप्ट व्यवस्थापक एक्स्टेंशन इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्क्रिप्ट व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला Stylus सारखे एक्स्टेंशन इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

ही स्टाईल इंस्टॉल करण्यासाठी तुम्हाला एक युझर स्टाईल व्यवस्थापक इंस्टॉल करावे लागेल.

(माझ्याकडे आधीच युझर स्टाईल व्यवस्थापक आहे, मला इंस्टॉल करू द्या!)

Advertisement:

// ==UserScript==
// @name        instagram_ex
// @description  enable save instagram images
// @namespace   http://userscripts.org/users/
// @match     https://www.instagram.com/*
// @version     0.2
// @grant	none
// ==/UserScript==

var instagram_mode={
	get isPicture () {
		return /https:\/\/www.instagram.com\/p\//i.test(location.href);
	},
	get isProfile () {
		return /https:\/\/www.instagram.com\/[^\/]+\/[^\/]*$/i.test(location.href);
	},
	get isHomePage () {
		return 'https://www.instagram.com/'==location.href;
	},
};

if (instagram_mode.isPicture)
{
	var pid = _sharedData.entry_data.PostPage[0].media.id;
	var profile_url = document.querySelector('header a.notranslate').href;
	var position_node = document.querySelector('section > a > time').parentNode;
	var node = document.createElement('a');
	node.href = profile_url;
	node.search = '?max_id=' + pid;

	node.className = position_node.className;
	node.text = 'GoAsTop';

	position_node.parentNode.insertBefore(node, position_node);
}

HTMLElement.prototype.observe=function (func)
{
	var ts=this;
	var obs_config={attributes: true, childList: true, subtree: true};
	var observer=null;
	var masked=function (){obs.disconnect();func();obs.observe(ts,obs_config);};
	obs=new (window.MutationObserver||window.WebKitMutationObserver)(masked);
	ts.addEventListener("unload", function(event){
		obs.disconnect();
	});
	obs.observe(ts, obs_config);
}

HTMLElement.prototype.killElementAttribute=function (selector, attrname)
{
	Array.prototype.forEach.call(this.querySelectorAll(selector), function(node){
		if (node.hasAttribute(attrname)) node.removeAttribute(attrname);
	});
}

HTMLElement.prototype.removeSelf=function()
{
	this.parentNode.removeChild(this);
}

document.onreadystatechange = function () {
	if (document.readyState == "complete") {
		clean_insta();
		if (document.body) document.body.observe(clean_insta);
	}
}

function clean_insta()
{
	var pimg=document.querySelectorAll('img[id^="pImage_"][src^="http"]');
	Array.prototype.forEach.call(pimg, function(node){
		var loader_id=node.id.replace("pImage_", "pImageLoader_");
		if (document.getElementById(loader_id)) return;
		node.killElementAttribute("*", "data-reactid");
		node.style="";
		var pnode=node.parentNode;
		while (pnode.nextElementSibling)
		{
			pnode.nextElementSibling.removeSelf();
		}
	});
}