Issue with JavaScript window.open() and window.close() functions

I’m trying to use JavaScript to open and close a new window in my web application. The opening part works fine, but I’m having trouble closing the window using window.close().

Here’s my code:

let myWindow;
//select dom element
const width = document.getElementById('width');
const height = document.getElementById('height');

//show window object properties 
width.innerHTML = "Window inner with is: " + window.innerWidth;
height.innerHTML = "Window inner height is: " + window.innerHeight;

function openWindow() {
  myWindow = window.open('https://www.google.com')
}

function closeWindow() {
  myWindow.close();
}
<div>
  <input type="button" value="Open window" onclick="openWindow()" />
</div>
<div>
  <input type="button" value="close window" onclick="closeWindow()" />
</div>

Cypress Test Automation: Self-Healing for Frequent UI Changes?

Currently, the test automation framework heavily relies on UI element selectors (IDs, classes, etc.) to interact with the application. However, frequent UI changes often render these selectors invalid, leading to manual updates in the test scripts.

This manual intervention becomes a bottleneck, and I’m seeking solutions to improve the framework’s resilience to UI changes. Ideally, I’d like the framework to:

  • Identify when a selector becomes invalid during test execution.
  • Suggest alternative ways to locate the target element (potentially using new selectors).

I’m interested in incorporating Machine Learning (ML) to enhance the framework’s ability to suggest new locators when encountering unexpected UI changes.

  • I’m familiar with the concept of self-healing test automation frameworks but haven’t implemented one yet. So don’t know how can I achieve this?
  • I’m open to exploring different solutions, including those that might involve Machine Learning (ML).
  • Are there any other effective JS-based strategies for self-healing test automation in Cypress that I might be missing?
  • Is it practical to integrate a Python model for locator validation, or are there simpler JS-based alternatives?
  • If Python integration is a viable option, can you recommend resources or best practices for achieving this in a Cypress framework?

I appreciate any suggestions or insights on building a self-healing framework in Cypress that can adapt to UI changes and reduce manual maintenance of test scripts.

Title: How to output changed registers and ESP in red color after each `p` command in Windbg using JavaScript?

I’m trying to write a JavaScript script for Windbg that outputs the changed registers and ESP in red color after each p command. I want to achieve this by comparing the current register values with the previous ones and highlighting the differences.

Here’s what I have so far(with chatgpt):

"use strict";

let logln = function(e) {
  host.diagnostics.debugLog(e + 'n');
};

let prevRegs = {};
let prevEsp = null;

function handle_p() {
  let Regs = host.currentThread.Registers.User;
  let esp = Regs.esp.toString(16);

  let changedRegs = {};
  let changedEsp = false;

  // Check for changed registers
  for (let reg in Regs) {
    if (Regs.hasOwnProperty(reg)) {
      let regVal = Regs[reg].toString(16);
      if (!prevRegs[reg] || prevRegs[reg] !== regVal) {
        changedRegs[reg] = regVal;
      }
    }
  }

  // Check for changed ESP
  if (prevEsp === null || prevEsp !== esp) {
    changedEsp = true;
  }

  // Output changed registers and ESP
  if (Object.keys(changedRegs).length > 0) {
    logln("Changed registers:");
    for (let reg in changedRegs) {
      if (changedRegs.hasOwnProperty(reg)) {
        let regVal = changedRegs[reg];
        logln(reg + "=" + regVal);
      }
    }
  }

  if (changedEsp) {
    let espDump = host.currentThread.Registers.User.readMemoryValues(Regs.esp, 16);
    logln("Changed ESP: " + esp);
    logln(espDump.join(' '));
  }

  // Update prevRegs and prevEsp
  prevRegs = Object.assign({}, Regs);
  prevEsp = esp;
}

function invokeScript() {
  let Control = host.namespace.Debugger.Utility.Control;

  // Check if a breakpoint is already set
  let BreakpointAlreadySet = Control.ExecuteCommand('.printf "%mu", "p"').indexOf("p") !== -1;

  if (BreakpointAlreadySet === false) {
    let Bp = Control.SetBreakpointAtOffset("p", 0, "ntdll");
    Bp.Command = '.echo doare; dx @$scriptContents.handle_p(); gc';
  } else {
    logln('Breakpoint already set.');
  }

  logln('Press "g" to run the target.');
}

However, when I try to execute this script in Windbg, I encounter an error related to host.utilities.control. How can I fix this issue or achieve the desired functionality in a different way?

Any help would be greatly appreciated. Thanks in advance!

