forked from AllMangasReader-dev/mirrors
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMangaChapter.js
More file actions
208 lines (208 loc) · 7.1 KB
/
MangaChapter.js
File metadata and controls
208 lines (208 loc) · 7.1 KB
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
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
var MangaChapter =
{
mirrorName: "MangaChapter",
canListFullMangas: false,
mirrorIcon: "img/mangachapter.png",
languages: "en",
isMe: function(url)
{
return (url.indexOf("mangachapter.net") != -1);
},
getMangaList: function(search, callback)
{
var urlSearch = "http://www.mangachapter.net/search.html?w=" + search;
var res = [];
var getMangaListRecursive = function(url, callback)
{
$.ajax(
{
url: url,
beforeSend: function(xhr)
{
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
success: function(response)
{
var div = document.createElement('div');
div.innerHTML = response.replace('<img ', '<noload ');
$(".info_box a", div).each(function(index)
{
res[res.length] = [$(this).text(), $(this).attr("href") || ""];
});
var next = false;
var isNext = function(index)
{
if ($(this).text() == "Next")
{
next = $(this).attr("href") || "";
return false;
}
}
$(".next-page a", div).each(isNext);
if (next)
getMangaListRecursive(next, callback);
else
callback("MangaChapter", res);
}
});
};
getMangaListRecursive(urlSearch, callback);
},
getListChaps: function(urlManga, mangaName, obj, callback)
{
var res = [];
var getListChapsRecursive = function(urlManga, mangaName, obj, callback)
{
$.ajax(
{
url: urlManga,
beforeSend: function(xhr)
{
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
success: function(response)
{
var div = document.createElement( "div" );
div.innerHTML = response.replace('<img ', '<noload ');
$(".mangadata a[title]", div).each(function(index)
{
var currentChapter = $(this).attr("title").toLowerCase().replace(mangaName.toLowerCase(), "");
res[res.length] = [currentChapter.trim(), $(this).attr("href") || ""];
});
var next = false;
var isNext = function(index)
{
if ($(this).text() == "Next")
{
next = $(this).attr("href") || "";
return false;
}
}
$(".mangadata a:not([title])", div).each(isNext);
if (next)
getListChapsRecursive(next, mangaName, obj, callback);
else
callback(res, obj);
}
});
};
getListChapsRecursive(urlManga, mangaName, obj, callback);
},
getInformationsFromCurrentPage: function(doc, curUrl, callback)
{
var name = $(".box-read h2 a", doc).attr("title") || "";
var mangaurl = curUrl.substring(0, curUrl.lastIndexOf('/')) + ".html";
var currentChapter = $(".box-read h1 strong", doc).text();
currentChapter = currentChapter.replace(name, "");
callback(
{
"name": name.trim(),
"currentChapter": currentChapter.trim(),
"currentMangaURL": mangaurl.trim(),
"currentChapterURL": curUrl
});
},
getListImages: function(doc, curUrl)
{
res = [];
$(".page-select:first option", doc).each(function(index)
{
res[res.length] = "http://www.mangachapter.net" + $(this).val();
});
return res;
},
removeBanners: function(doc, curUrl)
{
$("iframe", doc).remove();
},
whereDoIWriteScans: function(doc, curUrl)
{
return $(".scanAMR", doc);
},
whereDoIWriteNavigation: function(doc, curUrl)
{
return $(".navAMR", doc);
},
isCurrentPageAChapterPage: function(doc, curUrl)
{
return ($("#mangaImg, #Img1", doc).length != 0);
},
doSomethingBeforeWritingScans: function(doc, curUrl)
{
$(".mangaread-tp,.mangaread-bt", doc).remove();
$(".mangaread-icon", doc).remove();
$(".footer", doc).remove();
var viewer = $(".main", doc);
viewer.empty();
viewer.removeAttr("class");
viewer.removeAttr("style");
viewer.css("width", "auto");
$("<div class='navAMR'></div>").appendTo(viewer);
$("<div class='scanAMR'></div>").appendTo(viewer);
$("<div class='navAMR'></div>").appendTo(viewer);
$(".navAMR", doc).css({ 'text-align':'center', 'background-color':'#fff', 'margin-bottom':'15px' });
},
nextChapterUrl: function(select, doc, curUrl)
{
if ($(select).children("option:selected").prev().size() != 0)
{
return $(select).children("option:selected").prev().val();
}
return null;
},
previousChapterUrl: function(select, doc, curUrl)
{
if ($(select).children("option:selected").next().size() != 0)
{
return $(select).children("option:selected").next().val();
}
return null;
},
getImageFromPageAndWrite: function(urlImg, image, doc, curUrl)
{
$.ajax(
{
url: urlImg,
success: function(objResponse)
{
var div = document.createElement( "div" );
div.innerHTML = objResponse;
var src = $("#mangaImg, #Img1", div).attr("src") || "";
$( image ).attr( "src", src);
}
});
},
isImageInOneCol: function(img, doc, curUrl)
{
return false;
},
getMangaSelectFromPage: function(doc, curUrl)
{
return null;
},
doAfterMangaLoaded: function(doc, curUrl)
{
$("body > div:empty", doc).remove();
$(".imageAMR", doc).css('margin-top', '10px');
$("body, table", doc).css(
{
'background-color':'#000',
'border-bottom-color':'#000',
'border-left-color':'#000',
'border-right-color':'#000',
'border-top-color':'#000'
});
if (doc.createElement)
{
var script = doc.createElement('script');
script.innerText = "document.onkeydown = undefined;";
doc.body.appendChild(script);
}
}
}
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject == 'function') {
registerMangaObject("MangaChapter", MangaChapter);
}