How to prevent/stop/remove div element from loaded in search page result?

its been a long time since i post question on this website , i hope you guys are doing okay these days , now to the issue , i got this code that worked but not immediately:

const childElement = document.getElementById('m-x-content');
if (childElement && childElement.parentNode) {
    childElement.parentNode.remove();
}

I tried wrapping it with

document.addEventListener('DOMContentLoaded', () => {}

and it doesnt worked at all . Now the extensions i used : tampermonkey and runjavascript , both seems to only run the script fine but only after element is loaded .

Now i also already tried chatgpt suggestion about using and it didnt worked.

“… to use a bookmarklet or a custom browser extension to remove elements before they load, here’s a breakdown of how each approach can work:”

You can ask chapgpt and try it own your own .

so the question is , is this chrome/chromium specific issues , or thats just how browser work ? here is a link to a video that i recorded , you can see it in the last 15 sec that it didnt remove the element immedietly .

google.script.run.withSuccessHandler(…).withFailureHandler(…) is not a function

  1. I’m integrating my Google Apps Script library into another guest Google Apps Script.

  2. Both the library and the guest script are tied-to Google Sheets.

  3. The library has a sidebar.html file, which is called into the guest script like this:

    Guest Script > Script.gs

    function onOpen() {
      SpreadsheetApp.getUi()
          .createMenu('My Menu')
          .addItem('Open Sidebar', 'showSidebar')
          .addToUi();
    }
    
    function showSidebar() {
        myLibrary.showSidebar();
    }
    

    This works and creates the UI menu, and clicking it opens the sidebar.html from the library, which runs as an HTML file with all front-end JavaScript <script>s inside of it.

  4. In the sidebar.html file (in the library) I have a JavaScript function to communicate with a server-side function through google.script.run, like this:

    Library > sidebar.html

    <script>
        google.script.run
            .withSuccessHandler((backendResponse) => {
                console.log('Successfully got backend response!');
            })
            .withFailureHandler((error) => {
                console.log('Error getting backend response!');
            })
            .myBackendFunctionName(someArgument);
    </script>
    
    

This works alright when I run it in a Google Apps Script directly, but, when I run it from an integrated library, it throws the following error to the guest’s console:

Uncaught TypeError:
google.script.run.withSuccessHandler(…).withFailureHandler(…).myBackendFunctionName
is not a function

What am I doing wrong? and how can I fix that?

How can I convert a video to a standalone link in Javascript?

I want to create a program that allows the user to 1) Upload a video 2) Have it fed to some program , and 3) Have that program translate the video into some type of data url or blob protocal (but for videos…)

I understnad that there might be some challenges in this as a URL can only store so much and a video has a lot of data, but any help would be appreciated. I’m not the best in JS, so very step-by-step answers would be extra-helpful. Thanks!

I tried having a simple user video upload sequence as an mp4 and converting the bytes to Base64. I’m assuming from this point it can be transfered into some decoding URL?

<!DOCTYPE html>
<html lang="en">
<head>
    <title>MP4 to Base64 Converter</title>
</head>
<body>
    <h1>MP4 to Base64</h1>
    <input type="file" id="fileInput" accept="video/mp4">
    <button id="convertButton">Convert</button>
    <h2>Output (Base64):</h2>
    <textarea id="base64Output" rows="10" cols="80" readonly></textarea>

    <script>
        document.getElementById('convertButton').addEventListener('click', function() {
            const fileInput = document.getElementById('fileInput');
            const file = fileInput.files[0];

            if (file && file.type === 'video/mp4') {
                const reader = new FileReader();
                reader.onloadend = function() {
                    const base64String = reader.result.split(',')[1];
                    document.getElementById('base64Output').value = base64String;
                };
                reader.readAsDataURL(file);
            } else {
                alert('Please upload a valid MP4 file.');
            }
        });
    </script>
</body>
</html>

Dropdown reload when it is in Radio Ant design

import React, { useState } from "react";
import "./index.css";
import type { RadioChangeEvent } from "antd";
import { Input, Radio, Space, Select } from "antd";

