Add more utils

This commit is contained in:
bytedream 2025-04-03 23:48:53 +02:00
parent c081127d35
commit f6fcfd354a
3 changed files with 8 additions and 7 deletions

View File

@ -1,5 +1,6 @@
import { unpack } from './utils'; import { unpack } from './util/userspace';
import { Hosters, Redirect, TmpHost } from './settings'; import { Hosters, Redirect, TmpHost } from './settings';
import {lastPathSegment} from "~/lib/util/extract";
export interface Match { export interface Match {
name: string; name: string;
@ -113,10 +114,9 @@ export const LoadX: Match = {
regex: [/./gm], regex: [/./gm],
match: async () => { match: async () => {
const postMatch = window.location.href.match(/(?<=\/video\/)\S*(\/.*)?/)!; const hash = encodeURIComponent(lastPathSegment(window.location.href));
const response = await fetch( const response = await fetch(
`https://${window.location.host}/player/index.php?data=${encodeURIComponent(postMatch[0])}&do=getVideo`, `https://${window.location.host}/player/index.php?data=${hash}&do=getVideo`,
{ {
method: 'POST', method: 'POST',
headers: { headers: {
@ -140,11 +140,9 @@ export const Luluvdo: Match = {
regex: [/./gm], regex: [/./gm],
match: async () => { match: async () => {
const postMatch = window.location.href.match(/(?<=\/embed\/)\S*(\/.*)?/)!;
const requestBody = new FormData(); const requestBody = new FormData();
requestBody.set('op', 'embed'); requestBody.set('op', 'embed');
requestBody.set('file_code', postMatch[0]); requestBody.set('file_code', lastPathSegment(window.location.href));
const response = await fetch(`https://${window.location.host}/dl`, { const response = await fetch(`https://${window.location.host}/dl`, {
method: 'POST', method: 'POST',
body: requestBody, body: requestBody,

3
src/lib/util/extract.ts Normal file
View File

@ -0,0 +1,3 @@
export function lastPathSegment(path: string): string {
return path.substring(path.lastIndexOf('/'));
}