Within Dynamics 365 Online how to create records with related data from the UI

I Found a clear example of how to do it via the API: Link

But I cant seem to find any documentation or examples on using: Xrm.Page.data.entity.relatedEntities.add() to do the same thing.

I put together this based on the blog I found for doing this via the API.

Xrm.Page.data.entity.relatedEntities.add("contact_customer_accounts", 
[
    {
        "firstname": "John",
        "lastname": "Smith"
    }
])

whilst creating a new Account record, I open the Developer Console and paste the statement, it accepted my input, but then nothing happened after I clicked save.

Create declaration file for third party library as CJS

I am using a third party CJS library without types. My project is CJS with TypeScript. The importation works just fine (imports are transpiled to requires) if I disable errors using comments.

/* c8 ignore start */
// @ts-ignore
import * as func from "third-party-library";

const example = func();

I wanted to get rid of these comments and get some more accurate typing, so I created a .d.ts file for the library. It appears to be accurate thanks to this answer and my IDE / eslint no longer complains about unknown types or the use of any;

// third-party-library.d.ts
declare module "third-party-library" {
  function func(): string;
  export = func;
}

All good so far, except now I get the following error;

This module can only be referenced with ECMAScript imports/exports by turning on the ‘esModuleInterop’ flag and referencing its default export.ts(2497)

I have read that the ‘fix’ for this is to add the esModuleInterop flag in my tsconfig.json as described.

However, I don’t think this is the real fix because I am importing a CJS module into my pure CJS project. I shouldn’t need to do this.

As such, I believe that perhaps the declare in the library .d.ts is not quite accurate and the notation I am using is for ESM modules? Or perhaps I am importing incorrectly.

How can I resolve this without using esModuleInterop.

CKEditor setData() function not working everytime

I am using CKEditor 4 on a textarea filed in a page, when I open data i nedit form a grid in my page, I put the setData() function to set the content inside the textarea inside a on instanceReady event, but sometimes it doesn’t enter inside the instanceReady event function. This is my js code:

function prepCkEditor() {
  var oFCKeditor = CKEDITOR.instances.EMAIL_DESC_TEMPLATETextBox;
  if (!oFCKeditor) {
    CKEDITOR.replace('EMAIL_DESC_TEMPLATETextBox', {
        language: editorlang,
        toolbar: 'helpsi',
        skin: 'moono',
        scayt_autoStartup: CONFIGURAZIONE.enableSpellCheck,
        scayt_sLang: $('#hfUSER_LANGEXTENDED').val().replace('-', '_'),
        scayt_disableOptionsStorage: 'lang'
    });
  }
}

prepCkEditor();

var oFCKeditor = CKEDITOR.instances.EMAIL_DESC_TEMPLATETextBox;
if (oFCKeditor) {
   console.log(oFCKeditor.status);
   oFCKeditor.on('instanceReady', function () {
      oFCKeditor.setData(template.TemplateBody);
   });
}

The console.log statement put before the on instanceReady line prints ‘ready’ so it seems that the editor is fully loaded, but it doesn’t enter inside the function to set the data. What could it be the problem?

If I check in debug in the browser development tools, it wiorks but the status that prints is unloaded

Form Validation by Javascript in Laravel 10.x won’t work

I’m made a custom validation in Laravel 10.x blade using Javascript and Bootstrap 5 classes.
On press submit button the store action don’t work and the form is reloaded empty without putting data in database.

here the code of the javascript validation in the blade:

    <script> 
            function checkInput() 
                {
                var cognome = document.getElementById("cognome").value;
                var nome = document.getElementById("nome").value;
                var codFisc = document.getElementById("cod_fiscale").value;
                var area = document.getElementById("id_area").value;
                var check = 0;

                console.log("cognome: ", cognome);
                console.log("nome: ", nome);
                console.log("codFisc: ", codFisc);
                console.log("area: ", area);

                document.getElementById("cognome").classList.remove("is-invalid");
                document.getElementById("nome").classList.remove("is-invalid");
                document.getElementById("cod_fiscale").classList.remove("is-invalid");
                document.getElementById("id_area").classList.remove("is-invalid");  

                if (cognome == "")
                    {
                        document.getElementById("cognome").classList.add("is-invalid");
                        check = 1;
                    }

                if (nome == "")
                    {
                        document.getElementById("nome").classList.add("is-invalid");
                        check = 1;
                    }

                if (codFisc == "" || codFisc.length != 16)
                    {
                        document.getElementById("cod_fiscale").classList.add("is-invalid");
                        check = 1;
                    }        
                
                if (!id_area.value)
                    {
                        document.getElementById("id_area").classList.add("is-invalid");
                        check = 1;
                    }         

                console.log("check: ", check)    

                if (check == 0) 
                    {
                        document.getElementById("cognome").classList.remove("is-invalid");
                        document.getElementById("nome").classList.remove("is-invalid");
                        document.getElementById("cod_fiscale").classList.remove("is-invalid");
                        document.getElementById("id_area").classList.remove("is-invalid");                        
                        document.getElementById("formUtente").submit();
                    }
                }
    </script>