const App: React.FC = () => {
  const [value, setValue] = useState(1);

  const onChange = (e: RadioChangeEvent) => {
    console.log("radio checked", e.target.value);
    setValue(e.target.value);
  };

  return (
    <Radio.Group onChange={onChange} value={value}>
      <Space direction="vertical">
        <Radio value={1}>Option A</Radio>
        <Radio value={2}>Option B</Radio>
        <Radio value={3}>Option C</Radio>
        <Radio value={4}>
          <Select
            defaultValue="lucy"
            style={{ width: 120 }}
            options={[
              { value: "jack", label: "Jack" },
              { value: "lucy", label: "Lucy" },
              { value: "Yiminghe", label: "yiminghe" },
              { value: "disabled", label: "Disabled", disabled: true },
            ]}
            onClick={(e) => e.stopPropagation()}
          />
        </Radio>
      </Space>
    </Radio.Group>
  );
};

export default App;

I am experiencing an issue with my dropdown within a radio component in Ant Design. Whenever I attempt to click on the dropdown to expand it, the radio component’s state triggers a re-render. This causes the dropdown to reload, which makes it impossible for me to select any value within the dropdown’s Select component. How to fix it?

How to Detect Web Scrapers Using Chrome DevTools Protocol (CDP) Instead of Selenium or Puppeteer?

I’m experiencing an issue where my website is being targeted by web scraping bots. It appears that the attackers are controlling Chrome browsers using the Chrome DevTools Protocol (CDP) directly, rather than relying on automation frameworks like Selenium or Puppeteer. As a result, traditional browser fingerprinting methods aren’t revealing any unusual characteristics or anomalies.

I’ve Tried:

  1. Implementing standard browser fingerprinting techniques

Challenges:

  1. CDP-controlled browsers mimic regular user browsers closely, making it difficult to detect using conventional methods.
  2. Lack of distinctive fingerprints or behavioral anomalies.

Question:
What strategies or techniques can I use to effectively detect and mitigate web scrapers that are controlling Chrome browsers via the Chrome DevTools Protocol (CDP) instead of using automation tools like Selenium or Puppeteer? Are there specific indicators or advanced methods that can help identify such sophisticated scraping attempts?

Typescript expects array but got object, how do i make sure typescript knows its an object

Im writing a function that gets the active (selected) organisation.
Getting the values from the database was easy, making typescript happy is still a struggle.

    const { data, error } = await supabase
      .from('profiles')
      .select('active_organisation, organisations:organisations (*)')
      .eq('id', user.id)
      .single();

In this query i get a few things, the active organisation which is a number, but i also get the organisation with all its columns that is linked to my user.
How my code is setup, that linked organisation can only be one, so there is no way that organisations could be multiple rows.

**Now here comes the problem im facing:
**
Typescript thinks that organisations is an array and when i try to declare a type for the single row, it says i need to make sure its an array type because it might me multiple rows.

This is my full function for a bit more context.
Here you can see that in my return succes i try to make sure that organisations gets the type Organisation, but typescript wants me to use the following type Organisation[]

export async function getActiveOrganisation() {
    const supabase = await createClient();
    const { data: userData, error: userError } = await supabase.auth.getUser();
  
    if (userError || !userData.user) {
      return { success: false, error: 'User not found' };
    }
  
    const user = userData.user;
  
    const { data, error } = await supabase
      .from('profiles')
      .select('active_organisation, organisations:organisations (*)')
      .eq('id', user.id)
      .single();
  
    if (error) {
      return { success: false, error: error.message };
    }
  
    if (!data) {
      return { success: false, error: 'No profile found for the user' };
    }

    console.log(data);
    const organisation = data.organisations;

    if (!organisation) {
      return { success: false, error: 'No organisation found for the user' };
    }
  
    return { success: true, organisations: organisation as Organisation, activeOrganisationId: data.active_organisation };
  }

Id love to learn from a mistake i might have made, or something i dont know yet.
Also if there are any tips related to my way of coding they are more than welcome.

Generate all possible pairings of letters with no repetitions in javascript

