Help with voice assistant made with JavaScript

//Note: Offline recognition engines can be downloaded in the
//Android Language and Input settings (recommended for speed).
//Higher quality voices may also be downloaded.

//Called when application is started.
function OnStart()
{
    //Create a main layout with objects vertically centered.
    lay = app.CreateLayout( "Linear", "VCenter,FillXY" );   
    lay.SetBackground( "/res/drawable/pattern_carbon", "repeat" );

    var s = "<u>Hello, I am Maria</u><br><br>"
        + "By Rehan<br>";
    txt = app.CreateText( s, 0.9, 0.8, "Multiline,Html" );
    txt.SetTextSize( 32 );
    txt.AdjustColor("#ff6398ff");
    lay.AddChild( txt );
  
    //Add layout to app.    
    app.AddLayout( lay );
    
    //Create recognition object and set callbacks.
	speech = app.CreateSpeechRec("NoBeep,Parxtial");
	speech.SetOnResult( speech_OnResult );
	speech.SetOnError( speech_OnError );
	
	//Say something at start (to get speech engine ready).
    app.TextToSpeech( "Your wish is my command, Master Rehan", 1, 1.15, Listen );
    app.ShowProgress( );
}

//Start recognizing.
function Listen()
{
    app.HideProgress();
	speech.Recognize();
}

//Called with the recognition result(s).
function speech_OnResult( results, partial )
{
    //Get result.
    var cmd = results[0].toLowerCase();
    
    //Watch for key phrases.
    if( cmd.indexOf("maria") > -1 )
    {
        //speech.Cancel();
        app.TextToSpeech( "Yes Lord Rehan?", 1,2, Listen );
    }
    else if( cmd.indexOf("what")>-1 && cmd.indexOf("time")>-1 )
    {
        //speech.Cancel();
        app.TextToSpeech( GetTime()+"", 1,1.15, Listen  );
    }
    else if( cmd.indexOf("what")>-1 && cmd.indexOf("day")>-1 )
    {
       // speech.Cancel();
        app.TextToSpeech( GetDay(), 1,1.15, Listen );
    }
    else if( cmd.indexOf("how")>-1 && cmd.indexOf("you")>-1 )
    {
        //speech.Cancel();
        app.TextToSpeech( "Feelin good", 1,1.15, Listen );
    }
    else if(cmd.indexOf("what")>-1&&cmd.indexOf("battery")>-1)
    {
        app.TextToSpeech(app.GetBatteryLevel()*100/100*100,1,1.15,Listen);
     }
    else if( cmd.indexOf("exit")>-1||cmd.indexOf("close")>-1 )
    {
       app.Exit();
    }
    
    //Restart recognition.
    else speech.Recognize();
}


//Called if recognition fails.
function speech_OnError( error )
{
    console.log( "Error" + error );
    
    //Restart recognition.
    if( !speech.IsListening() ) speech.Recognize();
}

//Get the current time.
function GetTime()
{
    var d = new Date();
    if(d.getHours()<12)
    return d.getHours() + " " + d.getMinutes()+"AM";
    else 
    return (d.getHours()-12)+" "+d.getMinutes()+"PM"
}

//Get the current day.
function GetDay()
{
    var d = new Date();
    var weekday = new Array(7);
    weekday[0]=  "Sunday";
    weekday[1] = "Monday";
    weekday[2] = "Tuesday";
    weekday[3] = "Wednesday";
    weekday[4] = "Thursday";
    weekday[5] = "Friday";
    weekday[6] = "Saturday";
    return weekday[d.getDay()];
}

So here, I want to open either a webpage that opens the YouTube homepage or opens the YouTube app when it hears the word, “YouTube”.
But… It doesn’t seem to work that way. How can I make it open either a YouTube page or the the app when it hears the word??
Please note that I am running this script on my android tablet on a app called DroidScript

I’ve edited your post for readability. When you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

See this post to find the backtick on your keyboard. The “preformatted text” tool in the editor (</>) will also add backticks around text.

Note: Backticks are not single quotes.

markdown_Forums