MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / doVideos

Function doVideos

scripts/backup/m38u_detector.js:468–507  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

466 let shownUrls = [];
467
468 function doVideos() {
469 for (let v of Array.from(document.querySelectorAll("video"))) {
470 if (
471 v.duration &&
472 v.src &&
473 v.src.startsWith("http") &&
474 !shownUrls.includes(v.src)
475 ) {
476 const src = v.src;
477
478 shownUrls.push(src);
479 showVideo({
480 type: "video",
481 url: new URL(src),
482 duration: `${Math.ceil((v.duration * 10) / 60) / 10} mins`,
483 download() {
484 const details = {
485 url: src,
486 name: (() => {
487 let name = new URL(src).pathname.split("/").slice(-1)[0];
488 if (!/\.\w+$/.test(name)) {
489 if (name.match(/^\s*$/)) name = Date.now();
490 name = name + ".mp4";
491 }
492 return name;
493 })(),
494 headers: {
495 // referer: location.origin, // 不允许该头
496 origin: location.origin,
497 },
498 onerror(e) {
499 mgmapi.openInTab(src);
500 },
501 };
502 mgmapi.download(details);
503 },
504 });
505 }
506 }
507 }
508
509 async function doM3U({ url, content }) {
510 url = new URL(url);

Callers

nothing calls this directly

Calls 1

showVideoFunction · 0.85

Tested by

no test coverage detected