and the next is the code of the form inside the blade:

                    <form action="{{route('utenti.store')}}" method="post" name="formUtente" id="formUtente" role="form">
                    @csrf                     
                        <div class="form-group">
                            <label for="Cognome">Cognome</label>
                            <input type="text" class="form-control" id="cognome" name="cognome">
                            <div class="invalid-feedback">Il cognome non deve essere vuoto.</div>
                        </div>

                        <div class="form-group">
                            <label for="Nome">Nome</label>
                            <input type="text" class="form-control" id="nome" name="nome">
                            <div class="invalid-feedback">Il nome non deve essere vuoto.</div>
                        </div>

                        <div class="form-group">
                            <label for="Codice Fiscale">Codice Fiscale</label>
                            <input type="text" class="form-control" id="cod_fiscale" name="cod_fiscale">
                            <div class="invalid-feedback">Il codice fiscale non deve essere vuoto e deve essere lungo 16 caratteri.</div>
                        </div>

                        <div class="form-group">
                            <label for="Attivo">Attivo</label>
                            <select class="form-select" id="attivo" name="attivo">
                                <option value="1" selected>Si</option>
                                <option value="0">No</option>
                            </select>                                                        
                        </div>

                        <div class="form-group">
                            <label for="Area">Area</label>
                            <select class="form-select" id="id_area" name="id_area">
                                <option value="">Selezionare un'area...</option>                                                                        
                                    @foreach ($areas as $area)
                                        <option value="{{$area->id}}">{{$area->descrizione}}</option>
                                    @endforeach
                            </select>
                            <div class="invalid-feedback">Selezionare un'area dalla lista.</div>                            
                        </div>

                        <div class="form-group">
                            <label for="Cognome">Note</label>
                            <textarea rows=5 class="form-control" id="note" name="note"></textarea>
                        </div>

                        <br>
                        <button type="button" class="btn btn-primary" id="controlBTN" onclick="checkInput();">Inserisci nuovo utente</button>
                    </form>

I have tryed also with other JS submit methods but don’t work…
The problem is that the submit start but don’t go to controller for storage the data inside the database. The form works well without any validation on it.

Any suggestions?

Why custom multiselection element is not available after I selected item?

On laravel 10 site using docs at https://dev.to/koossaayy/laravel-livewire-multiple-selection-with-virtual-select-1f87 I try to make multiselection.
I made it with some changes in the code. In component :

<?php

namespace AppLivewireAdmin;

use AppModelsPermission;
use IlluminateSupportStr;
use LivewireComponent;

class UsersPermissionsEditor extends Component
{
    public $selectedPermissions= [];
    public $permissionsListing= [];

    public function render()
    {
        $this->permissionsListing = Permission::query()->get()/*->pluck('name', 'id')*/
            ->map(function ($selectedPermissionItem) {
                return ['id' => $selectedPermissionItem->id, 'label' => Str::replace('_', ' ', Str::title($selectedPermissionItem->name))];
            })
        ->toArray();
        return view('livewire.admin.users-permissions-editor');
    }
}

and in blade :

