Fortunately the web browsers have been created to protect the client environment from executing client processes and accessing client resources. However sometimes this limitation is too strong and does not let us to do some simple things like direct print a document without opening an intermediate print pop-up.
If you have a PC or are using macOS Mojave or earlier on your Mac, you can try this method to get back deleted text messages on your iPhone. However, if you have synced with this PC or Mac since deleting your text messages, this process will not work, as iTunes only saves your most recent backup data for a restore.