parent
69c85131f0
commit
3ceb2d5f60
1 changed files with 26 additions and 10 deletions
|
|
@ -2,16 +2,17 @@
|
||||||
// ==UserScript==
|
// ==UserScript==
|
||||||
// @name Viewcomic Scraper
|
// @name Viewcomic Scraper
|
||||||
// @namespace danielrayjones
|
// @namespace danielrayjones
|
||||||
// @version 0.0.6
|
// @version 0.0.7
|
||||||
// @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/*
|
||||||
// @grant none
|
// @grant none
|
||||||
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
|
// @require https://ajax.googleapis.com/ajax/libs/jquery/3.2.1/jquery.min.js
|
||||||
// @require https://raw.githubusercontent.com/tommcfarlin/konami-code/master/src/jquery.konami.min.js
|
// @require https://raw.githubusercontent.com/tommcfarlin/konami-code/master/src/jquery.konami.min.js
|
||||||
|
// @require https://bowercdn.net/c/jszip-3.1.5/dist/jszip.min.js
|
||||||
// ==/UserScript==
|
// ==/UserScript==
|
||||||
|
|
||||||
/* global jQuery */
|
/* global jQuery, JSZip */
|
||||||
|
|
||||||
(function($) {
|
(function($) {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
@ -36,23 +37,38 @@
|
||||||
let imgs = $('div.pinbin-copy img.picture, div.pinbin-copy img.hoverZoomLink').toArray();
|
let imgs = $('div.pinbin-copy img.picture, div.pinbin-copy img.hoverZoomLink').toArray();
|
||||||
console.log(imgs);
|
console.log(imgs);
|
||||||
|
|
||||||
|
let cbz = new JSZip();
|
||||||
|
|
||||||
|
function downloadCbz() {
|
||||||
|
cbz.generateAsync({type: 'blob'})
|
||||||
|
.then(blob => {
|
||||||
|
let title = name.replace(/-/g, ' ').replace(/\b([0-9]{4})\b/, '($1)');
|
||||||
|
|
||||||
|
let $el = $('<a>');
|
||||||
|
$(document.body).append($el);
|
||||||
|
$el.attr('href', URL.createObjectURL(blob));
|
||||||
|
$el.attr('download', `${title} (viewcomic) (Danjones).cbz`);
|
||||||
|
$el.get(0).click();
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
function getOne() {
|
function getOne() {
|
||||||
if (!imgs) return;
|
if (!imgs || !imgs.length) {
|
||||||
|
downloadCbz();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
let img = imgs.shift();
|
let img = imgs.shift();
|
||||||
console.log(img.src);
|
console.log(img.src);
|
||||||
|
|
||||||
fetch(img.src).then(resp => resp.blob()).then(blob => {
|
fetch(img.src).then(resp => resp.blob()).then(blob => {
|
||||||
let $el = $('<a>');
|
cbz.file(name + '-' + (i < 10 ? '00' : '0' ) + i + '.jpg', blob);
|
||||||
$(document.body).append($el);
|
|
||||||
$el.attr('href', URL.createObjectURL(blob));
|
|
||||||
$el.attr('download', name + '-' + (i < 10 ? '00' : '0' ) + i + '.jpg');
|
|
||||||
$el.get(0).click();
|
|
||||||
|
|
||||||
i = i+1;
|
i = i+1;
|
||||||
setTimeout(getOne, 1000);
|
setTimeout(getOne, 0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
getOne();
|
getOne();
|
||||||
}
|
}
|
||||||
|
|
||||||
})(jQuery);
|
})(jQuery);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue