Toggle Location Services on/off: Script Code

I’m trying to use the new Shortcuts app to create a workflow for easily toggling location services on / off (via Action extension and/or Siri).

It seems like I need to use Scriptable in order to complete this shortcut. I have only basic knowledge of JavaScript so any help with the code needed to create the Scriptable script will be appreciated.

I’ve pasted in code I think might be relevant but I’m a lil out of my league on getting a script to execute (image attached)

Or if there is an easier way to achieve this action please enlighten me thanks in a Vance for any help

Where did you find, or how did you come up, with that code?

I don’t think Scriptable has permission to change your location services status, so I’m highly doubtful this can work with Scriptable (or any other app, actually), but if you have the source for that code there might be something there that I’ve missed. (Like what “driver” is referencing.)

This might be the source:

(But I don’t think you can use this in Scriptable, JSBox, or Shortcuts)