-
Notifications
You must be signed in to change notification settings - Fork 16
/
EasyGoing.js
134 lines (134 loc) · 5.14 KB
/
EasyGoing.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
var EasyGoing = {
mirrorName : "Easy Going",
canListFullMangas : true,
mirrorIcon : "img/easygoing.png",
languages : "en",
isMe : function (url) {
"use strict";
return (url.match(/read\.egscans\.(com|org)/gi) !== null);
},
getMangaList : function (search, callback) {
"use strict";
$.ajax({
url : "http://read.egscans.com/",
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');
$("select[name='manga'] option", div).each(function () {
if ($(this).attr('value') !== 0) {
res[res.length] = [$(this).text(), "http://read.egscans.com/" + $(this).attr('value')];
}
});
callback("Easy Going", 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');
$("select[name='chapter'] option", div).each(function (index) {
res[res.length] = [$(this).text(), urlManga + '/' + $(this).attr('value')];
});
res.reverse();
callback(res, obj);
}
});
},
getInformationsFromCurrentPage : function (doc, curUrl, callback) {
"use strict";
var name = $("select[name='manga'] option:selected", doc).text(),
currentChapter = $("select[name='chapter'] option:selected", doc).text(),
currentMangaURL = "http://read.egscans.com/" + $("select[name='manga'] option:selected", doc).attr('value'),
currentChapterURL = currentMangaURL + '/' + $("select[name='chapter'] option:selected", doc).attr('value');
callback({
"name" : name,
"currentChapter" : currentChapter,
"currentMangaURL" : currentMangaURL,
"currentChapterURL" : currentChapterURL
});
},
getListImages : function (doc, curUrl) {
"use strict";
var res = [],
img = [],
txt,
i;
txt = $(".mid > table:nth-child(1) > tbody:nth-child(1) > tr:nth-child(3) > td:nth-child(1) > script:nth-child(2)", doc).html();
txt = JSON.stringify(txt);
img = txt.match(/img_url\.push\(\'.+?\' \)/g);
for (i = 0; img.length > i; i += 1) {
res.push("http://read.egscans.com/" + img[i].match(/'(.*?)'/ig)[0].replace(/'/g, ""));
}
return res;
},
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 ($("select[name='chapter']", doc).length > 0);
},
doSomethingBeforeWritingScans : function (doc, curUrl) {
"use strict";
$('td.mid', doc).empty();
$('td.mid', doc).append($("<div class='navAMR'></div>"));
$('td.mid', doc).append($("<div class='imgAMR'></div>"));
$('td.mid', doc).append($("<div class='navAMR'></div>"));
$(".navAMR").css("text-align", "center");
},
nextChapterUrl : function (select, doc, curUrl) {
"use strict";
if ($(select).children("option:selected").prev().size() !== 0) {
return $(select).children("option:selected").prev().val();
}
return null;
},
previousChapterUrl : function (select, doc, curUrl) {
"use strict";
if ($(select).children("option:selected").next().size() !== 0) {
return $(select).children("option:selected").next().val();
}
return null;
},
getImageFromPageAndWrite : function (urlImg, image, doc, curUrl) {
"use strict";
$(image).attr("src", urlImg);
},
isImageInOneCol : function (img, doc, curUrl) {
"use strict";
return false;
},
getMangaSelectFromPage : function (doc, curUrl) {
"use strict";
return null;
},
doAfterMangaLoaded : function (doc, curUrl) {
"use strict";
$("body > div:empty", doc).remove();
$('select', doc).css('background-color', 'white');
$('option', doc).css('background-color', 'white').css('color', 'black');
}
};
// Call registerMangaObject to be known by includer
if (typeof registerMangaObject == 'function') {
registerMangaObject("Easy Going", EasyGoing);
}