I’m playing a game where an Enigma M3 cipher is being used. It isn’t meant to be played this way, but I’m finding it fun. For the current clue, the plug board for the cipher isn’t known.

A plug board string looks like this: “bq cr di ej kw mt os px uz gh”

Here are the rules for this particular plug board:

  1. Letters can only be used once: “ab cc de” is an invalid plug
  2. It can be 0-20 characters
  3. It must be an even number of letters: “ab” is valid, but “ab c” is not

I’m trying to generate all possible combinations in javascript but struggling. Or rather, I’m struggling to do this in the most efficient way.

Since I know the answer-plug-board is likely in English, it’s probably pretty short; it’s difficult to come up with long phrases under the above constraint. So it’s better to try shorter answers first.

What’s the most efficient algorithm to do this in javascript?

Problems uploading PDF files for conversion using GroupDocs in Node.js

Description

  • I’m developing a Node.js application that allows users to upload PDF files for conversion into Word documents using the GroupDocs library. However, I’m facing a problem where the file isn’t uploaded correctly, resulting in conversion failures.

  • When I try to upload the file, I get a response indicating that the upload was unsuccessful, with the message:

{"uploaded": ["file.name"], "errors": []}

  • This suggests that the file wasn’t saved correctly, as the name returned doesn’t match the actual name of the file I’m trying to send.

Error logs:

  • The server is running on port 8080.
  • The path of the uploaded file is correct, but the upload response is not returning the expected file name.
  • The conversion fails because the file cannot be found.

Questions:

  • What could be causing this problem with the file name in the upload response?
  • How can I ensure that the file is sent correctly to the S3 and accessed at the conversion stage?

“I’d appreciate any help or suggestions to solve this problem!”

Main part of the code:

const iniciarConversao = async inputFilePath => {
    try {
        const fileStream = fs.createReadStream(inputFilePath);
        const fileApi = new groupdocs_conversion_cloud.FileApi(config);
        const uniqueFileName = `${Date.now()}_${path.basename(inputFilePath)}`;

        console.log("Tentando fazer o upload do arquivo:", uniqueFileName);

        const request = new groupdocs_conversion_cloud.UploadFileRequest(uniqueFileName, fileStream, "");
        const uploadResponse = await fileApi.uploadFile(request);

        console.log("Resposta do upload:", JSON.stringify(uploadResponse, null, 2));

        if (
            !uploadResponse ||
            !uploadResponse.uploaded ||
            uploadResponse.uploaded.length === 0 ||
            !uploadResponse.uploaded.includes(uniqueFileName)
        ) {
            console.error("Resposta de upload inválida:", uploadResponse);
            throw new Error("Falha no upload do arquivo para o S3");
        }

        const uploadedFilePath = uniqueFileName;
        console.log("Upload realizado com sucesso. Caminho após upload:", uploadedFilePath);

        const converterApi = new groupdocs_conversion_cloud.ConvertApi(config);
        const settings = new groupdocs_conversion_cloud.ConvertSettings();
        settings.filePath = uploadedFilePath;
        settings.format = "docx";
        settings.outputPath = "output";

        console.log("Configurações de conversão: ", settings);

        const convertRequest = new groupdocs_conversion_cloud.ConvertDocumentRequest(settings);
        const result = await converterApi.convertDocument(convertRequest);

        console.log("Resultado bruto da conversão:", result);

        if (result && result[0].url) {
            console.log("Documento convertido com sucesso");
            return result[0].url;
        } else {
            throw new Error("Resultado da conversão está vazio ou com formato incorreto");
        }
    } catch (error) {
        console.error("Erro na conversão: ", error);
        throw error;
    }
};

My expectation is that it will work, I’m just consuming an api that already does the conversion, or at least it was supposed to do it on its own, but every time after the upload to the dashboard where I have the grupdocs account, it doesn’t do the conversion!!!

How to get all rendered fields in a Form with VeeValidate?

I’m using VeeValidate to validate my forms. I’ve got a Form component with several Field components in it.

I’m trying to get all the fields rendered inside the form, very much like when I open the Vue DevTools plugin I see a list of all rendered Field components. I’m not looking for a list of the initial values, just the actual form fields.

