MCPcopy Index your code
hub / github.com/MALSync/MALSync / handlePage

Method handlePage

src/pages-sync/syncPage.ts:162–350  ·  view source on GitHub ↗
(curUrl = window.location.href)

Source from the content-addressed store, hash-verified

160 }
161
162 async handlePage(curUrl = window.location.href) {
163 let state: pageState;
164 this.curState = undefined;
165 this.setSearchObj(undefined);
166 this.url = curUrl;
167 this.browsingtime = Date.now();
168 let tempSingle;
169
170 if (this.page.isSyncPage(this.url)) {
171 this.loadUI();
172 state = {
173 on: 'SYNC',
174 title: this.page.sync.getTitle(this.url),
175 identifier: this.page.sync.getIdentifier(this.url),
176 detectedEpisode: parseInt(`${this.page.sync.getEpisode(this.url)}`),
177 };
178
179 this.setSearchObj(
180 new SearchClass(state.title, this.novel ? 'novel' : this.page.type, state.identifier),
181 );
182 this.searchObj.setPage(this.page);
183 this.searchObj.setSyncPage(this);
184 this.searchObj.setLocalUrl(this.generateLocalUrl(this.page, state));
185 this.curState = state;
186 await this.searchObj.search();
187
188 try {
189 tempSingle = await this.searchObj.initRules();
190 } catch (e) {
191 if (e instanceof UrlNotSupportedError) {
192 this.incorrectUrl();
193 }
194 throw e;
195 }
196
197 if (!state.detectedEpisode && state.detectedEpisode !== 0) {
198 if (this.page.type === 'anime') {
199 state.episode = 1;
200 } else {
201 state.episode = 0;
202 }
203 } else {
204 state.episode =
205 state.detectedEpisode + parseInt(this.searchObj.getRuledOffset(state.detectedEpisode));
206 }
207
208 if (typeof this.page.sync.getVolume !== 'undefined') {
209 state.volume = this.page.sync.getVolume(this.url);
210 }
211 if (this.page.type === 'anime') {
212 const playerInstance = PlayerSingleton.getInstance().startTracking();
213 playerInstance.addListener('syncPage', item => {
214 this.autoNextEp(item);
215 });
216 }
217 logger.m('Sync', 'green').log(state);
218 } else {
219 if (typeof this.page.overview === 'undefined') {

Callers 15

openCorrectionUiMethod · 0.95
buttonclickMethod · 0.95
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
checkFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80
initFunction · 0.80

Calls 15

setSearchObjMethod · 0.95
loadUIMethod · 0.95
generateLocalUrlMethod · 0.95
incorrectUrlMethod · 0.95
autoNextEpMethod · 0.95
fillUIMethod · 0.95
checkForFillerMethod · 0.95
startSyncHandlingMethod · 0.95
imageFallbackMethod · 0.95
getSingleFunction · 0.90
setPageMethod · 0.80
setSyncPageMethod · 0.80

Tested by

no test coverage detected