Slow down viewcomic scraper so Chrome lets us do it

This commit is contained in:
Dan Jones 2018-04-16 11:12:51 -05:00
commit 7e5653e06c

View file

@ -2,7 +2,7 @@
// ==UserScript== // ==UserScript==
// @name Viewcomic Scraper // @name Viewcomic Scraper
// @namespace danielrayjones // @namespace danielrayjones
// @version 0.0.2 // @version 0.0.3
// @description Scrape comics from viewcomic.com // @description Scrape comics from viewcomic.com
// @author Dan Jones // @author Dan Jones
// @match http://viewcomic.com/* // @match http://viewcomic.com/*
@ -22,18 +22,31 @@
$(window).on('konami.get', getStuff); $(window).on('konami.get', getStuff);
function getStuff() { function getStuff() {
let i = 0; let i = 0;
$('div.pinbin-copy img.picture').each(function () { let path = location.pathname.split('/');
let $el = $('<a>'); let end = path.pop();
$(document.body).append($el); while (!end && path.length) {
end = path.pop();
}
let name = end ? end : 'comic';
$el.attr('href', this.src); let imgs = $('div.pinbin-copy img.picture').toArray();
$el.attr('download', (i < 10 ? '00' : '0' ) + i + '.jpg');
$el.get(0).click();
i = i+1; function getOne() {
}); let img = imgs.shift();
console.log(img.src);
let $el = $('<a>');
$(document.body).append($el);
$el.attr('href', img.src);
$el.attr('download', name + '-' + (i < 10 ? '00' : '0' ) + i + '.jpg');
$el.get(0).click();
i = i+1;
setTimeout(getOne, 1000);
}
getOne();
} }
})(); })();