Greasy Fork

来自缓存

Greasy Fork is available in English.

Instagram 文章相片/影片下載器

下載文章中的相片、影片

当前为 2020-06-02 提交的版本,查看 最新版本

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Greasemonkey 油猴子Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Violentmonkey 暴力猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴Userscripts ,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展,例如 Tampermonkey 篡改猴,才能安装此脚本。

您需要先安装一款用户脚本管理器扩展后才能安装此脚本。

(我已经安装了用户脚本管理器,让我安装!)

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展,比如 Stylus,才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

您需要先安装一款用户样式管理器扩展后才能安装此样式。

(我已经安装了用户样式管理器,让我安装!)

// ==UserScript==
// @name         Instagram 文章相片/影片下載器
// @namespace    https://github.snkms.com/
// @version      1.0.3
// @description  下載文章中的相片、影片
// @author       5026
// @match        https://*.instagram.com/*
// @grant        GM_setValue
// @grant        GM_getValue
// @require      https://ajax.googleapis.com/ajax/libs/jquery/1.8.2/jquery.min.js
// @supportURL   https://www.facebook.com/smileopwe/
// ==/UserScript==

(function() {
    'use strict';
    alert('COMPLETE\n下載資料時,若貼文中有多張相片,則只會提取點擊下載資料當下的照片以及其前後的照片,共三張(若頭尾則兩張)。');
    var $ = window.jQuery;
    var timer = setInterval(function(){
        GM_setValue('oldHeight',$(document).height());

        if($('article ._97aPb[data-snig="canDownload"]').length==0 && onChangeURL()){
            console.log(true);
            onReadyMyDW();
        }
    },200);

    $(document).scroll(function(){
        if(GM_getValue('oldHeight') != $(this).height()){
            console.log('onChange()');
            onReadyMyDW();
        }
    });

    function onChangeURL(){
        var reA = /^(https:\/\/www.instagram.com\/p\/)/g;
        var reB = /^(https:\/\/www.instagram.com\/)$/g;
        var URLs = location.href;
        if(URLs.match(reA) || URLs.match(reB)){
            return true;
        }
    }
    function onReadyMyDW(){
        $('article ._97aPb').each(function(){
            if(!$(this).attr('data-snig')){

                if($(this).find('video.tWeCl').length){

                    $(this).append('<div class="SNKMS_IG_DW_MAIN_VIDEO" style="position: absolute;right:15px;top:15px;witdh:20px;height:20px;background:#fff;">下載影片資料</div>');
                    $(this).on('click','.SNKMS_IG_DW_MAIN_VIDEO',function(e){
                        $(this).parent().find('video.tWeCl').each(function(){
                            console.log($(this).attr('src'));
                        });
                    });
                }
                else{
                    $(this).append('<div class="SNKMS_IG_DW_MAIN" style="position: absolute;right:15px;top:15px;witdh:20px;height:20px;background:#fff;">下載圖片資料</div>');
                    $(this).on('click','.SNKMS_IG_DW_MAIN',function(e){
                        IG_createDM();
                        var i = 0;
                        $(this).parent().find('.FFVAD').each(function(){
                            i++;
                            console.log($(this).attr('src'));
                            $('.IG_SN_DIG>div').append('<a style="margin:10px 0px;color:#FFF;font-size:1.5rem;line-height:1.5rem;text-align:center;" target="_blank" href="'+$(this).attr('src')+'&dl=1">資料'+i+'</a>');
                        });
                    });
                }
                $(this).attr('data-snig','canDownload');
            }
        });
    }
    function IG_createDM(){
        $('body').append('<div class="IG_SN_DIG" style="position: fixed;left: 0px;right: 0px;bottom: 0px;top: 0px;background: rgba(0,0,0,.75);z-index: 500;"><div style="z-index: 501;position: absolute;left: 50%;transform: translateX(-50%);width: 500px;height: 700px;"></div></div>');
        $('.IG_SN_DIG>div').append('<button class="IG_SN_DIG_BTN">關閉視窗</button>');
    }
    $(function(){
        onReadyMyDW();

        $('body').on('click','.IG_SN_DIG_BTN',function(){
            $('.IG_SN_DIG').remove();
        });

    });
    // Your code here...
})();