Before

…lines 1–4 unchanged (4 lines)
5import { app, type BrowserWindow, dialog, ipcMain } from 'electron';
6import {
7 Innertube,
8 UniversalCache,
9 Utils,
10 YTNodes,
11} from '\u0079\u006f\u0075\u0074\u0075\u0062\u0065i.js';
12import is from 'electron-is';
13import filenamify from 'filenamify';
14import { Mutex } from 'async-mutex';
15import * as NodeID3 from 'node-id3';
16import { BG, type BgConfig } from 'bgutils-js';
17import { lazy } from 'lazy-var';
…lines 18–52 unchanged (35 lines)
53 log: false,
54 logger() {}, // Console.log,
55 progress() {}, // Console.log,
56 }),
57);
58const ffmpegMutex = new Mutex();
59
60let yt: Innertube;
61let win: BrowserWindow;
62let playingUrl: string;
63
64const isPremium = async () => {
65 // If signed out, it is understood as non-premium
…lines 66–127 unchanged (62 lines)
128}: BackendContext<DownloaderPluginConfig>) => {
129 win = _win;
130 config = await getConfig();
131
132 yt = await Innertube.create({
133 cache: new UniversalCache(false),
134 player_id: '0004de42',
135 cookie: await getCookieFromWindow(win),
136 generate_session_locally: true,
137 fetch: getNetFetchAsFetch(),
138 });
139
140 const requestKey = 'O43z0dpjhgX20SCx4KAo';
…lines 141–862 unchanged (722 lines)

After

…lines 1–4 unchanged (4 lines)
5import { app, type BrowserWindow, dialog, ipcMain } from 'electron';
6import {
7 Innertube,
8 UniversalCache,
9 Utils,
10 YTNodes,
11 Platform,
12} from '\u0079\u006f\u0075\u0074\u0075\u0062\u0065i.js';
13import is from 'electron-is';
14import filenamify from 'filenamify';
15import { Mutex } from 'async-mutex';
16import * as NodeID3 from 'node-id3';
17import { BG, type BgConfig } from 'bgutils-js';
…lines 18–54 unchanged (37 lines)
55 logger() {}, // Console.log,
56 progress() {}, // Console.log,
57 }),
58);
59const ffmpegMutex = new Mutex();
60
61Platform.shim.eval = async (data: Types.BuildScriptResult, env: Record<string, Types.VMPrimative>) => {
62 const properties = [];
63
64 if(env.n) {
65 properties.push(`n: exportedVars.nFunction("${env.n}")`)
66 }
67
68 if (env.sig) {
69 properties.push(`sig: exportedVars.sigFunction("${env.sig}")`)
70 }
71
72 const code = `${data.output}\nreturn { ${properties.join(', ')} }`;
73
74 return new Function(code)();
75}
76
77let yt: Innertube;
78let win: BrowserWindow;
79let playingUrl: string;
80
81const isPremium = async () => {
…lines 82–144 unchanged (63 lines)
145}: BackendContext<DownloaderPluginConfig>) => {
146 win = _win;
147 config = await getConfig();
148
149 yt = await Innertube.create({
150 cache: new UniversalCache(false),
151 cookie: await getCookieFromWindow(win),
152 generate_session_locally: true,
153 fetch: getNetFetchAsFetch(),
154 });
155
156 const requestKey = 'O43z0dpjhgX20SCx4KAo';
157 const visitorData = yt.session.context.client.visitorData;
…lines 158–878 unchanged (721 lines)

Before

program
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "existsSync"
, ","
import_specifier
identifier "mkdirSync"
, ","
import_specifier
identifier "writeFileSync"
} "}"
from "from"
string
' "'"
string_fragment "node:fs"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "join"
} "}"
from "from"
string
' "'"
string_fragment "node:path"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "randomBytes"
} "}"
from "from"
string
' "'"
string_fragment "node:crypto"
' "'"
; ";"
import_statement (+24 nodes collapsed)
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "Innertube"
, ","
import_specifier
identifier "UniversalCache"
, ","
import_specifier
identifier "Utils"
, ","
import_specifier
identifier "YTNodes"
, ","
} "}"
from "from"
string
' "'"
escape_sequence "\\u0079"
escape_sequence "\\u006f"
escape_sequence "\\u0075"
escape_sequence "\\u0074"
escape_sequence "\\u0075"
escape_sequence "\\u0062"
escape_sequence "\\u0065"
string_fragment "i.js"
' "'"
; ";"
import_statement
import "import"
import_clause
identifier "is"
from "from"
string
' "'"
string_fragment "electron-is"
' "'"
; ";"
import_statement
import "import"
import_clause
identifier "filenamify"
from "from"
string
' "'"
string_fragment "filenamify"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "Mutex"
} "}"
from "from"
string
' "'"
string_fragment "async-mutex"
' "'"
; ";"
import_statement
import "import"
import_clause
namespace_import
* "*"
as "as"
identifier "NodeID3"
from "from"
string
' "'"
string_fragment "node-id3"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "BG"
, ","
import_specifier
type "type"
identifier "BgConfig"
} "}"
from "from"
string
' "'"
string_fragment "bgutils-js"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "lazy"
} "}"
from "from"
string
' "'"
string_fragment "lazy-var"
' "'"
; ";"
import_statement (+26 nodes collapsed)
import_statement (+31 nodes collapsed)
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "getNetFetchAsFetch"
} "}"
from "from"
string
' "'"
string_fragment "@/plugins/utils/main"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "t"
} "}"
from "from"
string
' "'"
string_fragment "@/i18n"
' "'"
; ";"
import_statement (+21 nodes collapsed)
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "DownloaderPluginConfig"
} "}"
from "from"
string
' "'"
string_fragment "../index"
' "'"
; ";"
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "BackendContext"
} "}"
from "from"
string
' "'"
string_fragment "@/types/contexts"
' "'"
; ";"
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "GetPlayerResponse"
} "}"
from "from"
string
' "'"
string_fragment "@/types/get-player-response"
' "'"
; ";"
import_statement (+23 nodes collapsed)
import_statement (+30 nodes collapsed)
import_statement (+23 nodes collapsed)
import_statement (+27 nodes collapsed)
type_alias_declaration
type "type"
type_identifier "CustomSongInfo"
= "="
intersection_type
type_identifier "SongInfo"
& "&"
object_type
{ "{"
property_signature
property_identifier "trackId"
? "?"
type_annotation
: ":"
predefined_type
string "string"
} "}"
; ";"
lexical_declaration (+68 nodes collapsed)
lexical_declaration
const "const"
variable_declarator
identifier "ffmpegMutex"
= "="
new_expression
new "new"
identifier "Mutex"
arguments
( "("
) ")"
; ";"
lexical_declaration
let "let"
variable_declarator
identifier "yt"
type_annotation
: ":"
type_identifier "Innertube"
; ";"
lexical_declaration
let "let"
variable_declarator
identifier "win"
type_annotation
: ":"
type_identifier "BrowserWindow"
; ";"
lexical_declaration
let "let"
variable_declarator
identifier "playingUrl"
type_annotation
: ":"
predefined_type
string "string"
; ";"
lexical_declaration (+168 nodes collapsed)
lexical_declaration (+251 nodes collapsed)
export_statement (+107 nodes collapsed)
lexical_declaration
let "let"
variable_declarator
identifier "config"
type_annotation
: ":"
type_identifier "DownloaderPluginConfig"
; ";"
export_statement
export "export"
lexical_declaration
const "const"
variable_declarator
identifier "onMainLoad"
= "="
arrow_function
async "async"
formal_parameters (+24 nodes collapsed)
=> "=>"
statement_block
{ "{"
expression_statement
assignment_expression
identifier "win"
= "="
identifier "_win"
; ";"
expression_statement
assignment_expression
identifier "config"
= "="
await_expression
await "await"
call_expression
identifier "getConfig"
arguments
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "yt"
= "="
await_expression
await "await"
call_expression
member_expression
identifier "Innertube"
. "."
property_identifier "create"
arguments
( "("
object
{ "{"
pair
property_identifier "cache"
: ":"
new_expression
new "new"
identifier "UniversalCache"
arguments
( "("
false "false"
) ")"
, ","
pair
property_identifier "player_id"
: ":"
string
' "'"
string_fragment "0004de42"
' "'"
, ","
pair
property_identifier "cookie"
: ":"
await_expression
await "await"
call_expression
identifier "getCookieFromWindow"
arguments
( "("
identifier "win"
) ")"
, ","
pair
property_identifier "generate_session_locally"
: ":"
true "true"
, ","
pair
property_identifier "fetch"
: ":"
call_expression
identifier "getNetFetchAsFetch"
arguments
( "("
) ")"
, ","
} "}"
) ")"
; ";"
lexical_declaration
const "const"
variable_declarator
identifier "requestKey"
= "="
string
' "'"
string_fragment "O43z0dpjhgX20SCx4KAo"
' "'"
; ";"
lexical_declaration
const "const"
variable_declarator
identifier "visitorData"
= "="
member_expression
member_expression
member_expression
member_expression
identifier "yt"
. "."
property_identifier "session"
. "."
property_identifier "context"
. "."
property_identifier "client"
. "."
property_identifier "visitorData"
; ";"
if_statement (+339 nodes collapsed)
expression_statement (+32 nodes collapsed)
expression_statement (+43 nodes collapsed)
expression_statement (+34 nodes collapsed)
expression_statement
call_expression
identifier "downloadSongOnFinishSetup"
arguments
( "("
object
{ "{"
shorthand_property_identifier "ipc"
, ","
shorthand_property_identifier "getConfig"
} "}"
) ")"
; ";"
} "}"
; ";"
export_statement (+27 nodes collapsed)
export_statement (+148 nodes collapsed)
export_statement (+148 nodes collapsed)
function_declaration (+413 nodes collapsed)
function_declaration (+1277 nodes collapsed)
function_declaration (+205 nodes collapsed)
function_declaration (+550 nodes collapsed)
lexical_declaration (+68 nodes collapsed)
function_declaration (+304 nodes collapsed)
export_statement (+1377 nodes collapsed)
function_declaration (+177 nodes collapsed)
comment "// Playlist radio modifier needs to be cut from playlist ID"
lexical_declaration
const "const"
variable_declarator
identifier "INVALID_PLAYLIST_MODIFIER"
= "="
string
' "'"
string_fragment "RDAMPL"
' "'"
; ";"
lexical_declaration (+109 nodes collapsed)
lexical_declaration (+55 nodes collapsed)
lexical_declaration (+187 nodes collapsed)
comment "// This is used to bypass age restrictions"
lexical_declaration (+57 nodes collapsed)

