Process data from external javascript file



I want to read the ink level from my printer and the only way (at least that I am aware of) is to access this data through http binding.
Unfortunately the ink level is not stored in any json or html webpage, where I could use json or xpath transformation profiles, but it is only stored in a javascript file (and there is some magic javascript that will display the ink level dynamically within the UI of the printer).

The output of the JS file is as following and I am wondering what is the best approach to process this data (e.g. should I use some eval function to actually access the variables, better use regex or something else)?

var inktank=[];
var g_cur_tank_num=5;
var inkCOL = ['InkMaz',  'InkBlk',  'InkYel',  'InkPbk',  'InkCia'];

How to read the vars:
The ink tank has 5 cartridges (magenta, black, yellow, pigment black & cyan) and the 2nd value in each inktank object is representing the fill level (magenta = 2, black = 1, yellow = 2, pigment black = 1, cyan = 2).

Thanks in advance for any tips and recommendations on whats the best approach to parse / process these information.

And where is that available to openHAB? It sounds like you are describing a webpage that produces the visible values from running a little javascript. If you use HTTP from openHAB to scrape that page, the little javascript will NOT be run. This I doubt will ever be allowed in OH, security risk.
What you might do is reverse engineer the script to see how it gets the original data.

The original data I want to get is hard coded within the js file.
Therefor I don’t want to scrap the full web page but I want to use http binding to scrap the javascript file only.

By this I will get the content of the javascript file as text to openhab and my question is what’s the best approach to further process the text and extract the relevant information. Is it only regex or is there something else that will suit better?

Probably. That part is only string manipulation.