pixiv 自動查看差分和評論

try to take over the world!

当前为 2020-10-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         pixiv 自動查看差分和評論
// @namespace    pixiv 自動查看差分和評論
// @version      5.0
// @description  try to take over the world!
// @author       fmnijk
// @match        https://www.pixiv.net/artworks/*
// @grant        none
// ==/UserScript==

(window.onload = function() {
    'use strict';
    var stop1 = -100;
    function keeptrying1() {
        if(document.querySelector('.emr523-0') == null){
            stop1 += 1;
            if(stop1 < 0){
                setTimeout(( () => keeptrying1() ), 20);
            }else{
                listener1();
            }
        }else{
            document.querySelector('.emr523-0').click();
            listener1();
        }
    }
    keeptrying1();
    var stop2 = -100;
    function keeptrying2() {
        if(document.querySelector('._1Hom0qN') == null){
            stop2 += 1;
            if(stop2 < 0){
                setTimeout(( () => keeptrying2() ), 20);
            }
        }else{
            document.querySelector('._1Hom0qN').click();
        }
    }
    keeptrying2();

    function listener1(){
        document.addEventListener('keyup', (e) => {
            if (e.code === "ArrowRight") {
                stop1 = -100;
                stop2 = -100;
                keeptrying1();
                keeptrying2();
            }
            if (e.code === "ArrowLeft") {
                stop1 = -100;
                stop2 = -100;
                keeptrying1();
                keeptrying2();
            }
        });
    }
    /*var stop3 = -100;
    function keeptrying3() {
        if(document.querySelector('.sc-1mz6e1e-1.QBVJO') == null){
            stop3 += 1;
            if(stop3 < 0){
                console.log(stop3);
                setTimeout(( () => keeptrying3() ), 20);
            }
        }else{
            var as = document.querySelectorAll('.sc-1mz6e1e-1.QBVJO a');
            var imgs = document.querySelectorAll('.sc-1mz6e1e-1.QBVJO a img');
            if(as.length != imgs.length){
                stop3 += 1;
                if(stop3 < 0){
                    console.log(stop3);
                    setTimeout(( () => keeptrying3() ), 20);
                }
            }else{
                for (var i = 0; i < as.length; ++i) {
                    imgs[i].src = as[i].getAttribute('href');
                    imgs[i].srcset = as[i].getAttribute('href');
                    imgs[i].removeAttribute("style");
                    imgs[i].setAttribute("style", "max-height: 100%;");
                    console.log("width = " + imgs[i].getAttribute('width'));
                    document.querySelector('.sc-1nr368f-6.ertGlR').setAttribute("style", "width:1000px;");
                };
            }
        }
    }
    setTimeout(( () => keeptrying3() ), 0);*/
})();