enter image description here

My form is currently looks like this:

<Form :validationSchema="validationSchema" :initialValues="initialValues" ref=form>
  <Field name="symbol" />
  <Field name="currency" />
  <Field name="date" />
  <Field name="quantity" />
  <Field name="price" />
  <Field name="fees" />
  <Field name="asset_type" />
  <Field name="order_type" />
</Form>

WebGL Faces of a Pyramid Using Different Images Texture-Mapping – Cannot see images – Need Example to Better Understand

I am hoping someone can support reviewing my attached html and js code to correct my error. Or at minimum share with me a similar example so that I can learn to correct my errors.

The expectation is to create a textured Pyramid successfully using different images in .js (WebGL) on a each face of a pyramid. Please see my html and js code. I am unable to see any image. I tried fixing the CORS error with local host and still see nothing. I do not know where the error is to correct the issue.

HTML:

<!DOCTYPE html>
<html>

<button id = "ButtonX">Rotate X</button>
<button id = "ButtonY">Rotate Y</button>
<button id = "ButtonZ">Rotate Z</button>
<button id = "ButtonT">Toggle Rotation</button>

<img id="face0" src="face0.png" hidden crossorigin="anonymous"></img>
<img id="face1" src="face1.jpg" hidden crossorigin="anonymous"></img>
<img id="face2" src="face2.png" hidden crossorigin="anonymous"></img>
<img id="face3" src="face3.png" hidden crossorigin="anonymous"></img>
<script id="vertex-shader" type="x-shader/x-vertex">
#version 300 es

in vec4 aPosition;
in vec4 aColor;
in vec2 aTexCoord;

out vec4 vColor;
out vec2 vTexCoord;

uniform vec3 uTheta;

void main()
{
    // Compute the sines and cosines of theta for each of
    //   the three axes in one computation.
    vec3 angles = radians(uTheta);
    vec3 c = cos(angles);
    vec3 s = sin(angles);

    // Remeber: thse matrices are column-major
    mat4 rx = mat4(1.0, 0.0, 0.0, 0.0,
            0.0, c.x, s.x, 0.0,
            0.0, -s.x, c.x, 0.0,
            0.0, 0.0, 0.0, 1.0);

    mat4 ry = mat4(c.y, 0.0, -s.y, 0.0,
            0.0, 1.0, 0.0, 0.0,
            s.y, 0.0, c.y, 0.0,
            0.0, 0.0, 0.0, 1.0);


    mat4 rz = mat4(c.z, s.z, 0.0, 0.0,
            -s.z, c.z, 0.0, 0.0,
            0.0, 0.0, 1.0, 0.0,
            0.0, 0.0, 0.0, 1.0);

    vColor = aColor;
    vTexCoord = aTexCoord;
    gl_Position = rz * ry * rx * aPosition;
    gl_Position.z = -gl_Position.z;
}
</script>

<script id="fragment-shader" type="x-shader/x-fragment">
#version 300 es

precision mediump float;

in vec4 vColor;
in vec2 vTexCoord;
out vec4 fColor;

uniform sampler2D uTex0;
uniform sampler2D uTex1;

void
main()
{
    fColor = vColor*(texture(uTex0, vTexCoord)*texture(uTex1, vTexCoord));

}
</script>

<script type="text/javascript" src="../SmithLarisaProj7/initShaders.js"></script>
<script type="text/javascript" src="../SmithLarisaProj7/utility.js"></script>
<script type="text/javascript" src="../SmithLarisaProj7/MVnew.js"></script>
<script type="text/javascript" src="../SmithLarisaProj7/SmithLarisaPyramid.js"></script>



<body>
<canvas id="gl-canvas" width="1024" height="1024">
Oops ... your browser doesn't support the HTML5 canvas element
</canvas>
</body>
</html>



JS:



"use strict";

var canvas;
var gl;

var numPositions  = 12;

var positionsArray = [];
var normalsArray = [];
var colorsArray = [];

var texSize = 64;

var numChecks = 8;

var axis=0;

var program;