<div class="admin_page_container" id="users_permissions_editor_admin_page_container">
    <div class="editor_listing_wrapper_bix_width" x-data="adminUsersPermissionsEditorComponent()"
         x-init="[onAdminUsersPermissionsEditorComponentInit() ]" x-cloak>

        $selectedPermissions::{{ print_r($selectedPermissions, true) }}

        <input id="permissionsListing" name="permissionsListing" value="add permissionsListing TEST">
        <script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/virtual-select.min.js"
                integrity="sha256-Gsn2XyJGdUeHy0r4gaP1mJy1JkLiIWY6g6hJhV5UrIw=" crossorigin="anonymous"></script>

        <link rel="stylesheet"
              href="https://cdn.jsdelivr.net/npm/[email protected]/dist/virtual-select.min.css"
              integrity="sha256-KqTuc/vUgQsb5EMyyxWf62qYinMUXDpWELyNx+cCUr0=" crossorigin="anonymous">

        <div>
             AAAAA<div id="permissions"></div>BBB
            <script>

                function adminUsersPermissionsEditorComponent() {
                    console.log('adminUsersPermissionsEditorComponent::')

                    return {
                        fillUsersPermissions: function () {
                            var permissionsListing = @json($permissionsListing)

                                VirtualSelect.init({
                                    ele: '#permissions',
                                    multiple: true,
                                    options: permissionsListing,
                                });
                            let selectedPermissions = document.querySelector('#permissions');
                            selectedPermissions.addEventListener('change', () => {
                                let data = selectedPermissions.value;
                                @this.set('selectedPermissions', data);
                            });
                        },



                        onAdminUsersPermissionsEditorComponentInit: function () {
                        },


                    }
                }


            </script>

        </div>
    </div>

I see available multiselection element, but when I click on one of elements the multiselection element is not visible at all,

What I see in browsers console :

enter image description here

How that can be fixed ?

"laravel/framework": "^10.48.4",
"livewire/livewire": "^3.4.9",

Thanks in advance!

Ionic angular adyen integration

we have a ionic v1 angular cordova app for android and we are trying to integrate adyen https://docs.adyen.com/online-payments/build-your-integration/sessions-flow/?platform=Web&integration=Drop-in&version=5.60.0. However, I noticed they don’t have a out of the box support for cordova or any plugin.

What i tried

  • I tried integrating the web sdk in the anroid mobile app, however it did not workout i noticed app freeze.
  • I tried devloping a cordova android plugin, the examples looks too complex and i have limited knowledge in kotlin

What i expected

  • I expected a payment form by adyen, or in case of android plugin i expected an activity with payment form

Please point me as to what approach i can take.

Encoding issue – no results found due to special characters (Javascript & PHP)

I need help desperately…

I have this website: Horoskop Paradies. On this page I have a form that allows users to generate a horoscope on demand. In the form I have an input called, “Geburtsort”, which means “Place of birth”. When the user starts typing in the input, a list of suggested locations appear from a SQL database (that I own). It works most of the time, but not when the city name has special characters like “ü” etc. For example, “Cape Town” works, but not “Äbigrub”. I tried this on my local system using XAMPP and it works perfectly, but in production it does not. Try the live site for context, I also added some logs in the console.

Here is the relevant JS code:

placeOfBirthInput.addEventListener("input", async function () {
        const place = placeOfBirthInput.value;

        if (place) {
            const suggestions = await getLocationSuggestions(place);
            displaySuggestions(suggestions);
        } else {
            clearSuggestions();
        }
    });

    suggestionsDiv.addEventListener("click", function (event) {
    if (event.target.classList.contains("suggestion")) {
        selectedPlace = {
            name: event.target.getAttribute("data-name"),
            countryCode: event.target.getAttribute("data-countryCode"),
            latitude: event.target.getAttribute("data-latitude"),
            longitude: event.target.getAttribute("data-longitude"),
            timezone: event.target.getAttribute("data-timezone"), // Add timezone
        };
        placeOfBirthInput.value = selectedPlace.name;
        latitudeInput.value = selectedPlace.latitude; // Update latitude value
        longitudeInput.value = selectedPlace.longitude; // Update longitude value
        timezoneInput.value = selectedPlace.timezone; // Update timezone value
        clearSuggestions();
    }
});

async function getLocationSuggestions(place) {
    try {
        console.log("Place being sent for location suggestions:", place); // Log the place being sent

        const requestBody = "search=" + encodeURIComponent(place);
        console.log("Request Body:", requestBody); // Log the request body
        
        const response = await fetch(
            'https://api-horoskop-paradies.com/api.horoskop-paradies.ch/astrology/geoname.php',
            {
                method: "POST",
                headers: {
                    "Content-Type": "application/x-www-form-urlencoded",
                },
                body: "search=" + encodeURIComponent(place),
            }
        );

        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }

        const contentType = response.headers.get("content-type");
        const responseBody = await response.text(); // Read the response body once
        console.log("Response Body:", responseBody); // Log the response body

        // Check if the response body is empty
        if (responseBody.trim() === '') {
            console.log("Empty response body received.");
            return []; // Return an empty array
        }

        // Parse the JSON response body
        const suggestions = JSON.parse(responseBody);
        console.log("Parsed Suggestions:", suggestions); // Log the parsed suggestions

        if (!suggestions || suggestions.length === 0) {
            console.error("Invalid suggestions data:", suggestions);
            return []; // Return an empty array or handle the error as needed
        }

        // Process the suggestions further if needed...

        return suggestions; // Return the parsed suggestions
    } catch (error) {
        console.error("Error fetching location suggestions:", error);
        return []; // Return an empty array or handle the error as needed
    }
}

