-
Notifications
You must be signed in to change notification settings - Fork 16
/
Copy pathReadManga.js
142 lines (141 loc) · 4.58 KB
/
ReadManga.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 ReadManga = {
mirrorName: "ReadManga",
canListFullMangas: false,
mirrorIcon: "img/readmanga.png",
languages: "ru",
isMe: function (url) {
return (url.indexOf("readmanga.me/") !== -1);
},
getMangaList: function (search, callback) {
$.ajax({
url: "http://readmanga.me/search",
type: "POST",
data: {
q: 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;
var res = [];
$("#mangaResults td a:first-child", div).each(function (index) {
var tit = $($(this).contents()[0]).text();
tit = tit.split("|");
res[res.length] = [tit[0].trim(), "http://readmanga.me" + $(this).attr("href")];
});
callback("ReadManga", res);
}
});
},
getListChaps: function (urlManga, mangaName, obj, callback) {
$.ajax({
url: urlManga + "?mature=1",
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;
var res = [];
var mng_nm = (urlManga.split("/")).pop();
$("div.expandable td > a", div).each(function (index) {
var str = $(this).attr("href");
str = str.split("/")[1];
if (str === mng_nm) {
res[res.length] = [$($(this).contents()[0]).text(), "http://readmanga.me" + $(this).attr("href")];
}
});
callback(res, obj);
}
});
},
getInformationsFromCurrentPage: function (doc, curUrl, callback) {
var name = $($("#mangaBox h1 a:first-child", doc).contents()[0]).text();
var nameurl = "http://readmanga.me" + $("#mangaBox h1 a:first-child", doc).attr("href");
var curChapName = $("#chapterSelectorSelect:first option:selected", doc).text();
var chapurl = "http://readmanga.me" + $("#chapterSelectorSelect:first option:selected", doc).val();
callback({
"name": name,
"currentChapter": curChapName,
"currentMangaURL": nameurl,
"currentChapterURL": chapurl
});
},
getListImages: function (doc, curUrl2) {
var res = [];
var matches = doc.documentElement.innerHTML;
matches = matches.match(/rm_h\.init\(.*?\]\]/);
if (matches) {
matches = matches[0].slice(10);
matches = matches.split("'").join('"');
var b = JSON.parse(matches);
for (var i = 0; i < b.length; i++) {
res[i] = b[i][1] + b[i][0] + b[i][2];
}
}
return res;
},
removeBanners: function (doc, curUrl) {
$(".baner", doc).remove();
},
whereDoIWriteScans: function (doc, curUrl) {
return $("#mangaBox", doc);
},
whereDoIWriteNavigation: function (doc, curUrl) {
return $(".navAMR", doc);
},
isCurrentPageAChapterPage: function (doc, curUrl) {
return ($("img#mangaPicture", doc).size() > 0);
},
doSomethingBeforeWritingScans: function (doc, curUrl) {
$("#mangaBox", doc).prev().remove();
$("#mangaBox", doc).prev().remove();
$(".second-nav", doc).append($("h1", doc));
$("h1", doc).css("text-align", "center");
$("#mangaBox", doc).empty();
$(".footerControl", doc).remove();
$("#mangaBox", doc).css("width", "100%");
$("#mangaBox", doc).css("padding", "0");
$("#mangaBox", doc).css("padding-top", "10px");
$("#mangaBox", doc).css("padding-bottom", "10px");
$("#mangaBox", doc).css("border", "0");
$("#mangaBox", doc).css("background-color", "black");
$("#mangaBox", doc).before($("<div class='navAMR'></div>"));
$("#mangaBox", doc).after($("<div class='navAMR'></div>"));
},
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) {
$(image).attr("src", urlImg);
},
isImageInOneCol: function (img, doc, curUrl) {
return false;
},
getMangaSelectFromPage: function (doc, curUrl) {
$("#chapterSelectorSelect option", doc).each(function (index) {
$(this).val("http://readmanga.me" + $(this).val());
});
return $($("#chapterSelectorSelect", doc)[0]);
},
doAfterMangaLoaded: function (doc, curUrl) {
$("body > div:empty", doc).remove();
}
};
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject === "function") {
registerMangaObject("ReadManga", ReadManga);
}