Bitburner
Няма достатъчно оценки
How to get the window object without RAM cost
От implied
Here's a way to get the window object in NS2 scripts for free.
   
Награда
Добавяне към любими
В любими
Премахване от любими
The Goods
const funny_window = Function("return this")()

How in the hell..?
Pretty simple, to be honest. When you create a new function using the constructor, it runs under the window context. By returning 'this', you end up getting a reference to the window. This bypasses RAM requirements as (I presume) the RAM check only works with the main window reference. You can do this with any method on any object, too. Here's a more archaic version:
const funny_window = []["filter"]["constructor"]("return this")(); /* [] = empty array ["filter"] = instance of Array.filter ["constructor"] = get the constructor of the Function ("return this") = build a function to return the window () = run the new function */



If you found the guide useful, feel free to award and thumbs up this!
2 коментара
DandN 23 ноем. 2022 в 14:43 
const win = globalThis;
const doc = globalThis["document"];
implied  [автор] 9 ноем. 2022 в 18:57 
This may be patched at any time, so do be warned.