-
Notifications
You must be signed in to change notification settings - Fork 16
/
MangaInn.js
139 lines (139 loc) · 5.72 KB
/
MangaInn.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
var MangaInn = {
mirrorName : "MangaInn",
canListFullMangas : false,
languages : "en",
isMe : function (url) {
return (url.indexOf("mangainn.me/") !== -1);
},
getMangaList : function (search, callback) {
$.ajax({
url : "http://www.mangainn.me/advresults",
type : 'POST',
data : {
"seriestype" : "c",
"series" : search,
"authortype" : "c",
"artisttype" : "c",
"yeartype" : "o"
},
beforeSend : function (xhr) {
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
xhr.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
},
success : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse.replace(/<img/gi, '<noload');
var res = [];
$(".content .TurqHeadLabel", div).each(function (index) {
res[res.length] = [$(this).text().trim(), 'http://www.mangainn.me/manga/' + $(this).attr("onclick").toString().replace("function onclick(event) {", "").replace("MangaInfo", "").replace("}", "").replace("('", "").replace("')", "").trim()];
});
res.sort(function (a, b) {
return ((a[0].toLowerCase() < b[0].toLowerCase()) ? -1 : ((a[0] === b[0]) ? 0 : 1));
});
callback("MangaInn", res);
}
});
},
getListChaps : function (urlManga, mangaName, obj, callback) {
$.ajax({
url : urlManga,
beforeSend : function (xhr) {
xhr.setRequestHeader("Cache-Control", "no-cache");
xhr.setRequestHeader("Pragma", "no-cache");
},
complete : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse.responseText.replace(/<img/gi, '<noload');
var res = [];
$(".divThickBorder:last .BlackLabel14 a", div).each(function () {
if ($(this).text().trim() !== "") {
var name = $(this)[0].innerText.replace(mangaName, '').trim();
name = name.replace(' :', ':');
res[res.length] = [name, $(this)[0].href];
}
});
res.reverse();
callback(res, obj);
}
});
},
isCurrentPageAChapterPage : function (doc, curUrl) {
return (curUrl.search('www.mangainn.me/manga/chapter') > -1);
},
getInformationsFromCurrentPage : function (doc, curUrl, callback) {
var name = $('#gotoMangaInfo', doc).text();
var currentChapter = $('#chapters option:selected', doc).text().replace(name, '').trim();
var currentMangaURL = $('#gotoMangaInfo', doc).attr('href');
var currentChapterURL = "http://www.mangainn.me/manga/chapter/" + $("#chapters option:selected", doc).val();
callback({
"name" : name,
"currentChapter" : currentChapter,
"currentMangaURL" : currentMangaURL,
"currentChapterURL" : currentChapterURL
});
},
getListImages : function (doc, curUrl) {
var res = [];
$('#cmbpages > option', doc).each(function () {
if (this.value > 0) {
res.push(curUrl.substr(0, curUrl.length) + '/page_' + this.value);
}
});
return res;
},
getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) {
$.ajax({
url : urlImg,
success : function (objResponse) {
var div = document.createElement("div");
div.innerHTML = objResponse;
var src = $("img#imgPage", div).attr("src");
$(image).attr("src", src);
}
});
},
removeBanners : function (doc, curUrl) {
$("#divmangareadtopad", doc).remove();
$("#divmangareadtopad2", doc).remove();
},
whereDoIWriteScans : function (doc, curUrl) {
return $(".scanAMR", doc);
},
whereDoIWriteNavigation : function (doc, curUrl) {
return $(".navAMR", doc);
},
doSomethingBeforeWritingScans : function (doc, curUrl) {
$(".boscontent", doc).after("<div class='amrcontainer'></div>");
$(".boscontent", doc).empty();
$(".footer", doc).hide();
$(".amrcontainer", doc).append("<div class='navAMR widepage'></div>");
$(".amrcontainer", doc).append("<div class='scanAMR widepage'></div>");
$(".amrcontainer", doc).append("<div class='navAMR widepage'></div>");
},
nextChapterUrl : function (select, doc, curUrl) {
if ($(select).children("option:selected").next().size() !== 0) {
return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").next().val();
}
return null;
},
previousChapterUrl : function (select, doc, curUrl) {
if ($(select).children("option:selected").prev().size() !== 0) {
return "http://www.mangainn.me/manga/chapter/" + $(select).children("option:selected").prev().val();
}
return null;
},
isImageInOneCol : function (img, doc, curUrl) {
return false;
},
getMangaSelectFromPage : function (doc, curUrl) {
return $("#chapters", doc);
},
doAfterMangaLoaded : function (doc, curUrl) {
$("body > div:empty", doc).remove();
}
};
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject == 'function') {
registerMangaObject("MangaInn", MangaInn);
}