MCPcopy Create free account
hub / github.com/MALSync/MALSync / ajaxHandle

Function ajaxHandle

src/pages/Proxer/main.ts:146–193  ·  view source on GitHub ↗
(page)

Source from the content-addressed store, hash-verified

144let current = 0;
145
146function ajaxHandle(page) {
147 if (utils.urlPart(page.url, 3) !== 'info') return;
148 const detailPart = utils.urlPart(page.url, 5);
149 con.info('page', detailPart);
150 if (detailPart === 'list') {
151 utils.waitUntilTrue(
152 function () {
153 return j.$('#contentList').length;
154 },
155 function () {
156 if (j.$('#simple-navi a[href*="manga"]').length) {
157 Proxer.type = 'manga';
158 } else {
159 Proxer.type = 'anime';
160 }
161
162 const tempCurrent: number = parseInt(Proxer.overview!.getIdentifier(page.url));
163 if (tempCurrent !== current) {
164 current = tempCurrent;
165 page.handlePage();
166 } else {
167 try {
168 page.handleList();
169 } catch (e) {
170 con.error(e);
171 page.handlePage();
172 }
173 }
174 },
175 );
176 }
177 if (detailPart === 'details' || !detailPart) {
178 utils.waitUntilTrue(
179 function () {
180 return j.$('.hreview-aggregate').length;
181 },
182 function () {
183 current = parseInt(Proxer.overview!.getIdentifier(page.url));
184 if (j.$('#simple-navi a[href*="manga"]').length) {
185 Proxer.type = 'manga';
186 } else {
187 Proxer.type = 'anime';
188 }
189 page.handlePage();
190 },
191 );
192 }
193}
194
195function getEpisodeFallback(string, fallback) {
196 const exclude = string.match(/(special|extra)/gi);

Callers 1

initFunction · 0.85

Calls 4

handlePageMethod · 0.80
handleListMethod · 0.80
errorMethod · 0.80
infoMethod · 0.45

Tested by

no test coverage detected