And here is the server PHP code (geoname.php)

<?php
define('DEBUG_MODE', true); // Set to true to enable debugging, false to disable
header("Access-Control-Allow-Origin: *");
header("Access-Control-Allow-Methods: POST, GET, OPTIONS");
header("Access-Control-Allow-Headers: Content-Type");
header("Content-Type: application/json"); // Set response content type to JSON

// Database credentials
$servername = "localhost";
$username = "###";
$password = "###";
$database = "###";

// Create connection
$conn = new mysqli($servername, $username, $password, $database);

// Check connection
if ($conn->connect_error) {
    // Return error response if connection fails
    echo json_encode(array('error' => 'Connection failed: ' . $conn->connect_error));
    exit; // Terminate script execution
}

if ($_SERVER["REQUEST_METHOD"] === "POST" && isset($_POST['search'])) {
    // Get the search parameter
    $searchParam = urldecode($_POST['search']);

    // Log the received search parameter
    if (DEBUG_MODE) {
        error_log("Received search parameter: " . $searchParam);
    }

    // Perform any necessary modifications or validations on the search parameter
    // For example, you can trim whitespace or apply htmlspecialchars
    $searchParam = trim($searchParam);
    $searchParam = htmlspecialchars($searchParam);
    $cityName = '%' . $searchParam . '%';  // Use wildcard for partial matching

    // Log the modified search parameter
    if (DEBUG_MODE) {
        error_log("Modified search parameter: " . $cityName);
    }

    // Prepare and execute the database query
    $stmt = $conn->prepare("SELECT * FROM `world_database_all_new` WHERE place LIKE ? ORDER BY place ASC LIMIT 8");
    $stmt->bind_param("s", $_POST['search']);
    $stmt->execute();
    $result = $stmt->get_result();

    if ($result->num_rows > 0) {
        $data = array();
        while ($row = $result->fetch_assoc()) {
            $data[] = $row;
        }
        // Return JSON response with data
        echo json_encode($data);
    } else {
        // No results found
        echo json_encode(array('error' => 'No results found for: ' . $_POST['search']));
    }
} else {
    // Invalid request
    echo json_encode(array('error' => 'Invalid request'));
}

// Close database connection
$conn->close();
?>

Hoping to get some help please 🙂

Thanks!

I tried on my local system using XAMPP. It worked as expected, but in production it did not.

Can I get a value from a textbox which is in asp:DataGrid which is inside another asp:DataGrid’s TemplateColumn in Javascript?

Check the Screenshot  I have a asp:DataGrid (Assume as Grid A) which has several asp:BoundColumn and asp:TemplateColumn inside..
One of the asp:TemplateColumn has another asp:DataGrid (Assume as Grid B)inside it ,
I want to get a value from a textbox onkeyup which is in Grid B and return it after calculation using Javascript or JQuery..

  <asp:DataGrid ID="dgfloor" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-striped mb-0"
                                        ShowFooter="true" Width="100%">
                                        <PagerStyle HorizontalAlign="Right" NextPageText="Next" PrevPageText="Prev" />
                                        <Columns>

  <asp:DataGrid ID="dgfloor" runat="server" AutoGenerateColumns="False" CssClass="table table-bordered table-striped mb-0"
                                        ShowFooter="true" Width="100%">
                                        <PagerStyle HorizontalAlign="Right" NextPageText="Next" PrevPageText="Prev" />
                                        <Columns>
    <asp:BoundColumn DataField="Data1" HeaderText="Already Completion%" HeaderStyle-HorizontalAlign="Center" ItemStyle-HorizontalAlign="Center" HeaderStyle-Width="100px"></asp:BoundColumn>
   <asp:TemplateColumn HeaderText="Current Completion%" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px">
                                                                <ItemTemplate>
                                                                    <asp:TextBox ID="txtData2" Width="70" runat="server" Text='<%#Eval("Percentage") %>' />
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
   <asp:TemplateColumn HeaderText="Completion Amount" ItemStyle-HorizontalAlign="Center" HeaderStyle-HorizontalAlign="Center" ItemStyle-Width="100px">
                                                                <ItemTemplate>
                                                                    <asp:Label ID="lblData3" Text='<%#Eval("Completionamt") %>' runat="server"></asp:Label>
                                                                </ItemTemplate>
                                                            </asp:TemplateColumn>
 </Columns>

  </Columns>
  
 <script type="text/javascript">
        var grid = document.getElementById("<%= dgwork.ClientID %>");
        for (var i = 1; i < grid.rows.length; i++) {
            var grid2 = grid.rows[i].cells[6].childNodes[0].value;

            for (var i = 1; i < grid2.rows.length; i++) {
               

                var one = grid2.rows[i].cells[7].childNodes[0].value;
                alert(one);

            }
           
           
        }

        </script>

