-
Notifications
You must be signed in to change notification settings - Fork 16
/
Mangajoy.js
183 lines (183 loc) · 4.75 KB
/
Mangajoy.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
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
var Mangajoy = {
mirrorName: "Mangajoy",
canListFullMangas: false,
mirrorIcon: "img/mangajoy.png",
languages: "en",
isMe: function(url)
{
"use strict";
return (url.match(/^http:\/\/(www\.)?mangajoy\.com/gi) !== null);
},
getMangaList: function(search, callback)
{
"use strict";
$.ajax(
{
url: "http://mangajoy.com/manga-list/advanced-search/",
type: "POST",
data:
{
cbo_wpm_pag_mng_sch_nme: 0,
txt_wpm_pag_mng_sch_nme: search,
cmd_wpm_pag_mng_sch_sbm: "Search"
},
beforeSend: function(xhr)
{
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
success: function(objResponse)
{
// Limited to the first page of results, else a wide crazy search like 'a' would
// return more than a thousand pages of results.
var div = document.createElement("div"),
res = [];
div.innerHTML = objResponse.replace(/<img /gi, '<noload');
$(".srs h2 a", div).each(function()
{
res[res.length] = [$(this).text(), $(this).attr('href')];
});
callback("Mangajoy", 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"),
res = [];
div.innerHTML = objResponse.replace(/<img /gi, '<noload');
$(".chp_lst a", div).each(function (index) {
res[res.length] = [$('.val', this).text().substr(mangaName.length + 1), $(this).attr('href')];
});
callback(res, obj);
}
});
},
getInformationsFromCurrentPage: function(doc, curUrl, callback)
{
"use strict";
var name = $($("h1 a", doc)[1]).text(),
chapterSelect = $($(".wpm_nav_rdr select", doc)[0]),
currentChapter = $("option:selected", chapterSelect).text(),
currentMangaURL = chapterSelect.attr('onchange').toString().match(/location\.href='([^']+)'/)[1],
currentChapterURL = currentMangaURL + $("option:selected", chapterSelect).attr("value") + "/";
callback(
{
"name" : name,
"currentChapter" : currentChapter,
"currentMangaURL" : currentMangaURL,
"currentChapterURL" : currentChapterURL
});
},
getListImages: function(doc, curUrl)
{
"use strict";
var res = [],
pageSelect,
href,
i;
pageSelect = $($(".wpm_nav_rdr select", doc)[1]);
href = pageSelect.attr('onchange').toString().match(/location\.href='([^']+)'/)[1];
i = $("option", pageSelect).length;
for (true; i > 0; i -= 1)
{
res.push(href + i + "/");
}
res.reverse();
return res;
},
removeBanners: function(doc, curUrl)
{
return null;
},
whereDoIWriteScans: function(doc, curUrl)
{
"use strict";
return $('.imgAMR', doc);
},
whereDoIWriteNavigation: function(doc, curUrl)
{
"use strict";
return $(".navAMR", doc);
},
isCurrentPageAChapterPage: function(doc, curUrl)
{
"use strict";
return ($(".wpm_nav_rdr select", doc).length > 0);
},
doSomethingBeforeWritingScans: function(doc, curUrl)
{
"use strict";
$(".wpm_pag", doc).empty();
$(".wpm_pag", doc).append($("<div class='navAMR'></div>"));
$(".wpm_pag", doc).append($("<div class='imgAMR'></div>"));
$(".wpm_pag", doc).append($("<div class='navAMR'></div>"));
$(".navAMR", doc).css("text-align", "center");
},
nextChapterUrl: function(select, doc, curUrl)
{
"use strict";
if ($(select, doc).children("option:selected").prev().size() != 0) {
return $(select, doc).children("option:selected").prev().val();
}
return null;
},
previousChapterUrl: function(select, doc, curUrl)
{
"use strict";
if ($(select, doc).children("option:selected").next().size() !== 0) {
return $(select, doc).children("option:selected").next().val();
}
return null;
},
getImageFromPageAndWrite: function(urlImg, image, doc, curUrl)
{
"use strict";
$.ajax(
{
url: urlImg,
success: function(objResponse)
{
var div = document.createElement("div");
div.innerHTML = objResponse;
$(image).attr("src", $(".prw img", div).attr("src"));
}
});
},
isImageInOneCol: function(img, doc, curUrl)
{
"use strict";
return false;
},
getMangaSelectFromPage: function(doc, curUrl)
{
"use strict";
var chapterSelect = $($(".wpm_nav_rdr select", doc)[0]),
mangaUrl = chapterSelect.attr('onchange').toString().match(/location\.href='([^']+)'/)[1];
$("option", chapterSelect).each(function(index)
{
$(this).val(mangaUrl + $(this).val() + "/")
});
return chapterSelect;
},
doAfterMangaLoaded: function(doc, curUrl)
{
"use strict";
return null;
}
};
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject == 'function') {
registerMangaObject("Mangajoy", Mangajoy);
}