Javascript in Logic Pro

Hi. I found this script for adding a plugin to the first available channel slot in Logic Pro on the Soundflow forum. This is something I've seen a few people try to achieve without success... I'm wondering if it could be triggered by KM? I know less than nothing about scripting, so I'm hoping one of the local geniuses will know what's what...

const logic = sf.ui.app('com.apple.logic10'); const pluginPath = ['Audio Units', 'FabFilter', 'Pro-Q 3'];

function openInspector() {
    const inspectorBtn = logic.mainWindow.groups.whoseDescription.is('Control Bar').first.checkBoxes.whoseTitle.is('Inspector').first;

    if (!inspectorBtn.isCheckBoxChecked) {
        inspectorBtn.elementClick();
    }
}

function addInsertNextFreeSlot(pluginPath) {
    const inspector = logic.mainWindow.groups.whoseDescription.is('Inspector').first;

    inspector.childrenByRole("AXList").first.groups
        .filter(group => group.children.whoseDescription.is('Mixer').first.childrenByRole("AXLayoutItem").first.buttons.whoseDescription.is('audio plug-in').first.exists)
        .map(group => group.children.whoseDescription.is('Mixer').first.childrenByRole("AXLayoutItem").first.buttons.whoseDescription.is('audio plug-in').first.popupMenuSelect({
            menuPath: pluginPath,
        }));
}

function main() {
    logic.appActivateMainWindow();
    logic.mainWindow.invalidate();

    openInspector();

    addInsertNextFreeSlot(pluginPath);
}

main();

sf.keyboard.press({ keys: "right, return", });