Allow "Save image as..." on context menu of Instagram.
目前為
// ==UserScript==
// @name instagram_allow_saveimage
// @namespace http://catherine.v0cyc1pp.com/instagram_allow_saveimage.user.js
// @include https://www.instagram.com/*
// @version 1.10
// @require http://code.jquery.com/jquery-2.2.4.min.js
// @grant none
// @run-at document-end
// @description Allow "Save image as..." on context menu of Instagram.
// @description KNOWN ISSUE: can't save videos.
// ==/UserScript==
this.$ = this.jQuery = jQuery.noConflict(true);
console.log("instagram_allow_saveimage start");
function main() {
//$("div[is='null']").each(function() {
$("div").each(function() {
// Fix: The extension 'Chrome IG Story' is not showing.
//var parentEls = $(this).parents("#rcr-anchor");
var parentEls = $(this).parents("article");
//console.log("parentEls="+parentEls);
//console.log("parentEls.length="+parentEls.length);
if ( parentEls !== null && parentEls.length === 0 ) {
//console.log("Warning: this is the 'story'");
return;
}
var classname = $(this).attr("class");
var kids = $(this).children();
console.log("len="+kids.length);
if ( kids.length === 0 ) {
var at = $(this).attr("style");
if ( at !== null && at !== undefined && at !== "" ) {
console.log("return, this is a style: classname="+classname);
$(this).attr("display", "inline");
return;
}
/*
var button = $(this).parent("div").parent("button");
if ( button === null || button === undefined ) {
console.log("return, this is a button: classname="+classname);
return;
}
*/
console.log("hide: classname="+classname);
$(this).hide();
} else {
console.log("show: classname="+classname);
$(this).removeAttr("style");
}
});
/*
$("div > a").each(function() {
var classname = $(this).parent().attr("class");
console.log("parent classname="+classname);
var attr = $(this).attr("videoSpritePlayButton");
console.log("attr="+attr);
if ( attr === null || attr === undefined || attr === "" ) {
return;
}
console.log("hide: parent classname="+classname);
$(this).parent().hide();
});
$("iframe").each(function() {
$(this).parent().hide();
});
*/
}
var observer = new MutationObserver(function(mutations) {
observer.disconnect();
main();
observer.observe( document, config);
});
var config = { attributes: false, childList: true, characterData: false, subtree:true };
observer.observe( document, config);