Default HELP with android script+ modify xml

Hello everyone, this is the only place where I could ever find help to my project.
I need to create a script that opens url that redirects to playstore,
example: the script will open the url that redirects to a specific game or app and then the app opens itself from playstore.
the app should open only if it is already installed, not if there is BUY option or free install option.
is it possible?? somebody could points me toward the open button option in the ps apk??