()
| 334 | }, |
| 335 | // 这里不使用 oncompelete ,如果某个资源一直在加载中,就会导致 oncomplete 一直无法触发,导致脚本无法运行,所以改为 onactive 只要匹配上就会触发 |
| 336 | async onactive() { |
| 337 | /** iframe 跨域问题, 必须在 iframe 中执行 , 所以脱离学习脚本运行。 */ |
| 338 | if (/\/readsvr\/book\/mooc/.test(location.href)) { |
| 339 | // 26年上半学期新阅读任务点,计时翻页,达到一定时间才能翻下一页,这里等待时间然后执行翻页完成任务。 |
| 340 | if (document.querySelector('#reader')) { |
| 341 | // @ts-ignore |
| 342 | require(['reader'], (_reader) => { |
| 343 | waitForElement('.readerPager').then(() => { |
| 344 | setTimeout(async () => { |
| 345 | const jumper = document.querySelector<HTMLSelectElement>('#pagejump'); |
| 346 | if (_reader?.goPage && jumper) { |
| 347 | // 等待时间 |
| 348 | const timing = parseInt(new URL(location.href).searchParams.get('timing')?.toString() || '60') + 3; |
| 349 | console.log(timing); |
| 350 | await $.sleep(timing * 1000); |
| 351 | /** |
| 352 | * 1:书名页 |
| 353 | 2:版权页 |
| 354 | 3:前言页 |
| 355 | 4:目录页 |
| 356 | 5:正文275页 |
| 357 | 7:封底页 |
| 358 | */ |
| 359 | jumper.value = '5'; |
| 360 | jumper.dispatchEvent(new Event('change')); |
| 361 | console.log('已跳转正文页'); |
| 362 | await $.sleep(timing * 1000); |
| 363 | jumper.value = '7'; |
| 364 | jumper.dispatchEvent(new Event('change')); |
| 365 | console.log('已跳转封底页'); |
| 366 | await $.sleep(timing * 1000); |
| 367 | Array.from(document.querySelectorAll<HTMLElement>('.readerPager')) |
| 368 | .filter((el) => el.style.zIndex === '101')[0] |
| 369 | .click(); |
| 370 | console.log('阅读完成'); |
| 371 | } |
| 372 | }, 3000); |
| 373 | }); |
| 374 | }); |
| 375 | } |
| 376 | // 普通阅读任务点,id 是 #ReadWeb |
| 377 | else { |
| 378 | $console.log('正在完成书籍/PPT...'); |
| 379 | setTimeout(() => { |
| 380 | // @ts-ignore |
| 381 | // eslint-disable-next-line no-undef |
| 382 | readweb.goto(epage); |
| 383 | }, 5000); |
| 384 | } |
| 385 | return; |
| 386 | } |
| 387 | |
| 388 | // 主要处理 |
| 389 | if (/\/knowledge\/cards/.test(location.href)) { |
| 390 | const updateMediaState = () => { |
| 391 | // @ts-ignore |
| 392 | if (top.currentMedia) { |
| 393 | // @ts-ignore 倍速设置 |
nothing calls this directly
no test coverage detected