To test it I have tried this JS to check whether its getting the value from the Grid B but it dint work..

The actual thing is i need to get the value from grid b and calculate it

when I change the value in Current Completion% textbox it should calculate Already Completion%*Amount and display it in Completion Amount (calculations should be done in script)

Add border to parent row cell

My problem is:

  1. When i select YES – i have border line around cell only in cell with checkbox YES – I need change it to select all rows.

  2. When I select YES – I need show error message – but it’s not working. How can i change it?

// YES
$('[id^="id_0-medical_question"][id$="_0"]').click(function() {
  $(this).parent().parent().css({
    'border': '2px solid #da4f49'
  });
  $(this).parent().parent().find('.medical_error_message').html('Error - you not like this');
});
// NO
$('[id^="id_0-medical_question"][id$="_1"]').click(function() {
  $(this).parent().parent().css({
    'border': '1px solid #ddd',
    'color': '#000000',
    'font-weight': 'normal'
  });
  $(this).parent().parent().find('.medical_error_message').html('');
});
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.7.1/jquery.min.js"></script>

<table class="table">
  <tbody>
    <tr>
      <td class="medical_question"><b>1. Do you like</b></td>
      <td>YES</td>
      <td>NOW</td>
    </tr>

    <tr>
      <td class="medical_question">
        1. Red hair
        <p class="medical_error_message"></p>
      </td>

      <td style="border: 2px solid rgb(218, 79, 73);"><label for="id_0-medical_question1_0"><input type="radio" name="0-medical_question1" value="1" required="" id="id_0-medical_question1_0">
     YES</label>
      </td>

      <td><label for="id_0-medical_question1_1"><input type="radio" name="0-medical_question1" value="0" required="" id="id_0-medical_question1_1">
     NO</label>
      </td>
    </tr>

    <tr>
      <td class="medical_question">
        2. Blond hair
        <p class="medical_error_message"></p>
      </td>

      <td><label for="id_0-medical_question2_0"><input type="radio" name="0-medical_question2" value="1" required="" id="id_0-medical_question2_0">
     YES
    </label>
      </td>

      <td><label for="id_0-medical_question2_1"><input type="radio" name="0-medical_question2" value="0" required="" id="id_0-medical_question2_1">
     NO</label>
      </td>
    </tr>

Error Connecting to the Binance Websocket for Market Streams (Javascript)

I was previously able to connect to the Binance Websocket, in August 2021, to pull in the current Bitcoin price in Javascript like this:

let webSocket = new WebSocket('wss://stream.binance.com:9443/ws/btcusdt@trade');
webSocket.onmessage = (event) => {
    console.log(event.data);
}

However, since then the documentation has been updated and I can’t figure out how to get the same websocket working again. Any help would be much appreciated

Documentation: https://binance-docs.github.io/apidocs/spot/en/#websocket-market-streams

I’ve tried this as recommended by the documentation:

let webSocket = new WebSocket('wss://stream.binance.com:9443/ws');
webSocket.onopen = function() {
    webSocket.send(
      JSON.stringify({
        method: "SUBSCRIBE",
        params: [
            "btcusdt@aggTrade",
            "btcusdt@depth"
        ],
        id: 1
      })
    );
};
webSocket.onmessage = (event) => {
        console.log(event.data);
}

But I’m still getting this error “WebSocket connection to ‘wss://stream.binance.com:9443/ws’ failed:” in the console.

Android Intent and JavaScript

I installed an app on my Android 12-equipped smartphone called Memento Database that I use to store data. This app is programmable with scripts made in JavaScript.
Sometimes I need to copy the contents of the textual fields of the records that I have saved in the various databases to the clipboard of the virtual keyboard of my smartphone (I use Gboard). I am looking for a script using the intent command that solve the problem.
Please help me to get this script. Thanks.
Loris