var texture;

var imageUrls = [
    "face0.png",
    "face1.jpg",
    "face2.png",
    "face3.png"
];

var t1, t2;

var c;

var flag = true;


var vertices = [
   vec4(0.5, -0.2722, 0.2886, 1.0),
   vec4(0.0, -0.2772, -0.5773, 1.0),
   vec4(-0.5, -0.2722, 0.2886, 1.0),
   vec4(0.0, 0.5443, 0.0, 1.0)
];
var vertexColors = [
    vec4(0.0, 0.0, 1.0, 1.0),  // blue
    vec4(1.0, 0.0, 1.0, 1.0),  // magenta
    vec4(0.0, 1.0, 1.0, 1.0),  // cyan
    vec4(0.0, 0.0, 0.0, 1.0) // white
 ];
 

/* var image1 = new Uint8Array(4*texSize*texSize);

    for ( var i = 0; i < texSize; i++ ) {
        for ( var j = 0; j <texSize; j++ ) {
            var patchx = Math.floor(i/(texSize/numChecks));
            var patchy = Math.floor(j/(texSize/numChecks));
            if(patchx%2 ^ patchy%2) c = 255;
            else c = 0;
            //c = 255*(((i & 0x8) == 0) ^ ((j & 0x8)  == 0))
            image1[4*i*texSize+4*j] = c;
            image1[4*i*texSize+4*j+1] = c;
            image1[4*i*texSize+4*j+2] = c;
            image1[4*i*texSize+4*j+3] = 255;
        }
    }

var image2 = new Uint8Array(4*texSize*texSize);

    // Create a checkerboard pattern
    for (var i = 0; i < texSize; i++) {
        for (var j = 0; j <texSize; j++) {
            image2[4*i*texSize+4*j] = 127+127*Math.sin(0.1*i*j);
            image2[4*i*texSize+4*j+1] = 127+127*Math.sin(0.1*i*j);
            image2[4*i*texSize+4*j+2] = 127+127*Math.sin(0.1*i*j);
            image2[4*i*texSize+4*j+3] = 255;
           }
    }
*/
var positionsArray = [];
var colorsArray = [];
var texCoordsArray = [];

var texCoord0 = [
    vec2(0, 0),
    vec2(0, 1),
    vec2(1, 1),
    vec2(1, 0)
];
var texCoord1 = [
    vec2(0, 0),
    vec2(0, 1),
    vec2(1, 1),
    vec2(1, 0)
];
var texCoord2 = [
    vec2(0, 0),
    vec2(0, 1),
    vec2(1, 1),
    vec2(1, 0)
];

var texCoord3 = [
    vec2(0, 0),
    vec2(0, 1),
    vec2(1, 1),
    vec2(1, 0)
];

var xAxis = 0;
var yAxis = 1;
var zAxis = 2;
var axis = xAxis;

var theta = vec3(45.0, 45.0, 45.0);

var thetaLoc;

function configureTexture(images, textureUnit) {
    gl.activeTexture(gl.TEXTURE0 = textureUnit);
    texture = gl.createTexture();
    gl.bindTexture(gl.TEXTURE_2D, texture);
    gl.texImage2D(gl.TEXTURE_2D, 0, gl.RGBA, gl.RGBA, gl.UNSIGNED_BYTE, images);
    gl.generateMipmap(gl.TEXTURE_2D);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MIN_FILTER,
                      gl.NEAREST_MIPMAP_LINEAR);
    gl.texParameteri(gl.TEXTURE_2D, gl.TEXTURE_MAG_FILTER, gl.NEAREST);

    gl.uniform1i(gl.getUniformLocation(program, "uTexMap" + textureUnit),textureUnit);
    }

function tri(a, b, c, texCoord) {
     positionsArray.push(vertices[a]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[0]);

     positionsArray.push(vertices[b]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[1]);

     positionsArray.push(vertices[c]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[2]);

     positionsArray.push(vertices[a]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[0]);

     positionsArray.push(vertices[c]);
     colorsArray.push(vertexColors[a]);
     texCoordsArray.push(texCoord[2]);

}

