Image Download with Ctrl+Click/Shift [GLOBAL]

Ctrl+Click/Shift image downloading for most single-image pages

Versione datata 20/08/2020. Vedi la nuova versione l'ultima versione.

// ==UserScript==
// @name            Image Download with Ctrl+Click/Shift [GLOBAL]
// @namespace       imageSaving
// @description     Ctrl+Click/Shift image downloading for most single-image pages
// @author          NightLancerX
// @match           *://*/*.jpg*
// @match           *://*/*.png*
// @version         2.1
// @homepageURL     https://github.com/NightLancer/PixivPreview
// @license         MIT License
// @grant           none
// @run-at          document-end
// ==/UserScript==

(function() {
    'use strict';
    
    let img = document.querySelectorAll('img')[0];
    let imgSrc = img.src;
    
    function main()
    {
        let anchor = document.createElement('a');
        anchor.href = img.src;
        anchor.target = '_self';
        anchor.download = (imgSrc.indexOf('?')>-1)? imgSrc.substring(imgSrc.lastIndexOf("/")+1, imgSrc.indexOf('?')): imgSrc.substring(imgSrc.lastIndexOf("/")+1);
        document.body.appendChild(anchor);
        anchor.click();
    };
    
    img.onclick = function(e)
    {
        if (e.ctrlKey) //save with Ctrl+Click
        {
            e.preventDefault();
	    main();
        };           
    };
    
    document.onkeyup = function(e)
    {
        if (e.keyCode == 16) //save with shift
        {
            main();
        }
    };
})();
长期地址
遇到问题?请前往 GitHub 提 Issues,或加Q群1031348184

赞助商

Fishcpy

广告

Rainyun

注册一下就行

Rainyun

一年攒够 12 元