mirror of
https://github.com/yt-dlp/yt-dlp.git
synced 2026-03-03 04:39:23 +00:00
6
Makefile
6
Makefile
@@ -202,9 +202,9 @@ CONTRIBUTORS: Changelog.md
|
|||||||
|
|
||||||
# The following EJS_-prefixed variables are auto-generated by devscripts/update_ejs.py
|
# The following EJS_-prefixed variables are auto-generated by devscripts/update_ejs.py
|
||||||
# DO NOT EDIT!
|
# DO NOT EDIT!
|
||||||
EJS_VERSION = 0.4.0
|
EJS_VERSION = 0.5.0
|
||||||
EJS_WHEEL_NAME = yt_dlp_ejs-0.4.0-py3-none-any.whl
|
EJS_WHEEL_NAME = yt_dlp_ejs-0.5.0-py3-none-any.whl
|
||||||
EJS_WHEEL_HASH = sha256:19278cff397b243074df46342bb7616c404296aeaff01986b62b4e21823b0b9c
|
EJS_WHEEL_HASH = sha256:674fc0efea741d3100cdf3f0f9e123150715ee41edf47ea7a62fbdeda204bdec
|
||||||
EJS_PY_FOLDERS = yt_dlp_ejs yt_dlp_ejs/yt yt_dlp_ejs/yt/solver
|
EJS_PY_FOLDERS = yt_dlp_ejs yt_dlp_ejs/yt yt_dlp_ejs/yt/solver
|
||||||
EJS_PY_FILES = yt_dlp_ejs/__init__.py yt_dlp_ejs/_version.py yt_dlp_ejs/yt/__init__.py yt_dlp_ejs/yt/solver/__init__.py
|
EJS_PY_FILES = yt_dlp_ejs/__init__.py yt_dlp_ejs/_version.py yt_dlp_ejs/yt/__init__.py yt_dlp_ejs/yt/solver/__init__.py
|
||||||
EJS_JS_FOLDERS = yt_dlp_ejs/yt/solver
|
EJS_JS_FOLDERS = yt_dlp_ejs/yt/solver
|
||||||
|
|||||||
@@ -55,7 +55,7 @@ default = [
|
|||||||
"requests>=2.32.2,<3",
|
"requests>=2.32.2,<3",
|
||||||
"urllib3>=2.0.2,<3",
|
"urllib3>=2.0.2,<3",
|
||||||
"websockets>=13.0",
|
"websockets>=13.0",
|
||||||
"yt-dlp-ejs==0.4.0",
|
"yt-dlp-ejs==0.5.0",
|
||||||
]
|
]
|
||||||
curl-cffi = [
|
curl-cffi = [
|
||||||
"curl-cffi>=0.5.10,!=0.6.*,!=0.7.*,!=0.8.*,!=0.9.*,<0.15; implementation_name=='cpython'",
|
"curl-cffi>=0.5.10,!=0.6.*,!=0.7.*,!=0.8.*,!=0.9.*,<0.15; implementation_name=='cpython'",
|
||||||
|
|||||||
@@ -105,6 +105,66 @@ CHALLENGES: list[Challenge] = [
|
|||||||
'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt':
|
'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt':
|
||||||
'ttJC2JfQdSswRAIgGBCxZyAfKyi0cjXCb3DqEctUw-NYdNmOEvaepit0zJAtIEsgOV2SXZjhSHMNy0NXNGa1kOyBf6HPuAuCduh-_',
|
'ttJC2JfQdSswRAIgGBCxZyAfKyi0cjXCb3DqEctUw-NYdNmOEvaepit0zJAtIEsgOV2SXZjhSHMNy0NXNGa1kOyBf6HPuAuCduh-_',
|
||||||
}),
|
}),
|
||||||
|
# 4e51e895: main variant broke sig solving; n challenge is added only for regression testing
|
||||||
|
Challenge('4e51e895', Variant.main, JsChallengeType.N, {
|
||||||
|
'0eRGgQWJGfT5rFHFj': 't5kO23_msekBur',
|
||||||
|
}),
|
||||||
|
Challenge('4e51e895', Variant.main, JsChallengeType.SIG, {
|
||||||
|
'AL6p_8AwdY9yAhRzK8rYA_9n97Kizf7_9n97Kizf7_9n97Kizf7_9n97Kizf7_9n97Kizf7_9n97Kizf7':
|
||||||
|
'AwdY9yAhRzK8rYA_9n97Kizf7_9n97Kizf7_9n9pKizf7_9n97Kizf7_9n97Kizf7_9n97Kizf7',
|
||||||
|
}),
|
||||||
|
# 42c5570b: tce variant broke sig solving; n challenge is added only for regression testing
|
||||||
|
Challenge('42c5570b', Variant.tce, JsChallengeType.N, {
|
||||||
|
'ZdZIqFPQK-Ty8wId': 'CRoXjB-R-R',
|
||||||
|
}),
|
||||||
|
Challenge('42c5570b', Variant.tce, JsChallengeType.SIG, {
|
||||||
|
'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt':
|
||||||
|
'EN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavcOmNdYN-wUtgEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt',
|
||||||
|
}),
|
||||||
|
# 54bd1de4: tce variant broke sig solving; n challenge is added only for regression testing
|
||||||
|
Challenge('54bd1de4', Variant.tce, JsChallengeType.N, {
|
||||||
|
'ZdZIqFPQK-Ty8wId': 'ka-slAQ31sijFN',
|
||||||
|
}),
|
||||||
|
Challenge('54bd1de4', Variant.tce, JsChallengeType.SIG, {
|
||||||
|
'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0tipeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtt':
|
||||||
|
'gN7a-hudCuAuPH6fByOk1_GNXN0yNMHShjZXS2VOgsEItAJz0titeavEOmNdYN-wUtcEqD3bCXjc0iyKfAyZxCBGgIARwsSdQfJ2CJtp',
|
||||||
|
}),
|
||||||
|
# 94667337: tce and es6 variants broke sig solving; n and main/tv variants are added only for regression testing
|
||||||
|
Challenge('94667337', Variant.main, JsChallengeType.N, {
|
||||||
|
'BQoJvGBkC2nj1ZZLK-': 'ib1ShEOGoFXIIw',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.main, JsChallengeType.SIG, {
|
||||||
|
'NJAJEij0EwRgIhAI0KExTgjfPk-MPM9MAdzyyPRt=BM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=gwzz':
|
||||||
|
'AJEij0EwRgIhAI0KExTgjfPk-MPM9MNdzyyPRtzBM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.tv, JsChallengeType.N, {
|
||||||
|
'BQoJvGBkC2nj1ZZLK-': 'ib1ShEOGoFXIIw',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.tv, JsChallengeType.SIG, {
|
||||||
|
'NJAJEij0EwRgIhAI0KExTgjfPk-MPM9MAdzyyPRt=BM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=gwzz':
|
||||||
|
'AJEij0EwRgIhAI0KExTgjfPk-MPM9MNdzyyPRtzBM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.es6, JsChallengeType.N, {
|
||||||
|
'BQoJvGBkC2nj1ZZLK-': 'ib1ShEOGoFXIIw',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.es6, JsChallengeType.SIG, {
|
||||||
|
'NJAJEij0EwRgIhAI0KExTgjfPk-MPM9MAdzyyPRt=BM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=gwzz':
|
||||||
|
'AJEij0EwRgIhAI0KExTgjfPk-MPM9MNdzyyPRtzBM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.tce, JsChallengeType.N, {
|
||||||
|
'BQoJvGBkC2nj1ZZLK-': 'ib1ShEOGoFXIIw',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.tce, JsChallengeType.SIG, {
|
||||||
|
'NJAJEij0EwRgIhAI0KExTgjfPk-MPM9MAdzyyPRt=BM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=gwzz':
|
||||||
|
'AJEij0EwRgIhAI0KExTgjfPk-MPM9MNdzyyPRtzBM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.es6_tce, JsChallengeType.N, {
|
||||||
|
'BQoJvGBkC2nj1ZZLK-': 'ib1ShEOGoFXIIw',
|
||||||
|
}),
|
||||||
|
Challenge('94667337', Variant.es6_tce, JsChallengeType.SIG, {
|
||||||
|
'NJAJEij0EwRgIhAI0KExTgjfPk-MPM9MAdzyyPRt=BM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=gwzz':
|
||||||
|
'AJEij0EwRgIhAI0KExTgjfPk-MPM9MNdzyyPRtzBM8-XO5tm5hlMCSVpAiEAv7eP3CURqZNSPow8BXXAoazVoXgeMP7gH9BdylHCwgw=',
|
||||||
|
}),
|
||||||
]
|
]
|
||||||
|
|
||||||
requests: list[JsChallengeRequest] = []
|
requests: list[JsChallengeRequest] = []
|
||||||
|
|||||||
@@ -1,10 +1,10 @@
|
|||||||
# This file is generated by devscripts/update_ejs.py. DO NOT MODIFY!
|
# This file is generated by devscripts/update_ejs.py. DO NOT MODIFY!
|
||||||
|
|
||||||
VERSION = '0.4.0'
|
VERSION = '0.5.0'
|
||||||
HASHES = {
|
HASHES = {
|
||||||
'yt.solver.bun.lib.js': '6ff45e94de9f0ea936a183c48173cfa9ce526ee4b7544cd556428427c1dd53c8073ef0174e79b320252bf0e7c64b0032cc1cf9c4358f3fda59033b7caa01c241',
|
'yt.solver.bun.lib.js': '6ff45e94de9f0ea936a183c48173cfa9ce526ee4b7544cd556428427c1dd53c8073ef0174e79b320252bf0e7c64b0032cc1cf9c4358f3fda59033b7caa01c241',
|
||||||
'yt.solver.core.js': '05964b458d92a65d4fb7a90bcb5921c9fed2370f4e4f2f25badb41f28aff9069e0b3c4e5bf1baf2d3021787b67fc6093cefa44de30cffdc6f9fb25532484003b',
|
'yt.solver.core.js': '9742868113d7b0c29e24a95c8eb2c2bec7cdf95513dc7f55f523ba053c0ecf2af7dcb0138b1d933578304f0dda633a6b3bfff64e912b4c547b99dad083428c4b',
|
||||||
'yt.solver.core.min.js': '0cd3c0b37e095d3cca99443b58fe03980ac3bf2e777c2485c23e1f6052b5ede9f07c7f1c79a9c3af3258ea91a228f099741e7eb07b53125b5dcc84bb4c0054f3',
|
'yt.solver.core.min.js': 'aee8c3354cfd535809c871c2a517d03231f89cd184e903af82ee274bcc2e90991ef19cb3f65f2ccc858c4963856ea87f8692fe16d71209f4fc7f41c44b828e36',
|
||||||
'yt.solver.deno.lib.js': '9c8ee3ab6c23e443a5a951e3ac73c6b8c1c8fb34335e7058a07bf99d349be5573611de00536dcd03ecd3cf34014c4e9b536081de37af3637c5390c6a6fd6a0f0',
|
'yt.solver.deno.lib.js': '9c8ee3ab6c23e443a5a951e3ac73c6b8c1c8fb34335e7058a07bf99d349be5573611de00536dcd03ecd3cf34014c4e9b536081de37af3637c5390c6a6fd6a0f0',
|
||||||
'yt.solver.lib.js': '1ee3753a8222fc855f5c39db30a9ccbb7967dbe1fb810e86dc9a89aa073a0907f294c720e9b65427d560a35aa1ce6af19ef854d9126a05ca00afe03f72047733',
|
'yt.solver.lib.js': '1ee3753a8222fc855f5c39db30a9ccbb7967dbe1fb810e86dc9a89aa073a0907f294c720e9b65427d560a35aa1ce6af19ef854d9126a05ca00afe03f72047733',
|
||||||
'yt.solver.lib.min.js': '8420c259ad16e99ce004e4651ac1bcabb53b4457bf5668a97a9359be9a998a789fee8ab124ee17f91a2ea8fd84e0f2b2fc8eabcaf0b16a186ba734cf422ad053',
|
'yt.solver.lib.min.js': '8420c259ad16e99ce004e4651ac1bcabb53b4457bf5668a97a9359be9a998a789fee8ab124ee17f91a2ea8fd84e0f2b2fc8eabcaf0b16a186ba734cf422ad053',
|
||||||
|
|||||||
@@ -60,25 +60,28 @@ var jsc = (function (meriyah, astring) {
|
|||||||
}
|
}
|
||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
const nsigExpression = {
|
const nsig = {
|
||||||
type: 'VariableDeclaration',
|
|
||||||
kind: 'var',
|
|
||||||
declarations: [
|
|
||||||
{
|
|
||||||
type: 'VariableDeclarator',
|
|
||||||
init: {
|
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
callee: { type: 'Identifier' },
|
callee: { or: [{ type: 'Identifier' }, { type: 'SequenceExpression' }] },
|
||||||
arguments: [
|
arguments: [
|
||||||
{ type: 'Literal' },
|
{},
|
||||||
{
|
{
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
callee: { type: 'Identifier', name: 'decodeURIComponent' },
|
callee: { type: 'Identifier', name: 'decodeURIComponent' },
|
||||||
|
arguments: [{}],
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
};
|
||||||
},
|
const nsigAssignment = {
|
||||||
],
|
type: 'AssignmentExpression',
|
||||||
|
left: { type: 'Identifier' },
|
||||||
|
operator: '=',
|
||||||
|
right: nsig,
|
||||||
|
};
|
||||||
|
const nsigDeclarator = {
|
||||||
|
type: 'VariableDeclarator',
|
||||||
|
id: { type: 'Identifier' },
|
||||||
|
init: nsig,
|
||||||
};
|
};
|
||||||
const logicalExpression = {
|
const logicalExpression = {
|
||||||
type: 'ExpressionStatement',
|
type: 'ExpressionStatement',
|
||||||
@@ -97,6 +100,17 @@ var jsc = (function (meriyah, astring) {
|
|||||||
callee: { type: 'Identifier' },
|
callee: { type: 'Identifier' },
|
||||||
arguments: {
|
arguments: {
|
||||||
or: [
|
or: [
|
||||||
|
[
|
||||||
|
{
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'Identifier',
|
||||||
|
name: 'decodeURIComponent',
|
||||||
|
},
|
||||||
|
arguments: [{ type: 'Identifier' }],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
[
|
[
|
||||||
{ type: 'Literal' },
|
{ type: 'Literal' },
|
||||||
{
|
{
|
||||||
@@ -110,6 +124,8 @@ var jsc = (function (meriyah, astring) {
|
|||||||
},
|
},
|
||||||
],
|
],
|
||||||
[
|
[
|
||||||
|
{ type: 'Literal' },
|
||||||
|
{ type: 'Literal' },
|
||||||
{
|
{
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
callee: {
|
callee: {
|
||||||
@@ -138,18 +154,18 @@ var jsc = (function (meriyah, astring) {
|
|||||||
expression: {
|
expression: {
|
||||||
type: 'AssignmentExpression',
|
type: 'AssignmentExpression',
|
||||||
operator: '=',
|
operator: '=',
|
||||||
left: { type: 'Identifier' },
|
left: { or: [{ type: 'Identifier' }, { type: 'MemberExpression' }] },
|
||||||
right: { type: 'FunctionExpression', params: [{}, {}, {}] },
|
right: { type: 'FunctionExpression' },
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{ type: 'FunctionDeclaration', params: [{}, {}, {}] },
|
{ type: 'FunctionDeclaration' },
|
||||||
{
|
{
|
||||||
type: 'VariableDeclaration',
|
type: 'VariableDeclaration',
|
||||||
declarations: {
|
declarations: {
|
||||||
anykey: [
|
anykey: [
|
||||||
{
|
{
|
||||||
type: 'VariableDeclarator',
|
type: 'VariableDeclarator',
|
||||||
init: { type: 'FunctionExpression', params: [{}, {}, {}] },
|
init: { type: 'FunctionExpression' },
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
@@ -157,20 +173,18 @@ var jsc = (function (meriyah, astring) {
|
|||||||
],
|
],
|
||||||
};
|
};
|
||||||
function extract$1(node) {
|
function extract$1(node) {
|
||||||
if (!matchesStructure(node, identifier$1)) {
|
const blocks = [];
|
||||||
return null;
|
if (matchesStructure(node, identifier$1)) {
|
||||||
}
|
|
||||||
let block;
|
|
||||||
if (
|
if (
|
||||||
node.type === 'ExpressionStatement' &&
|
node.type === 'ExpressionStatement' &&
|
||||||
node.expression.type === 'AssignmentExpression' &&
|
node.expression.type === 'AssignmentExpression' &&
|
||||||
node.expression.right.type === 'FunctionExpression'
|
node.expression.right.type === 'FunctionExpression' &&
|
||||||
|
node.expression.right.params.length >= 3
|
||||||
) {
|
) {
|
||||||
block = node.expression.right.body;
|
blocks.push(node.expression.right.body);
|
||||||
} else if (node.type === 'VariableDeclaration') {
|
} else if (node.type === 'VariableDeclaration') {
|
||||||
for (const decl of node.declarations) {
|
for (const decl of node.declarations) {
|
||||||
if (
|
if (
|
||||||
decl.type === 'VariableDeclarator' &&
|
|
||||||
_optionalChain$2([
|
_optionalChain$2([
|
||||||
decl,
|
decl,
|
||||||
'access',
|
'access',
|
||||||
@@ -178,97 +192,123 @@ var jsc = (function (meriyah, astring) {
|
|||||||
'optionalAccess',
|
'optionalAccess',
|
||||||
(_2) => _2.type,
|
(_2) => _2.type,
|
||||||
]) === 'FunctionExpression' &&
|
]) === 'FunctionExpression' &&
|
||||||
|
decl.init.params.length >= 3
|
||||||
|
) {
|
||||||
|
blocks.push(decl.init.body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
node.type === 'FunctionDeclaration' &&
|
||||||
|
node.params.length >= 3
|
||||||
|
) {
|
||||||
|
blocks.push(node.body);
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} else if (
|
||||||
|
node.type === 'ExpressionStatement' &&
|
||||||
|
node.expression.type === 'SequenceExpression'
|
||||||
|
) {
|
||||||
|
for (const expr of node.expression.expressions) {
|
||||||
|
if (
|
||||||
|
expr.type === 'AssignmentExpression' &&
|
||||||
|
expr.right.type === 'FunctionExpression' &&
|
||||||
|
expr.right.params.length === 3
|
||||||
|
) {
|
||||||
|
blocks.push(expr.right.body);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
for (const block of blocks) {
|
||||||
|
let call = null;
|
||||||
|
for (const stmt of block.body) {
|
||||||
|
if (matchesStructure(stmt, logicalExpression)) {
|
||||||
|
if (
|
||||||
|
stmt.type === 'ExpressionStatement' &&
|
||||||
|
stmt.expression.type === 'LogicalExpression' &&
|
||||||
|
stmt.expression.right.type === 'SequenceExpression' &&
|
||||||
|
stmt.expression.right.expressions[0].type ===
|
||||||
|
'AssignmentExpression' &&
|
||||||
|
stmt.expression.right.expressions[0].right.type === 'CallExpression'
|
||||||
|
) {
|
||||||
|
call = stmt.expression.right.expressions[0].right;
|
||||||
|
}
|
||||||
|
} else if (stmt.type === 'IfStatement') {
|
||||||
|
let consequent = stmt.consequent;
|
||||||
|
while (consequent.type === 'LabeledStatement') {
|
||||||
|
consequent = consequent.body;
|
||||||
|
}
|
||||||
|
if (consequent.type !== 'BlockStatement') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const n of consequent.body) {
|
||||||
|
if (n.type !== 'VariableDeclaration') {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const decl of n.declarations) {
|
||||||
|
if (
|
||||||
|
matchesStructure(decl, nsigDeclarator) &&
|
||||||
_optionalChain$2([
|
_optionalChain$2([
|
||||||
decl,
|
decl,
|
||||||
'access',
|
'access',
|
||||||
(_3) => _3.init,
|
(_3) => _3.init,
|
||||||
'optionalAccess',
|
'optionalAccess',
|
||||||
(_4) => _4.params,
|
(_4) => _4.type,
|
||||||
'access',
|
]) === 'CallExpression'
|
||||||
(_5) => _5.length,
|
|
||||||
]) === 3
|
|
||||||
) {
|
) {
|
||||||
block = decl.init.body;
|
call = decl.init;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (node.type === 'FunctionDeclaration') {
|
if (call) {
|
||||||
block = node.body;
|
|
||||||
} else {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
const relevantExpression = _optionalChain$2([
|
|
||||||
block,
|
|
||||||
'optionalAccess',
|
|
||||||
(_6) => _6.body,
|
|
||||||
'access',
|
|
||||||
(_7) => _7.at,
|
|
||||||
'call',
|
|
||||||
(_8) => _8(-2),
|
|
||||||
]);
|
|
||||||
let call = null;
|
|
||||||
if (matchesStructure(relevantExpression, logicalExpression)) {
|
|
||||||
if (
|
|
||||||
_optionalChain$2([
|
|
||||||
relevantExpression,
|
|
||||||
'optionalAccess',
|
|
||||||
(_9) => _9.type,
|
|
||||||
]) !== 'ExpressionStatement' ||
|
|
||||||
relevantExpression.expression.type !== 'LogicalExpression' ||
|
|
||||||
relevantExpression.expression.right.type !== 'SequenceExpression' ||
|
|
||||||
relevantExpression.expression.right.expressions[0].type !==
|
|
||||||
'AssignmentExpression' ||
|
|
||||||
relevantExpression.expression.right.expressions[0].right.type !==
|
|
||||||
'CallExpression'
|
|
||||||
) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
call = relevantExpression.expression.right.expressions[0].right;
|
|
||||||
} else if (
|
|
||||||
_optionalChain$2([
|
|
||||||
relevantExpression,
|
|
||||||
'optionalAccess',
|
|
||||||
(_10) => _10.type,
|
|
||||||
]) === 'IfStatement' &&
|
|
||||||
relevantExpression.consequent.type === 'BlockStatement'
|
|
||||||
) {
|
|
||||||
for (const n of relevantExpression.consequent.body) {
|
|
||||||
if (!matchesStructure(n, nsigExpression)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
if (
|
|
||||||
n.type !== 'VariableDeclaration' ||
|
|
||||||
_optionalChain$2([
|
|
||||||
n,
|
|
||||||
'access',
|
|
||||||
(_11) => _11.declarations,
|
|
||||||
'access',
|
|
||||||
(_12) => _12[0],
|
|
||||||
'access',
|
|
||||||
(_13) => _13.init,
|
|
||||||
'optionalAccess',
|
|
||||||
(_14) => _14.type,
|
|
||||||
]) !== 'CallExpression'
|
|
||||||
) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
call = n.declarations[0].init;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (call === null) {
|
} else if (stmt.type === 'ExpressionStatement') {
|
||||||
return null;
|
if (
|
||||||
|
stmt.expression.type !== 'LogicalExpression' ||
|
||||||
|
stmt.expression.operator !== '&&' ||
|
||||||
|
stmt.expression.right.type !== 'SequenceExpression'
|
||||||
|
) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
for (const expr of stmt.expression.right.expressions) {
|
||||||
|
if (matchesStructure(expr, nsigAssignment) && expr.type) {
|
||||||
|
if (
|
||||||
|
expr.type === 'AssignmentExpression' &&
|
||||||
|
expr.right.type === 'CallExpression'
|
||||||
|
) {
|
||||||
|
call = expr.right;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (call) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!call) {
|
||||||
|
continue;
|
||||||
}
|
}
|
||||||
return {
|
return {
|
||||||
type: 'ArrowFunctionExpression',
|
type: 'ArrowFunctionExpression',
|
||||||
params: [{ type: 'Identifier', name: 'sig' }],
|
params: [{ type: 'Identifier', name: 'sig' }],
|
||||||
body: {
|
body: {
|
||||||
type: 'CallExpression',
|
type: 'CallExpression',
|
||||||
callee: { type: 'Identifier', name: call.callee.name },
|
callee: call.callee,
|
||||||
arguments:
|
arguments: call.arguments.map((arg) => {
|
||||||
call.arguments.length === 1
|
if (
|
||||||
? [{ type: 'Identifier', name: 'sig' }]
|
arg.type === 'CallExpression' &&
|
||||||
: [call.arguments[0], { type: 'Identifier', name: 'sig' }],
|
arg.callee.type === 'Identifier' &&
|
||||||
|
arg.callee.name === 'decodeURIComponent'
|
||||||
|
) {
|
||||||
|
return { type: 'Identifier', name: 'sig' };
|
||||||
|
}
|
||||||
|
return arg;
|
||||||
|
}),
|
||||||
optional: false,
|
optional: false,
|
||||||
},
|
},
|
||||||
async: false,
|
async: false,
|
||||||
@@ -276,6 +316,8 @@ var jsc = (function (meriyah, astring) {
|
|||||||
generator: false,
|
generator: false,
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
function _optionalChain$1(ops) {
|
function _optionalChain$1(ops) {
|
||||||
let lastAccessLHS = undefined;
|
let lastAccessLHS = undefined;
|
||||||
let value = ops[0];
|
let value = ops[0];
|
||||||
@@ -472,8 +514,31 @@ var jsc = (function (meriyah, astring) {
|
|||||||
return value;
|
return value;
|
||||||
}
|
}
|
||||||
function preprocessPlayer(data) {
|
function preprocessPlayer(data) {
|
||||||
const ast = meriyah.parse(data);
|
const program = meriyah.parse(data);
|
||||||
const body = ast.body;
|
const plainStatements = modifyPlayer(program);
|
||||||
|
const solutions = getSolutions(plainStatements);
|
||||||
|
for (const [name, options] of Object.entries(solutions)) {
|
||||||
|
plainStatements.push({
|
||||||
|
type: 'ExpressionStatement',
|
||||||
|
expression: {
|
||||||
|
type: 'AssignmentExpression',
|
||||||
|
operator: '=',
|
||||||
|
left: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
computed: false,
|
||||||
|
object: { type: 'Identifier', name: '_result' },
|
||||||
|
property: { type: 'Identifier', name: name },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
right: multiTry(options),
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}
|
||||||
|
program.body.splice(0, 0, ...setupNodes);
|
||||||
|
return astring.generate(program);
|
||||||
|
}
|
||||||
|
function modifyPlayer(program) {
|
||||||
|
const body = program.body;
|
||||||
const block = (() => {
|
const block = (() => {
|
||||||
switch (body.length) {
|
switch (body.length) {
|
||||||
case 1: {
|
case 1: {
|
||||||
@@ -506,16 +571,7 @@ var jsc = (function (meriyah, astring) {
|
|||||||
}
|
}
|
||||||
throw 'unexpected structure';
|
throw 'unexpected structure';
|
||||||
})();
|
})();
|
||||||
const found = { n: [], sig: [] };
|
block.body = block.body.filter((node) => {
|
||||||
const plainExpressions = block.body.filter((node) => {
|
|
||||||
const n = extract(node);
|
|
||||||
if (n) {
|
|
||||||
found.n.push(n);
|
|
||||||
}
|
|
||||||
const sig = extract$1(node);
|
|
||||||
if (sig) {
|
|
||||||
found.sig.push(sig);
|
|
||||||
}
|
|
||||||
if (node.type === 'ExpressionStatement') {
|
if (node.type === 'ExpressionStatement') {
|
||||||
if (node.expression.type === 'AssignmentExpression') {
|
if (node.expression.type === 'AssignmentExpression') {
|
||||||
return true;
|
return true;
|
||||||
@@ -524,41 +580,241 @@ var jsc = (function (meriyah, astring) {
|
|||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
});
|
});
|
||||||
block.body = plainExpressions;
|
return block.body;
|
||||||
for (const [name, options] of Object.entries(found)) {
|
|
||||||
const unique = new Set(options.map((x) => JSON.stringify(x)));
|
|
||||||
if (unique.size !== 1) {
|
|
||||||
const message = `found ${unique.size} ${name} function possibilities`;
|
|
||||||
throw (
|
|
||||||
message +
|
|
||||||
(unique.size
|
|
||||||
? `: ${options.map((x) => astring.generate(x)).join(', ')}`
|
|
||||||
: '')
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
plainExpressions.push({
|
function getSolutions(statements) {
|
||||||
type: 'ExpressionStatement',
|
const found = { n: [], sig: [] };
|
||||||
expression: {
|
for (const statement of statements) {
|
||||||
type: 'AssignmentExpression',
|
const n = extract(statement);
|
||||||
operator: '=',
|
if (n) {
|
||||||
left: {
|
found.n.push(n);
|
||||||
type: 'MemberExpression',
|
|
||||||
computed: false,
|
|
||||||
object: { type: 'Identifier', name: '_result' },
|
|
||||||
property: { type: 'Identifier', name: name },
|
|
||||||
},
|
|
||||||
right: options[0],
|
|
||||||
},
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
ast.body.splice(0, 0, ...setupNodes);
|
const sig = extract$1(statement);
|
||||||
return astring.generate(ast);
|
if (sig) {
|
||||||
|
found.sig.push(sig);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return found;
|
||||||
}
|
}
|
||||||
function getFromPrepared(code) {
|
function getFromPrepared(code) {
|
||||||
const resultObj = { n: null, sig: null };
|
const resultObj = { n: null, sig: null };
|
||||||
Function('_result', code)(resultObj);
|
Function('_result', code)(resultObj);
|
||||||
return resultObj;
|
return resultObj;
|
||||||
}
|
}
|
||||||
|
function multiTry(generators) {
|
||||||
|
return {
|
||||||
|
type: 'ArrowFunctionExpression',
|
||||||
|
params: [{ type: 'Identifier', name: '_input' }],
|
||||||
|
body: {
|
||||||
|
type: 'BlockStatement',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'VariableDeclaration',
|
||||||
|
kind: 'const',
|
||||||
|
declarations: [
|
||||||
|
{
|
||||||
|
type: 'VariableDeclarator',
|
||||||
|
id: { type: 'Identifier', name: '_results' },
|
||||||
|
init: {
|
||||||
|
type: 'NewExpression',
|
||||||
|
callee: { type: 'Identifier', name: 'Set' },
|
||||||
|
arguments: [],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'ForOfStatement',
|
||||||
|
left: {
|
||||||
|
type: 'VariableDeclaration',
|
||||||
|
kind: 'const',
|
||||||
|
declarations: [
|
||||||
|
{
|
||||||
|
type: 'VariableDeclarator',
|
||||||
|
id: { type: 'Identifier', name: '_generator' },
|
||||||
|
init: null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
right: { type: 'ArrayExpression', elements: generators },
|
||||||
|
body: {
|
||||||
|
type: 'BlockStatement',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'TryStatement',
|
||||||
|
block: {
|
||||||
|
type: 'BlockStatement',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'ExpressionStatement',
|
||||||
|
expression: {
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: { type: 'Identifier', name: '_results' },
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'add' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
arguments: [
|
||||||
|
{
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'Identifier',
|
||||||
|
name: '_generator',
|
||||||
|
},
|
||||||
|
arguments: [
|
||||||
|
{ type: 'Identifier', name: '_input' },
|
||||||
|
],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
handler: {
|
||||||
|
type: 'CatchClause',
|
||||||
|
param: null,
|
||||||
|
body: { type: 'BlockStatement', body: [] },
|
||||||
|
},
|
||||||
|
finalizer: null,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
await: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'IfStatement',
|
||||||
|
test: {
|
||||||
|
type: 'UnaryExpression',
|
||||||
|
operator: '!',
|
||||||
|
argument: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: { type: 'Identifier', name: '_results' },
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'size' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
prefix: true,
|
||||||
|
},
|
||||||
|
consequent: {
|
||||||
|
type: 'BlockStatement',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'ThrowStatement',
|
||||||
|
argument: {
|
||||||
|
type: 'TemplateLiteral',
|
||||||
|
expressions: [],
|
||||||
|
quasis: [
|
||||||
|
{
|
||||||
|
type: 'TemplateElement',
|
||||||
|
value: { cooked: 'no solutions', raw: 'no solutions' },
|
||||||
|
tail: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternate: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'IfStatement',
|
||||||
|
test: {
|
||||||
|
type: 'BinaryExpression',
|
||||||
|
left: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: { type: 'Identifier', name: '_results' },
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'size' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
right: { type: 'Literal', value: 1 },
|
||||||
|
operator: '!==',
|
||||||
|
},
|
||||||
|
consequent: {
|
||||||
|
type: 'BlockStatement',
|
||||||
|
body: [
|
||||||
|
{
|
||||||
|
type: 'ThrowStatement',
|
||||||
|
argument: {
|
||||||
|
type: 'TemplateLiteral',
|
||||||
|
expressions: [
|
||||||
|
{
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: { type: 'Identifier', name: '_results' },
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'join' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
arguments: [{ type: 'Literal', value: ', ' }],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
quasis: [
|
||||||
|
{
|
||||||
|
type: 'TemplateElement',
|
||||||
|
value: {
|
||||||
|
cooked: 'invalid solutions: ',
|
||||||
|
raw: 'invalid solutions: ',
|
||||||
|
},
|
||||||
|
tail: false,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'TemplateElement',
|
||||||
|
value: { cooked: '', raw: '' },
|
||||||
|
tail: true,
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
alternate: null,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
type: 'ReturnStatement',
|
||||||
|
argument: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: {
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: {
|
||||||
|
type: 'CallExpression',
|
||||||
|
callee: {
|
||||||
|
type: 'MemberExpression',
|
||||||
|
object: { type: 'Identifier', name: '_results' },
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'values' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
arguments: [],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'next' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
arguments: [],
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
computed: false,
|
||||||
|
property: { type: 'Identifier', name: 'value' },
|
||||||
|
optional: false,
|
||||||
|
},
|
||||||
|
},
|
||||||
|
],
|
||||||
|
},
|
||||||
|
async: false,
|
||||||
|
expression: false,
|
||||||
|
generator: false,
|
||||||
|
};
|
||||||
|
}
|
||||||
function main(input) {
|
function main(input) {
|
||||||
const preprocessedPlayer =
|
const preprocessedPlayer =
|
||||||
input.type === 'player'
|
input.type === 'player'
|
||||||
|
|||||||
Reference in New Issue
Block a user