After

program
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "existsSync"
, ","
import_specifier
identifier "mkdirSync"
, ","
import_specifier
identifier "writeFileSync"
} "}"
from "from"
string
' "'"
string_fragment "node:fs"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "join"
} "}"
from "from"
string
' "'"
string_fragment "node:path"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "randomBytes"
} "}"
from "from"
string
' "'"
string_fragment "node:crypto"
' "'"
; ";"
import_statement (+24 nodes collapsed)
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "Innertube"
, ","
import_specifier
identifier "UniversalCache"
, ","
import_specifier
identifier "Utils"
, ","
import_specifier
identifier "YTNodes"
, ","
import_specifier
identifier "Platform"
, ","
} "}"
from "from"
string
' "'"
escape_sequence "\\u0079"
escape_sequence "\\u006f"
escape_sequence "\\u0075"
escape_sequence "\\u0074"
escape_sequence "\\u0075"
escape_sequence "\\u0062"
escape_sequence "\\u0065"
string_fragment "i.js"
' "'"
; ";"
import_statement
import "import"
import_clause
identifier "is"
from "from"
string
' "'"
string_fragment "electron-is"
' "'"
; ";"
import_statement
import "import"
import_clause
identifier "filenamify"
from "from"
string
' "'"
string_fragment "filenamify"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "Mutex"
} "}"
from "from"
string
' "'"
string_fragment "async-mutex"
' "'"
; ";"
import_statement
import "import"
import_clause
namespace_import
* "*"
as "as"
identifier "NodeID3"
from "from"
string
' "'"
string_fragment "node-id3"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "BG"
, ","
import_specifier
type "type"
identifier "BgConfig"
} "}"
from "from"
string
' "'"
string_fragment "bgutils-js"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "lazy"
} "}"
from "from"
string
' "'"
string_fragment "lazy-var"
' "'"
; ";"
import_statement (+26 nodes collapsed)
import_statement (+31 nodes collapsed)
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "getNetFetchAsFetch"
} "}"
from "from"
string
' "'"
string_fragment "@/plugins/utils/main"
' "'"
; ";"
import_statement
import "import"
import_clause
named_imports
{ "{"
import_specifier
identifier "t"
} "}"
from "from"
string
' "'"
string_fragment "@/i18n"
' "'"
; ";"
import_statement (+21 nodes collapsed)
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "DownloaderPluginConfig"
} "}"
from "from"
string
' "'"
string_fragment "../index"
' "'"
; ";"
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "BackendContext"
} "}"
from "from"
string
' "'"
string_fragment "@/types/contexts"
' "'"
; ";"
import_statement
import "import"
type "type"
import_clause
named_imports
{ "{"
import_specifier
identifier "GetPlayerResponse"
} "}"
from "from"
string
' "'"
string_fragment "@/types/get-player-response"
' "'"
; ";"
import_statement (+23 nodes collapsed)
import_statement (+30 nodes collapsed)
import_statement (+23 nodes collapsed)
import_statement (+27 nodes collapsed)
type_alias_declaration
type "type"
type_identifier "CustomSongInfo"
= "="
intersection_type
type_identifier "SongInfo"
& "&"
object_type
{ "{"
property_signature
property_identifier "trackId"
? "?"
type_annotation
: ":"
predefined_type
string "string"
} "}"
; ";"
lexical_declaration (+68 nodes collapsed)
lexical_declaration
const "const"
variable_declarator
identifier "ffmpegMutex"
= "="
new_expression
new "new"
identifier "Mutex"
arguments
( "("
) ")"
; ";"
expression_statement
assignment_expression
member_expression
member_expression
identifier "Platform"
. "."
property_identifier "shim"
. "."
property_identifier "eval"
= "="
arrow_function
async "async"
formal_parameters
( "("
required_parameter
identifier "data"
type_annotation
: ":"
nested_type_identifier
identifier "Types"
. "."
type_identifier "BuildScriptResult"
, ","
required_parameter
identifier "env"
type_annotation
: ":"
generic_type
type_identifier "Record"
type_arguments
< "<"
predefined_type
string "string"
, ","
nested_type_identifier
identifier "Types"
. "."
type_identifier "VMPrimative"
> ">"
) ")"
=> "=>"
statement_block
{ "{"
lexical_declaration
const "const"
variable_declarator
identifier "properties"
= "="
array
[ "["
] "]"
; ";"
if_statement
if "if"
parenthesized_expression
( "("
member_expression
identifier "env"
. "."
property_identifier "n"
) ")"
statement_block
{ "{"
expression_statement
call_expression
member_expression
identifier "properties"
. "."
property_identifier "push"
arguments
( "("
template_string
` "`"
string_fragment "n: exportedVars.nFunction(\""
template_substitution
${ "${"
member_expression
identifier "env"
. "."
property_identifier "n"
} "}"
string_fragment "\")"
` "`"
) ")"
} "}"
if_statement
if "if"
parenthesized_expression
( "("
member_expression
identifier "env"
. "."
property_identifier "sig"
) ")"
statement_block
{ "{"
expression_statement
call_expression
member_expression
identifier "properties"
. "."
property_identifier "push"
arguments
( "("
template_string
` "`"
string_fragment "sig: exportedVars.sigFunction(\""
template_substitution
${ "${"
member_expression
identifier "env"
. "."
property_identifier "sig"
} "}"
string_fragment "\")"
` "`"
) ")"
} "}"
lexical_declaration
const "const"
variable_declarator
identifier "code"
= "="
template_string
` "`"
template_substitution
${ "${"
member_expression
identifier "data"
. "."
property_identifier "output"
} "}"
escape_sequence "\\n"
string_fragment "return { "
template_substitution
${ "${"
call_expression
member_expression
identifier "properties"
. "."
property_identifier "join"
arguments
( "("
string
' "'"
string_fragment ", "
' "'"
) ")"
} "}"
string_fragment " }"
` "`"
; ";"
return_statement
return "return"
call_expression
new_expression
new "new"
identifier "Function"
arguments
( "("
identifier "code"
) ")"
arguments
( "("
) ")"
; ";"
} "}"
lexical_declaration
let "let"
variable_declarator
identifier "yt"
type_annotation
: ":"
type_identifier "Innertube"
; ";"
lexical_declaration
let "let"
variable_declarator
identifier "win"
type_annotation
: ":"
type_identifier "BrowserWindow"
; ";"
lexical_declaration
let "let"
variable_declarator
identifier "playingUrl"
type_annotation
: ":"
predefined_type
string "string"
; ";"
lexical_declaration (+168 nodes collapsed)
lexical_declaration (+251 nodes collapsed)
export_statement (+107 nodes collapsed)
lexical_declaration
let "let"
variable_declarator
identifier "config"
type_annotation
: ":"
type_identifier "DownloaderPluginConfig"
; ";"
export_statement
export "export"
lexical_declaration
const "const"
variable_declarator
identifier "onMainLoad"
= "="
arrow_function
async "async"
formal_parameters (+24 nodes collapsed)
=> "=>"
statement_block
{ "{"
expression_statement
assignment_expression
identifier "win"
= "="
identifier "_win"
; ";"
expression_statement
assignment_expression
identifier "config"
= "="
await_expression
await "await"
call_expression
identifier "getConfig"
arguments
( "("
) ")"
; ";"
expression_statement
assignment_expression
identifier "yt"
= "="
await_expression
await "await"
call_expression
member_expression
identifier "Innertube"
. "."
property_identifier "create"
arguments
( "("
object
{ "{"
pair
property_identifier "cache"
: ":"
new_expression
new "new"
identifier "UniversalCache"
arguments
( "("
false "false"
) ")"
, ","
pair
property_identifier "cookie"
: ":"
await_expression
await "await"
call_expression
identifier "getCookieFromWindow"
arguments
( "("
identifier "win"
) ")"
, ","
pair
property_identifier "generate_session_locally"
: ":"
true "true"
, ","
pair
property_identifier "fetch"
: ":"
call_expression
identifier "getNetFetchAsFetch"
arguments
( "("
) ")"
, ","
} "}"
) ")"
; ";"
lexical_declaration
const "const"
variable_declarator
identifier "requestKey"
= "="
string
' "'"
string_fragment "O43z0dpjhgX20SCx4KAo"
' "'"
; ";"
lexical_declaration
const "const"
variable_declarator
identifier "visitorData"
= "="
member_expression
member_expression
member_expression
member_expression
identifier "yt"
. "."
property_identifier "session"
. "."
property_identifier "context"
. "."
property_identifier "client"
. "."
property_identifier "visitorData"
; ";"
if_statement (+339 nodes collapsed)
expression_statement (+32 nodes collapsed)
expression_statement (+43 nodes collapsed)
expression_statement (+34 nodes collapsed)
expression_statement
call_expression
identifier "downloadSongOnFinishSetup"
arguments
( "("
object
{ "{"
shorthand_property_identifier "ipc"
, ","
shorthand_property_identifier "getConfig"
} "}"
) ")"
; ";"
} "}"
; ";"
export_statement (+27 nodes collapsed)
export_statement (+148 nodes collapsed)
export_statement (+148 nodes collapsed)
function_declaration (+413 nodes collapsed)
function_declaration (+1277 nodes collapsed)
function_declaration (+205 nodes collapsed)
function_declaration (+550 nodes collapsed)
lexical_declaration (+68 nodes collapsed)
function_declaration (+304 nodes collapsed)
export_statement (+1377 nodes collapsed)
function_declaration (+177 nodes collapsed)
comment "// Playlist radio modifier needs to be cut from playlist ID"
lexical_declaration
const "const"
variable_declarator
identifier "INVALID_PLAYLIST_MODIFIER"
= "="
string
' "'"
string_fragment "RDAMPL"
' "'"
; ";"
lexical_declaration (+109 nodes collapsed)
lexical_declaration (+55 nodes collapsed)
lexical_declaration (+187 nodes collapsed)
comment "// This is used to bypass age restrictions"
lexical_declaration (+57 nodes collapsed)