Improve useragent parsing

This commit is contained in:
Ajay 2022-02-22 00:51:45 -05:00
parent 22b4135d62
commit dbb8128a3a

View file

@ -1,11 +1,11 @@
export function parseUserAgent(userAgent: string): string {
const ua = userAgent.toLowerCase();
if (ua.includes("com.google.android.youtube/") || ua.includes("com.vanced.android.youtube/")) {
if (ua.match(/(com.google.android.youtube\/)|(com.vanced.android.youtube\/)|(^YouTube\/)|(^Dalvik\/)/)) {
return `Vanced/${ua.match(/.android.youtube\/([^\s]+)/)[1]}`;
}
if (ua.includes("mpv_sponsorblock/")) {
if (ua.match(/(mpv_sponsorblock\/)|(^python-requests)|(^GuzzleHttp\/)|(^PostmanRuntime\/)/)) {
return ua;
}