function colorPyramid()
{
    tri(1, 2, 3, texCoord0);
    tri(2, 3, 0, texCoord1);
    tri(3, 1, 2, texCoord2);
    tri(0, 2, 1, texCoord3);
}

window.onload = function init() {

    canvas = document.getElementById("gl-canvas");

    gl = canvas.getContext('webgl2');
    if (!gl) alert("WebGL 2.0 isn't available");

    gl.viewport(0, 0, canvas.width, canvas.height);
    gl.clearColor(1.0, 1.0, 1.0, 1.0);

    gl.enable(gl.DEPTH_TEST);

    var numImages = imageUrls.length;
    for(var i=0; i<numImages; i++) {
        var images = document.getElementById("face" + (i+1));
        configureTexture(images, i);
    }

    //
    //  Load shaders and initialize attribute buffers
    //
    program = initShaders(gl, "vertex-shader", "fragment-shader");
    gl.useProgram(program);

    colorPyramid();

    var cBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, cBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, flatten(colorsArray), gl.STATIC_DRAW);

    var colorLoc = gl.getAttribLocation( program, "aColor");
    gl.vertexAttribPointer(colorLoc, 4, gl.FLOAT, false, 0, 0);
    gl.enableVertexAttribArray(colorLoc);

    var vBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, vBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, flatten(positionsArray), gl.STATIC_DRAW);

    var positionLoc = gl.getAttribLocation( program, "aPosition");
    gl.vertexAttribPointer(positionLoc, 4, gl.FLOAT, false, 0, 0);
    gl.enableVertexAttribArray(positionLoc );

    var tBuffer = gl.createBuffer();
    gl.bindBuffer(gl.ARRAY_BUFFER, tBuffer);
    gl.bufferData(gl.ARRAY_BUFFER, flatten(texCoordsArray), gl.STATIC_DRAW);

    var texCoordLoc = gl.getAttribLocation(program, "aTexCoord");
    gl.vertexAttribPointer(texCoordLoc, 2, gl.FLOAT, false, 0, 0);
    gl.enableVertexAttribArray(texCoordLoc);

    var image = document.getElementById("face");
    configureTexture(image);

    
    gl.activeTexture(gl.TEXTURE0);
    gl.bindTexture(gl.TEXTURE_2D, texture1);
    gl.uniform1i(gl.getUniformLocation( program, "uTex0"), 0);

    gl.activeTexture(gl.TEXTURE3 );
    gl.bindTexture(gl.TEXTURE_2D, texture3);
    gl.uniform1i(gl.getUniformLocation( program, "uTex1"), 3);


    thetaLoc = gl.getUniformLocation(program, "uTheta");


 document.getElementById("ButtonX").onclick = function(){axis = xAxis;};
 document.getElementById("ButtonY").onclick = function(){axis = yAxis;};
 document.getElementById("ButtonZ").onclick = function(){axis = zAxis;};
 document.getElementById("ButtonT").onclick = function(){flag = !flag;};

    render();
}

var render = function() {
    gl.clear(gl.COLOR_BUFFER_BIT | gl.DEPTH_BUFFER_BIT);
    if(flag) theta[axis] += 2.0;
    gl.uniform3fv(thetaLoc, theta);
    for(i=0;i<12;i++){
        gl.bindTexture(gl.TEXTURE_2D, texture[i+start])
    gl.drawArrays(gl.TRIANGLES, 12*i, numPositions);
    }
    requestAnimationFrame(render);
}

I tried using a php opening a local host to fix CORS error, but still am unable to see any image. Therefore, I believe there is an issue in the code.

How do I set a node module import path as a variable?

I have 2 seperate files with various JS functions on them. I want to import either one based on a condition. I am unsure how to do this.

I have:

import { mainURL } from '../../support/helperFunctions.js';

let dataPath = '../../../data/data.js';
if (mainURL.includes('dev')) {
    dataPath = '../../../data/dataDev.js';
}
import { coreData, lastUpdated } from dataPath;

But I get the error Unexpected token for the import line.

I’ve also tried

