From 0c1f46beb38df13813ba497abf77d39b39779cd0 Mon Sep 17 00:00:00 2001
From: absidue <48293849+absidue@users.noreply.github.com>
Date: Mon, 9 Dec 2024 23:41:29 +0100
Subject: [PATCH] fix(Player): Fix signature algorithm extraction

---
 src/core/Player.ts | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/src/core/Player.ts b/src/core/Player.ts
index b5cfac317..1345c9044 100644
--- a/src/core/Player.ts
+++ b/src/core/Player.ts
@@ -224,14 +224,21 @@ export default class Player {
   }
 
   static extractSigSourceCode(data: string): string {
-    const calls = getStringBetweenStrings(data, 'function(a){a=a.split("")', 'return a.join("")}');
+    let calls = getStringBetweenStrings(data, 'function(a){a=a.split("")', 'return a.join("")}');
+    let var_name = 'a';
+
+    if (!calls) {
+      calls = getStringBetweenStrings(data, 'function(J){J=J.split("")', 'return J.join("")}');
+      var_name = 'J';
+    }
+
     const obj_name = calls?.split(/\.|\[/)?.[0]?.replace(';', '')?.trim();
     const functions = getStringBetweenStrings(data, `var ${obj_name}={`, '};');
 
     if (!functions || !calls)
       Log.warn(TAG, 'Failed to extract signature decipher algorithm.');
 
-    return `function descramble_sig(a) { a = a.split(""); let ${obj_name}={${functions}}${calls} return a.join("") } descramble_sig(sig);`;
+    return `function descramble_sig(${var_name}) { ${var_name} = ${var_name}.split(""); let ${obj_name}={${functions}}${calls} return ${var_name}.join("") } descramble_sig(sig);`;
   }
 
   static extractNSigSourceCode(data: string): string | undefined {