-
Notifications
You must be signed in to change notification settings - Fork 16
/
MangaLib.js
142 lines (142 loc) · 5.01 KB
/
MangaLib.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
var MangaLib = {
mirrorName : "Manga Library",
canListFullMangas : true,
mirrorIcon : "img/mangalib.png",
languages : "pl",
isMe : function (url) {
"use strict";
return (url.indexOf("manga-lib.pl/") !== -1);
},
getMangaList : function (search, callback) {
"use strict";
$.ajax({
url : "http://www.manga-lib.pl/index.php/manga/search?title=" + search,
beforeSend : function (xhr) {
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
success : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse.replace(/<img /gi, "<noload ");
var res = [];
$("table.manga_list tbody tr td:first-child a", div).each(function (index) {
res[res.length] = [$(this).text(), $(this).attr("href")];
});
callback("Manga Library", res);
}
});
},
getListChaps : function (urlManga, mangaName, obj, callback) {
"use strict";
$.ajax({
url : urlManga,
beforeSend : function (xhr) {
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
success : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse.replace(/<img /gi, "<noload ");
var res = [];
$("table.chapters_list tbody tr td:first-child a", div).each(function (index) {
res[res.length] = [$(this).text(), $(this).attr("href")];
});
callback(res, obj);
}
});
},
getInformationsFromCurrentPage : function (doc, curUrl, callback) {
"use strict";
var name;
var currentChapter;
var currentMangaURL;
var currentChapterURL;
name = $(".reader_top_panel .reader_top_panel_l a", doc)[0].text();
currentMangaURL = $(".reader_top_panel .reader_top_panel_l a", doc)[0].attr("href");
currentChapter = $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).text();
currentChapterURL = $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).attr("value");
callback({
"name" : name,
"currentChapter" : currentChapter,
"currentMangaURL" : currentMangaURL,
"currentChapterURL" : currentChapterURL
});
},
getListImages : function (doc, curUrl) {
"use strict";
var res = [];
$("option", $(".reader_top_panel .reader_top_panel_l .ch_page", doc)).each(function (index) {
res[res.length] = $(this).attr("value");
});
return res;
},
removeBanners : function (doc, curUrl) {
"use strict";
},
whereDoIWriteScans : function (doc, curUrl) {
"use strict";
return $(".reader", doc);
},
whereDoIWriteNavigation : function (doc, curUrl) {
"use strict";
return $(".navAMR", doc);
},
isCurrentPageAChapterPage : function (doc, curUrl) {
"use strict";
return ($("#img_curr", doc).size() > 0);
},
doSomethingBeforeWritingScans : function (doc, curUrl) {
"use strict";
$(".reader", doc).empty();
$(".reader", doc).css("height", "auto");
$(".reader", doc).css("width", "auto");
$(".reader", doc).before("<div class='navAMR'></div>");
$(".reader", doc).after("<div class='navAMR'></div>");
$(".navAMR", doc).css("text-align", "center");
},
nextChapterUrl : function (select, doc, curUrl) {
"use strict";
if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().size() !== 0) {
return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).prev().attr("value");
}
return null;
},
previousChapterUrl : function (select, doc, curUrl) {
"use strict";
if ($("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().size() !== 0) {
return $("option:selected", $(".reader_top_panel .reader_top_panel_l .ch_chapter", doc)).next().attr("value");
}
return null;
},
getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) {
"use strict";
$.ajax({
url : urlImg,
success : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse;
var src = $("#img_curr", div).attr("src");
$(image).attr("src", src);
}
});
},
isImageInOneCol : function (img, doc, curUrl) {
"use strict";
return false;
},
getMangaSelectFromPage : function (doc, curUrl) {
"use strict";
return $($(".reader_menu .left select", doc)[0]);
},
doAfterMangaLoaded : function (doc, curUrl) {
"use strict";
$("body > div:empty", doc).remove();
$(".reader_page_holder .AMRtable", doc).css("background-color", "black");
$(".reader_page_holder .AMRtable tr", doc).css("background-color", "black");
$(".reader_page_holder .AMRtable tr td", doc).css("background-color", "black");
}
};
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject == 'function') {
registerMangaObject("Manga Library", MangaLib);
}