Greasy Fork

Greasy Fork is available in English.

pixiv快速打开原图

通过Ctrl+右键快速打开pixiv图片原图

目前为 2021-05-29 提交的版本,查看 最新版本

// ==UserScript==
// @name            pixiv快速打开原图
// @description     通过Ctrl+右键快速打开pixiv图片原图
// @version         0.2
// @namespace       Pikaqian
// @author          Pikaqian
// @include         *://www.pixiv.net/*
// @include         *://www.pixivision.net/*
// @icon            https://www.pixiv.net/favicon.ico
// @grant
// ==/UserScript==

(function() {
    'use strict';

    var match_rules=[
        /([_=:;&\-\/\.\?\d\w]+?illust_id=(\d+)(?:&|$|))/i ,
        /(http(?:s|):\/\/[_\-\/\.\d\w]+?\/(\d{4,})_p\d{1,4}[_\-\/\.\d\w]*)/i
    ];
    var preTime=0,
        preElemnt=null,
        baseURL=document.URL.match(/(.+)\//)[1],
        isEdge=navigator.userAgent.indexOf("Edge")>0

    window.addEventListener('contextmenu',function (event) {
        var el = event.target
        if (el != null) {
            var nowTime=new Date().getTime()
            var url,pid,HTML,results,img,imgMatch
            if((nowTime-preTime<500&&preElemnt==el)||event.ctrlKey){
                HTML=el.outerHTML
                for(var i in match_rules){
                    results=HTML.match(match_rules[i])
                    if(results!=null&&results.length>1){
                        url=results[1]
                        pid=results[2]
                        break
                    }
                }
                //``````````````````````````````````````````````````````````````````````
                if(results!=null){
                    var HTML_1=el.parentNode.previousSibling.childNodes[1]
                    var HTML_2="no results"
                    if(HTML_1!=undefined){
                        HTML_2=HTML_1.childNodes[0].childNodes[1].childNodes[0].data
                        for(var k=1;k<=HTML_2;k++){
                            var url_multiple="https://pixiv.cat/"+pid+"-"+k+".png"
                            window.open(url_multiple)
                            console.log(url_multiple)
                        }
                    }
                    else{
                        var url_single="https://pixiv.cat/"+pid+".png"
                        window.open(url_single)
                        console.log(url_single)
                    }
                }
                //````````````````````````````````````````````````````````````````````
                else{
                    var ans=HTML.split(".jpg")[0]
                    var ans_1=ans.split("/")[ans.split("/").length-1]
                    var ans_2=ans_1.split("_")[0]
                    var url_single_1="https://pixiv.cat/"+ans_2+".gif"
                    window.open(url_single_1)
                    console.log(url_single_1)
                }
                event.preventDefault();
                console.log(HTML_2)
                //``````````````````````````````````````````````````````````````````````
            }
            preTime=nowTime;
            preElemnt=el;
        }
    });

})();