if (mainURL.includes('dev')) {
    import { coreData, lastUpdated } from '../../../data/dataDev.js';
}
else {
    import { coreData, lastUpdated } from '../../../data/data.js';
}

And a few other variations of this.

Would anyone know how to achieve this in node?

Does iterating over promises actually runs them?

While working with googleapis library with a coworker, I’ve stumbled onto this error:

Uncaught GaxiosError Error: request to <gmail api url> failed, reason: connect EMFILE <xxx.xxx.xx.xxx:xxx> - Local (undefined:undefined)
    at _request (/gmail-api/node_modules/gaxios/build/src/gaxios.js:149:19)
    at processTicksAndRejections (<node_internals>/internal/process/task_queues:95:5)
gaxios.js:149
Process exited with code 1

It happened only if I tried to generate a list of promises to be used with Promise.all:

const promises = emailList.map((email) => {
      return this.gmailApi.users.messages.get({
        userId: 'me',
        id: email.id,
      })
    })

const resolvedPromises = await Promise.all(promises)

However, if instead I manually executed only the first 10 promises, without mapping each one to my promises variable, it would work. It seems it only causes the error AFTER I iterate each promise with the .map… My question is: Why does this happen? What is node doing behind the curtains?

Morphing map bubble size on update in highcharts maps

I have a map with a bubble on it (simplified example):

A map of greater Brisbane in Queensland, Australia. On the map, a red semi-transparent bubble is centered on inner-city Brisbane

On click of a button, I want the bubble to do 3 things:

  • Change size
  • Change colour
  • Morph between states nicely (i.e. transition)

It currently morphs colour nicely but does not change size at all. When I can get it to change size, it doesn’t do it smoothly (it goes directly from one state to the other, no morphing).

How do I get size to morph nicely in addition to colour?

Live example here: https://codepen.io/n93/pen/ExqpgLR

Reproducible code:

HTML

<script src="https://code.highcharts.com/maps/highmaps.js"></script>
<script src="https://code.highcharts.com/maps/modules/exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/offline-exporting.js"></script>
<script src="https://code.highcharts.com/maps/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/maps/modules/accessibility.js"></script>
<script src="https://code.highcharts.com/maps/modules/tiledwebmap.js"></script>

<div id="container"></div>
<button id="change-size-button">
Change the bubble size
</button>

JS

var map;
map = Highcharts.mapChart("container", {
  mapNavigation: {
    enabled: true,
    buttonOptions: {
      alignTo: "spacingBox",
    },
  },

  mapView: {
    projection: {
      name: "WebMercator",
    },
    center: [152.9993, -27.41962],
    zoom: 10,
  },
  series: [
    {
      type: "tiledwebmap",
      name: "Tiles",
      provider: {
        type: "OpenStreetMap",
        theme: "Standard",
        subdomain: "a",
      },
      opacity: 0.5,
    },
    {
      type: "mapbubble",
      
      minSize: 20,
      maxSize: 100,
      data: [
        {
        name: "New series",
          lat: -27.451,
          lon: 153.0117,
          z: 30,
          color: "#F00011",
        },
      ],
    },
  ],
})

document
  .getElementById("change-size-button")
  .addEventListener("click", function () {
    map.series[1].data.forEach((point) => {
      point.update({
        // This works correctly
            name: "Updated series",
        color: "#080CAB",
        // This does not
        z: 40,
      })
    })
  })

How do you arithmetic on values from a form in Javascript?

I’m teaching myself basic Javascript and trying to figure out how to do math with values a user enters in a form.

This is what I have so far, but I’m clearly using the wrong kind of forumula because it’s concatenating the digits rather than adding the numbers. I’ve also tried changing the types of the three input fields between “text” and “number”, to no avail.

    <form name="thing" id="calculator">

A <input type="number" name="inputa" size="16" class="display">
<br>
B <input type="number" name="inputb" size="16" class="display">


<input type="button" name="dothething" value="add them" OnClick="thing.output2.value = eval(thing.inputa.value + thing.inputb.value)">

<br>
A+B=<input type="text" name="output2" size="16" class="display">
    </form>