Skip to content
This repository has been archived by the owner on Sep 17, 2019. It is now read-only.

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
pikax committed Jun 20, 2017
1 parent 3154376 commit e0e20c6
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 14 deletions.
33 changes: 21 additions & 12 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -2022,6 +2022,13 @@ verbose$4("using %O", config$6);
var Parser$3 = (function () {
function Parser() {
}
Object.defineProperty(Parser.prototype, "secretAlgorithm", {
get: function () {
return this._secretAlgorithm;
},
enumerable: true,
configurable: true
});
Parser.prototype.mangas = function ($) {
var mangas = [];
$("table.listing > tbody > tr").slice(2).each(function (i, el) {
Expand Down Expand Up @@ -2063,7 +2070,6 @@ var Parser$3 = (function () {
chapter = -7;
console.warn("couldn't resolve the chapter for '%s', please refer to %s", src, "https://github.com/pikax/gin-downloader/issues/7");
}

chapters[i] = {
name: mangaName,
chap_number: chapter,
Expand Down Expand Up @@ -2141,11 +2147,13 @@ var Parser$3 = (function () {
return sandbox.imgs.map(function (x) { return /url=([^&]*)/.exec(x)[1]; }).map(decodeURIComponent);
};
Parser.prototype.getSecret = function (html) {
var m = /\["([^"]*)"]; chko[^\[]*\[(\d+)]/gm.exec(html);
if (m) {
return m[1].decodeEscapeSequence();
var matches = [];
var m;
var regex = /(var (_[\da-z]*) = \["([^"]*)"]; chko =([^\[]*\[\d+][^;]*); [^)]*\))/gm;
while (m = regex.exec(html)) {
matches.push(m[1]);
}
return null;
return matches.join(";");
};
Parser.prototype.imagesPaths = function (doc) {
throw new Error("no needed");
Expand All @@ -2160,15 +2168,16 @@ var Parser$3 = (function () {
enumerable: true,
configurable: true
});
Parser.prototype.buildVM = function (cajs, lojs) {
Parser.prototype.buildVM = function (cajs, lojs, algorithm) {
var scripts = [cajs,
lojs,
"chko = (secret && chko + secret) || chko; key = CryptoJS.SHA256(chko);",
algorithm,
"for (var img in lstImages) {" +
"imgs.push(wrapKA(lstImages[img]).toString())" +
"" +
"};"
];
debug$5("building vm with: %o", algorithm);
this._secretAlgorithm = algorithm;
return this._vm = new vm.Script(scripts.join("\n"));
};
Parser.prototype.filter = function (doc) {
Expand Down Expand Up @@ -2551,14 +2560,14 @@ var KissManga = (function (_super) {
function KissManga() {
return _super.call(this, config$6, new Parser$3(), new Helper$3(), strategy$2) || this;
}
KissManga.prototype.getVM = function () {
KissManga.prototype.getVM = function (secret) {
return __awaiter$5(this, void 0, void 0, function () {
var vm$$1, tkCa, tkLo, tkLst, lst;
return __generator$5(this, function (_a) {
switch (_a.label) {
case 0:
vm$$1 = this.parser.VM;
if (vm$$1) {
if (vm$$1 && this.parser.secretAlgorithm === secret) {
return [2 , vm$$1];
}
tkCa = this.request.getHtml(url.resolve(this.config.site, "/Scripts/ca.js"));
Expand All @@ -2568,7 +2577,7 @@ var KissManga = (function (_super) {
return [4 , Promise.all(tkLst)];
case 1:
lst = _a.sent();
return [2 , this.parser.buildVM(lst[0], lst[1])];
return [2 , this.parser.buildVM(lst[0], lst[1], secret)];
}
});
});
Expand Down Expand Up @@ -2617,7 +2626,7 @@ var KissManga = (function (_super) {
case 2:
html = _a.sent();
secret = this.parser.getSecret(html);
return [4 , this.getVM()];
return [4 , this.getVM(secret)];
case 3:
vm$$1 = _a.sent();
imgs = this.parser.imagesList(html, secret, vm$$1);
Expand Down
2 changes: 1 addition & 1 deletion dist/types/sites/kissmanga/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { Helper } from "./names";
import { FilteredResults, MangaFilter, ImageSource, MangaSource, Site, SiteConfig } from "../../declarations";
export declare class KissManga extends MangaSite<SiteConfig, Parser, Helper> implements Site {
constructor();
private getVM();
private getVM(secret);
mangas(filter?: MangaFilter): Promise<MangaSource[]>;
filter(filter?: MangaFilter): Promise<FilteredResults>;
images(name: string, chapNumber: number): Promise<Promise<ImageSource>[]>;
Expand Down
4 changes: 3 additions & 1 deletion dist/types/sites/kissmanga/parser.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ import "../../declarations";
import { Chapter, FilteredResults, MangaInfo, MangaSource, MangaXDoc, SiteParser } from "../../declarations";
import { Script } from "vm";
export declare class Parser implements SiteParser {
readonly secretAlgorithm: string;
private _secretAlgorithm;
private _vm;
private static fixNames;
private static resolveName;
Expand All @@ -18,7 +20,7 @@ export declare class Parser implements SiteParser {
imagesPaths(doc: MangaXDoc): string[];
image(html: string): string;
readonly VM: Script;
buildVM(cajs: string, lojs: string): Script;
buildVM(cajs: string, lojs: string, algorithm: string): Script;
filter(doc: MangaXDoc): Promise<FilteredResults> | FilteredResults;
static ResolveChapterVolume(title: string): string;
static ResolveChapterNumber(title: string): number;
Expand Down

0 comments on commit e0e20c6

Please sign in to comment.