JavaScript Embedding and Extraction in PDFs

I want to embed some JS code into a pdf that extracts the content of a line and auto runs on open.
I tested it out by just running app.alert and it worked on MSEdge.

What JS Modules/methods would I have to use to achieve this. Any answer helps

I have tried finding modules online and the ones I have found are all working from the outside, asking for file name. I am looking for JS code that I want to embed into my PDF that extracts the content of backend line 57 and runs app.alert(line 57)