Hi Pratham,
I am not sure, how you can achieve this, but there's a workaround
you can add a dataview where your javascript snippet is, and put it's datasource as Nanoflow, in the nanoflow you can call a JS action.
Just create a JS action, that expects a string, and manipulate it however you want.
Now, in the nanoflow, JS will expect a string, you can pass the string in the JS action through parameter you will get from your parent dataview.
I hope this helps you find a solution.
Kindly accept the answer, if it helps! :)