|
1 | 1 | // ============================================================================= |
2 | | -// YouTube N-Parameter Solver — Remote Module v4 -> v6 |
| 2 | +// YouTube N-Parameter Solver — Remote Module v4 -> v7 |
3 | 3 | // Hosted at: https://github.com/solarizeddev/firedown-solver |
4 | 4 | // The background.js shell fetches, caches, and executes this module. |
5 | 5 | // |
6 | 6 | // v6 additions: preprocessCipher() for signature cipher detection on base.js |
7 | 7 | // The cipher function is obfuscated with the same string table + XOR pattern |
8 | 8 | // as the n-param function, but lives in the 'main' player variant (base.js) |
9 | 9 | // rather than the TV variant. |
| 10 | +// |
| 11 | +// v7 additions: preprocessPlayer() now supports base.js (main player variant) |
| 12 | +// The TV player no longer contains the n-param challenge function as of |
| 13 | +// player version ace4b2f8 (March 2026). findStringTable search window |
| 14 | +// increased to 5000 chars and 'use strict' fallback added to preprocessPlayer |
| 15 | +// to handle base.js copyright header offset. |
10 | 16 | // ============================================================================= |
11 | | -var SOLVER_VERSION = 6; |
| 17 | +var SOLVER_VERSION = 7; |
12 | 18 |
|
13 | 19 | var SETUP_CODE = [ |
14 | 20 | 'if(typeof globalThis.XMLHttpRequest==="undefined"){globalThis.XMLHttpRequest={prototype:{}};}', |
@@ -38,7 +44,7 @@ var SETUP_CODE = [ |
38 | 44 | * Handles: "...".split(";"), '...'.split("}"), ["...","..."] |
39 | 45 | */ |
40 | 46 | function findStringTable(data) { |
41 | | - var chunk = data.substring(0, 2000); |
| 47 | + var chunk = data.substring(0, 5000); |
42 | 48 | var splitCalls = chunk.matchAll(/\.split\((['"])(.)(\1)\)/g); |
43 | 49 | for (var sc of splitCalls) { |
44 | 50 | var delimiter = sc[2], splitPos = sc.index; |
@@ -73,7 +79,7 @@ function findStringTable(data) { |
73 | 79 | * Returns array of { funcName, bases: number[] } |
74 | 80 | */ |
75 | 81 | function findCandidates(data, tableVar, splitIdx) { |
76 | | - var earlyChunk = data.substring(0, Math.min(data.length, 30000)); |
| 82 | + var earlyChunk = data.substring(0, Math.min(data.length, 60000)); |
77 | 83 | var funcDefs = earlyChunk.matchAll(/(?:^|[^a-zA-Z0-9_$])(?:var\s+)?(\w+)=function\((\w+(?:,\w+){2,})\)\{/g); |
78 | 84 | var candidates = []; |
79 | 85 | for (var fd of funcDefs) { |
@@ -201,6 +207,14 @@ function preprocessPlayer(data, solvedCache) { |
201 | 207 | probeBody = buildCachedProbe(solvedCache.funcName, solvedCache.r, solvedCache.p); |
202 | 208 | } else { |
203 | 209 | var table = findStringTable(data); |
| 210 | + // base.js has its string table after copyright comments (~3KB in), |
| 211 | + // so try findStringTable on the source starting from 'use strict' |
| 212 | + if (!table) { |
| 213 | + var usIdx = data.indexOf("'use strict';"); |
| 214 | + if (usIdx > 0 && usIdx < 10000) { |
| 215 | + table = findStringTable(data.substring(usIdx)); |
| 216 | + } |
| 217 | + } |
204 | 218 | if (table) { |
205 | 219 | candidates = findCandidates(data, table.tableVar, table.splitIdx); |
206 | 220 | if (candidates.length > 0) { |
|
0 commit comments