pixiv 自動查看差分和評論

pixiv 自動點擊圖片的查看全部和評論的瀏覽更多按鈕

当前为 2021-05-01 提交的版本,查看 最新版本

// ==UserScript==
// @name         pixiv 自動查看差分和評論
// @namespace    pixiv 自動查看差分和評論
// @version      7.0.2
// @description  pixiv 自動點擊圖片的查看全部和評論的瀏覽更多按鈕
// @author       fmnijk
// @match        https://www.pixiv.net/*
// @grant        none
// ==/UserScript==

history.pushState = ( f => function pushState(){
    var ret = f.apply(this, arguments);
    window.dispatchEvent(new Event('pushstate'));
    window.dispatchEvent(new Event('locationchange'));
    return ret;
})(history.pushState);

history.replaceState = ( f => function replaceState(){
    var ret = f.apply(this, arguments);
    window.dispatchEvent(new Event('replacestate'));
    window.dispatchEvent(new Event('locationchange'));
    return ret;
})(history.replaceState);

window.addEventListener('popstate',()=>{
    window.dispatchEvent(new Event('locationchange'))
});

function keeptrying(times, delay) {
    if(times == 0){
        return false;
    }
    if(document.querySelector('._1Hom0qN') != null){
        document.querySelector('._1Hom0qN').click();
    }
    if(document.querySelector('.emr523-0') != null){
        document.querySelector('.emr523-0').click();
    }
    setTimeout(( () => keeptrying(times - 1, delay) ), delay);
    console.log('keeptrying');
}

window.addEventListener('locationchange', function (){
    keeptrying(20, 50);
})

(window.onload = function () {
    keeptrying(20, 50);
})();