mirror of
https://github.com/ajayyy/SponsorBlockServer.git
synced 2025-12-16 16:37:12 +03:00
Parse user agent header
This commit is contained in:
13
src/utils/userAgent.ts
Normal file
13
src/utils/userAgent.ts
Normal file
@@ -0,0 +1,13 @@
|
||||
export function parseUserAgent(userAgent: string): string {
|
||||
const ua = userAgent.toLowerCase();
|
||||
|
||||
if (ua.includes("com.google.android.youtube/") || ua.includes("com.vanced.android.youtube/")) {
|
||||
return `Vanced/${ua.match(/.android.youtube\/([^\s]+)/)[1]}`;
|
||||
}
|
||||
|
||||
if (ua.includes("mpv_sponsorblock/")) {
|
||||
return ua;
|
||||
}
|
||||
|
||||
return "";
|
||||
}
|
||||
Reference in New Issue
Block a user