I definitely don’t completely understand the code, but using Templater in conjunction with Dataview is surely possible, as evidenced here: Create list of links based on all open tabs
Perhaps someone will kindly point you in the right direction, or possibly completely solve your use case. I could see uses in my workflow for your request. Good luck!
Thanks.