|
@@ -82,15 +82,30 @@ getStringBetween = (string, needleStart, needleEnd, offsetStart = 0, offsetEnd =
|
|
return string.substring(x + needleStart.length + offsetEnd, y + offsetStart);
|
|
return string.substring(x + needleStart.length + offsetEnd, y + offsetStart);
|
|
}
|
|
}
|
|
|
|
|
|
-getDecipherFunction = (string) => {
|
|
|
|
- const js = string.replace("var _yt_player={}", "");
|
|
|
|
- const top = getStringBetween(js, `a=a.split("")`, "};", 1, -28);
|
|
|
|
- const beginningOfFunction =
|
|
|
|
- "var " + getStringBetween(top, `a=a.split("")`, "(", 10, 1).split(".")[0] + "=";
|
|
|
|
- const side = getStringBetween(js, beginningOfFunction, "};", 2, -beginningOfFunction.length);
|
|
|
|
- console.log(`side: ${side}`);
|
|
|
|
- console.log(`top: ${top}`);
|
|
|
|
- return eval(side + top);
|
|
|
|
|
|
+getDecipherFunction = (jsCode) => {
|
|
|
|
+ const match = jsCode.match(/([a-zA-Z0-9]+)=function\([a-zA-Z0-9]+\)\{a=a\.split\(""\).*};/)
|
|
|
|
+ if (!match && match.length <= 1) {
|
|
|
|
+ return null;
|
|
|
|
+ }
|
|
|
|
+ let result = "";
|
|
|
|
+ const dependencyMatchs = match[0].match(/([$a-zA-Z0-9]+\.[$a-zA-Z0-9]+)/g)
|
|
|
|
+ const existDependencies = [];
|
|
|
|
+ if (dependencyMatchs && dependencyMatchs.length >= 1) {
|
|
|
|
+ for (let currentMatch of dependencyMatchs) {
|
|
|
|
+ const varName = currentMatch.split('.')[0];
|
|
|
|
+ if (existDependencies.includes(varName)) {
|
|
|
|
+ continue
|
|
|
|
+ }
|
|
|
|
+ const varNameMatch = jsCode.match(new RegExp(`var \\${varName}={(.|\\n)*?};`), 'ig');
|
|
|
|
+ if (varNameMatch && varNameMatch.length >= 1) {
|
|
|
|
+ result += varNameMatch[0] + "\n";
|
|
|
|
+ }
|
|
|
|
+ existDependencies.push(varName);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ result += `\n${match[0]}`;
|
|
|
|
+ console.log(`decipherFunction result: ` + result);
|
|
|
|
+ return eval(result);
|
|
};
|
|
};
|
|
|
|
|
|
const cache = {};
|
|
const cache = {};
|
|
@@ -119,7 +134,7 @@ getUrlFromSignature = async (signatureCipher, baseJsUrl, platform) => {
|
|
searchParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
searchParams[decodeURIComponent(key)] = decodeURIComponent(value);
|
|
}
|
|
}
|
|
const [url, signature, sp] = [searchParams["url"], searchParams["s"], searchParams["sp"]];
|
|
const [url, signature, sp] = [searchParams["url"], searchParams["s"], searchParams["sp"]];
|
|
- console.log(signatureCipher, url, signature, sp);
|
|
|
|
|
|
+ console.log(`signatureCipher=${signatureCipher}, url=${url}, signature=${signature}, sp=${sp}`)
|
|
return `${url}&${sp}=${decipher(signature)}`;
|
|
return `${url}&${sp}=${decipher(signature)}`;
|
|
}
|
|
}
|
|
|
|
|