Slow down viewcomic scraper so Chrome lets us do it
This commit is contained in:
parent
0f51e2e12b
commit
7e5653e06c
1 changed files with 23 additions and 10 deletions
|
|
@ -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/*
|
||||||
|
|
@ -24,16 +24,29 @@
|
||||||
function getStuff() {
|
function getStuff() {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
|
||||||
$('div.pinbin-copy img.picture').each(function () {
|
let path = location.pathname.split('/');
|
||||||
|
let end = path.pop();
|
||||||
|
while (!end && path.length) {
|
||||||
|
end = path.pop();
|
||||||
|
}
|
||||||
|
let name = end ? end : 'comic';
|
||||||
|
|
||||||
|
let imgs = $('div.pinbin-copy img.picture').toArray();
|
||||||
|
|
||||||
|
function getOne() {
|
||||||
|
let img = imgs.shift();
|
||||||
|
console.log(img.src);
|
||||||
|
|
||||||
let $el = $('<a>');
|
let $el = $('<a>');
|
||||||
$(document.body).append($el);
|
$(document.body).append($el);
|
||||||
|
$el.attr('href', img.src);
|
||||||
$el.attr('href', this.src);
|
$el.attr('download', name + '-' + (i < 10 ? '00' : '0' ) + i + '.jpg');
|
||||||
$el.attr('download', (i < 10 ? '00' : '0' ) + i + '.jpg');
|
|
||||||
$el.get(0).click();
|
$el.get(0).click();
|
||||||
|
|
||||||
i = i+1;
|
i = i+1;
|
||||||
});
|
setTimeout(getOne, 1000);
|
||||||
|
}
|
||||||
|
getOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
})();
|
})();
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue