Is there an extension that bypasses user-agent completely? [closed]

I don’t know why but User-Agent Switcher does not work on https://www.w3schools.com/jsref/tryit.asp?filename=tryjsref_nav_useragent

Tried different extensions and nothing works.

This is such simple issue I don’t know what else to say to fill out this space with text. Oh Woe! Nothing works neither https://chromewebstore.google.com/detail/user-agent-switcher-and-m/bhchdcejhohfmigjafbampogmaanbfkg

I don’t know why the character limit is so high

POS System – Unable to Toggle ‘Show Receipt’ Feature Based on Setting (Laravel, JavaScript, Session Management)

Problem Description:
I am working on a POS system where I need to allow users to enable or disable the “Show Receipt” feature after completing a cash transaction. The receipt should only be shown if the setting is enabled; otherwise, it should be skipped.

I have implemented the following:
Backend (Laravel):

A setting in the business settings (enable_show_receipt) that controls whether the receipt is shown after a transaction.
The setting is stored in the session and should be accessible in the JavaScript part.
Frontend (JavaScript):

A JavaScript function (pos_print(receipt)) that checks the session value of enable_show_receipt and either shows or hides the receipt accordingly.
I’m trying to dynamically check this value and skip the receipt print if the setting is disabled.

However, the issue is:

Even when the “Enable Show Receipt” checkbox is disabled or enabled in the settings, the print preview window still shows up.
The setting does not seem to be applied properly, and the receipt is always printed regardless of the checkbox setting.

When the “Enable Show Receipt” checkbox is checked:
The receipt should be shown after a successful transaction.

When the checkbox is unchecked:
The receipt should be skipped.

Error submitting data: Failed to fetch, while submitting html css, js form data to google sheets

step1.html

    <!doctype html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
    <title>Visa Points Calculator</title>
    <link rel="stylesheet" href="bootstrap.css">
    <link rel="stylesheet" href="bootstrap.min.css">
    <link rel="stylesheet" href="style.css">
</head>
<body class="bg-light">
    <div class="container py-5">
        <div class="text-center">
            <h1>Visa Points Calculator Step-1</h1>
        </div>
        
        <form id="visaForm">
            <div class="row">
            <div class="col-md-6">
            <div class="form-group">
                <label for="candidateName">Candidate's Name:</label>
                <input type="text" class="form-control" id="candidateName" required>
            </div>

            <div class="form-group">
                <label for="contactNumber">Contact Number:</label>
                <input type="tel" class="form-control" id="contactNumber" required>
            </div>

            <div class="form-group">
                <label for="dob">Date of Birth:</label>
                <input type="date" class="form-control" id="dob" required>
            </div>

            <div class="form-group">
                <label for="email">Email ID:</label>
                <input type="email" class="form-control" id="email" required>
            </div>

            <div class="form-group">
                <label>Highest Education:</label><br>
                <input type="radio" name="education" value="10th"> 10th<br>
                <input type="radio" name="education" value="12th"> 12th<br>
                <input type="radio" name="education" value="Graduate"> Graduate<br>
                <input type="radio" name="education" value="Postgraduate"> Postgraduate<br>
                <input type="radio" name="education" value="Doctorate"> Doctorate<br>
            </div>

            <div class="form-group">
                <label for="degree">Educational Degrees:</label>
                <input type="text" class="form-control" id="degree">
            </div>

            <div class="form-group">
                <label>Assets:</label><br>
                <input type="checkbox" value="Irrigation Land"> Irrigation Land<br>
                <input type="checkbox" value="Commercial Land"> Commercial Land<br>
                <input type="checkbox" value="Apartment or Flat"> Apartment or Flat<br>
                <input type="checkbox" value="House"> House<br>
            </div>
            </div>

            <div class="col-md-6">
            <div class="form-group">
                <label for="currentVisaCountry">Current Visa Country(If any):</label>
                <select class="form-control" id="currentVisaCountry">
                    
                </select>
            </div>

            <div class="form-group">
                <label for="newVisaCountry">Want a visa to:</label>
                <select class="form-control" id="newVisaCountry">
                    
                </select>
            </div>

            <div class="form-group">
                <label for="visaRejectionCountries">Visa Rejection Countries(If any):</label>
                <select class="form-control" id="visaRejectionCountries">
                    
                </select>
            </div>

            <div class="form-group">
                <label for="lastVisaRejectionDate">Last Visa Rejection Date(If any):</label>
                <input type="date" class="form-control" id="dob" required>
            </div>

            <div class="form-group">
                <label>Profession:</label><br>
                <input type="radio" name="profession" value="Student" onclick="toggleIncomeFields(false)"> Student<br>
                <input type="radio" name="profession" value="Businessman" onclick="toggleIncomeFields(true)"> Businessman<br>
                <input type="radio" name="profession" value="Salaried" onclick="toggleIncomeFields(true)"> Salaried Employee<br>
            </div>

            <div id="incomeFields" style="display: none;">
                <div class="form-group">
                    <label for="monthlyIncome">Monthly Income(In Indian Rupees):</label>
                    <input type="text" class="form-control" id="monthlyIncome">
                </div>
                <div class="form-group">
                    <label>Income Type:</label><br>
                    <input type="checkbox" value="Business"> Business<br>
                    <input type="checkbox" value="Salaried"> Salaried<br>
                    <input type="checkbox" value="Other"> Other<br>
                </div>
            </div>

            </div>
            </div>

            <div style="text-align: center;">
                <button type="submit" class="btn btn-primary">Step-2</button>
            </div>
        </form>
    </div>

    <script>
        const countries = ["None", "Afghanistan", "Albania", "Algeria", "Andorra", "Angola", "Argentina", "Australia", "Austria", "Bangladesh", "Belgium", "Brazil", "Canada", "China", "Denmark", "Egypt", "Finland", "France", "Germany", "India", "Italy", "Japan", "Mexico", "Netherlands", "Norway", "Pakistan", "Russia", "Saudi Arabia", "South Africa", "Spain", "Sweden", "Switzerland", "United Kingdom", "United States"];
        
        function populateCountries(selectId) {
            const selectElement = document.getElementById(selectId);
            countries.forEach(country => {
                const option = document.createElement('option');
                option.value = country;
                option.textContent = country;
                selectElement.appendChild(option);
            });
        }

        populateCountries('currentVisaCountry');
        populateCountries('newVisaCountry');
        populateCountries('visaRejectionCountries');

        function toggleIncomeFields(show) {
            document.getElementById('incomeFields').style.display = show ? 'block' : 'none';
        }


        function toggleIncomeFields(show) {
            document.getElementById('incomeFields').style.display = show ? 'block' : 'none';
        }

        document.getElementById('visaForm').addEventListener('submit', function(e) {
    e.preventDefault();

    const formData = new FormData(e.target);
    let data = {};

    // Convert FormData to JSON Object
    formData.forEach((value, key) => {
        if (data[key]) {
            if (Array.isArray(data[key])) {
                data[key].push(value);
            } else {
                data[key] = [data[key], value];
            }
        } else {
            data[key] = value;
        }
    });

    // Collect checked checkboxes manually
    data['assets'] = Array.from(document.querySelectorAll('input[type="checkbox"]:checked')).map(cb => cb.value);

    fetch('https://script.google.com/macros/s/AKfycbxOF8FLSlEd1sVmineXKQtph2Ix1RokQcJ3VuCYR3veLyi7xo98h3eW0zTvQN_fFnNK/exec', {
        method: 'POST',
         mode: 'cors',  // Ensure CORS mode is enabled
        body: JSON.stringify(data),
        headers: { 'Content-Type': 'application/json' }
    })
    .then(response => {
        if (!response.ok) {
            throw new Error(`HTTP error! Status: ${response.status}`);
        }
        return response.json();
    })
    .then(responseJson => {
        if (responseJson.result === "success") {
            alert('Data submitted successfully');
            window.location.href = '/stepcountries.html';
        } else {
            alert('Error in Google Apps Script: ' + JSON.stringify(responseJson));
        }
    })
    .catch(error => alert('Error submitting data: ' + error.message));
});

    </script>
</body>
</html>

Google sheet App Script:

    function doPost(e) {
  try {
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
    const data = JSON.parse(e.postData.contents);

    const values = [
      data['candidateName'],
      data['contactNumber'],
      data['dob'],
      data['email'],
      data['education'],
      JSON.stringify(data['assets']),  // Convert assets to JSON
      data['currentVisaCountry'],
      data['newVisaCountry'],
      data['visaRejectionCountries'],
      data['degree'],
      data['profession'],
      data['monthlyIncome']
    ];

    sheet.appendRow(values);

    // ✅ Return a response with proper CORS headers
    return ContentService.createTextOutput(JSON.stringify({ result: 'success' }))
      .setMimeType(ContentService.MimeType.JSON);
      
  } catch (error) {
    return ContentService.createTextOutput(JSON.stringify({ result: 'error', message: error.message }))
      .setMimeType(ContentService.MimeType.JSON);
  }
}

// ✅ Handle CORS Preflight Requests (OPTIONS)
function doGet(e) {
  return ContentService.createTextOutput("")
    .setMimeType(ContentService.MimeType.TEXT)
}

PostMan shows no error on handling and submitting data into sheets.

Error faced in browser when interacting live website link:https://ashrithmanagementservicelimited.github.io/VisaScore/step1.html

Error in dev mode:

    `Access to fetch at 'https://script.google.com/macros/s/AKfycbzbAyTfLqI3rJJJd2aYy6XdYZD60wViYYkwxzwSSyuc-i7zrW79t4J0gjdHF2olYdy0/exec'
 from origin 'https://ashrithmanagementservicelimited.github.io' has been blocked
 by CORS policy: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource.
 If an opaque response serves your needs, set the request's mode to 'no-cors' to fetch the resource with CORS disabled.Understand this errorAI
    step1.html:167 

        
        
       POST https://script.google.com/macros/s/AKfycbzbAyTfLqI3rJJJd2aYy6XdYZD60wViYYkwxzwSSyuc-i7zrW79t4J0gjdHF2olYdy0/exec net::ERR_FAILED`

Another Google Sheet App Script:

    function doPost(e) {
  try {
    const sheet = SpreadsheetApp.getActiveSpreadsheet().getSheetByName('Sheet1');
    const data = JSON.parse(e.postData.contents);

    const values = [
      data['candidateName'],
      data['contactNumber'],
      data['dob'],
      data['email'],
      data['education'],
      JSON.stringify(data['assets']),  // Convert assets to JSON
      data['currentVisaCountry'],
      data['newVisaCountry'],
      data['visaRejectionCountries'],
      data['degree'],
      data['profession'],
      data['monthlyIncome']
    ];

    sheet.appendRow(values);

    // ✅ Return a response with proper CORS headers
    return ContentService.createTextOutput(JSON.stringify({ result: 'success' }))
      .setMimeType(ContentService.MimeType.JSON)
      .setHeader("Access-Control-Allow-Origin", "*")
      .setHeader("Access-Control-Allow-Methods", "POST, GET")
      .setHeader("Access-Control-Allow-Headers", "Content-Type: application/json")

      
  } catch (error) {
    return ContentService.createTextOutput(JSON.stringify({ result: 'error', message: error.message }))
      .setMimeType(ContentService.MimeType.JSON)
      .setHeader("Access-Control-Allow-Origin", "*")
      .setHeader("Access-Control-Allow-Methods", "POST, GET")
      .setHeader("Access-Control-Allow-Headers", "Content-Type: application/json")

  }
}

// ✅ Handle CORS Preflight Requests (OPTIONS)
function doGet(e) {
  return ContentService.createTextOutput("")
    .setMimeType(ContentService.MimeType.JSON)
    .setHeader("Access-Control-Allow-Origin", "*")
    .setHeader("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
    .setHeader("Access-Control-Allow-Headers", "Content-Type: application/json")

}

Error while executing Script:

TypeError: ContentService.createTextOutput(...).setMimeType(...).setHeader is not a function
doPost  @ Code.gs:34

Another script:

return HtmlService.createHtmlOutput(JSON.stringify({ result: 'error', message: error.message }))
      .setMimeType(ContentService.MimeType.JSON)
      .setXFrameOptionsMode(HtmlService.XFrameOptionsMode.ALLOWALL);
  }

Same browser error appears as above but postman displays no error and saves data

Dropdown select2 plugin cannot search

Im using this Select2 plugin in dropdown at my partial view. The textbox is coming on the dropdown but i couldnt type anything inside that textbox. I need an asssist here.

    <link href="~/Content/Multiselect/select2.min.css" rel="stylesheet" />
<!-- Select2 JS -->
<script src="~/Content/Multiselect/select2.min.js"></script>

<script>
    $(".searchfilter").select2();

</script>

<span class="input-group-addon p-0 cust-addon">

                                                    @Html.DropDownListFor(model => model.DialCode, (SelectList)ViewBag.DialCodeList, "Please Select", new { @class = " form-control requiredfield searchfilter Select2-fixed-width", @style = "width: 95px;" })
                                                </span>
<style>
.input-group .form-control {
    height: 34px; /* Match height */
    border-radius: 0; /* Consistent edges */
}

.input-group-addon .form-control {
    height: 34px; /* Match the input height */
    border-radius: 0; /* Consistent edges */
}

.cust-addon {
    padding: 0px !important;
}

.Select2-fixed-width + .select2-container {
    display: block !important; /* Ensure it is displayed correctly */
    width: 120px !important;
    font-size: 12px !important; /* Adjust the font size as needed */
}

How can I make a text appear when hovering?

I’ve tried to use a loop to add an event listener for the mouse entering and exiting the text but I cant seem to figure it out.

//hide text by default
for (i = 0; i < document.querySelectorAll("#answer").length; i++) {
  document.querySelectorAll("#answer")[i].style.visibility = "hidden";

}

//loop to add listeners to every answer to appear when hover, disappear when no hover
for (i = 0; i < document.querySelectorAll("#answer").length; i++) {
  document.querySelectorAll("#answer")[i].addEventListener("onmouseenter", appear);
  document.querySelectorAll("#answer")[i].addEventListener("onmouseleave", disappear);
}


//show text when hover
function appear() {
  document.getElementById("answer").style.visibility = "visible";
}

//hide text when not hover
function disappear() {
  document.getElementById("answer").style.visibility = "hidden";
}
<div id="Nouns">
  <h2 class="Word-title">Nouns</h2>
  <ul id="List-words">
    <li>eachother--<span id="Answer">서로</span></li>
    <li>Tongs--<span id="Answer">집게</span></li>
    <li>Scissors--<span id="Answer">가위</span></li>
    <li>Sentence--<span id="Answer">문장</span></li>
    <li>Grammar--<span id="Answer">문법</span></li>
    <li>Part--<span id="Answer">부분</span></li>
  </ul>
</div>

How to webscrape magicbricks.com [closed]

How can I web scrape more details section data from magicbricks.com. I am not able to get this, every time my JSON file contains empty data. I have tried different codes and html tags from a website, but every time I get empty results. One time I got some data but the description available there is showing empty in my JSON file.

I have tried to use HTML tags of description but not able to get results.

How can I detect whether the device that a webpage script is running on has accelerometers available for devicemotion/deviceorientation access?

I’m trying to detect whether a device that’s running a webpage JavaScript script in a browser has accelerometer data available for devicemotion and deviceorientation access. This is what I have now:

  function onMotion(event) {
    if (event.acceleration.y==null) {
      //there can be null events even on supported devices
      return;
    }
    document.getElementById("support-status-text").innerHTML = "Supported on this device";
    document.getElementById("y-acceleration-text").innerHTML = roundToFixed(event.acceleration.y);
  }

  function roundToFixed(value) {
    return value==null ? value : value.toFixed(2);
  }

  if (!('ondeviceorientation' in window)) {
    document.getElementById("support-status-text").innerHTML = "Orientation not supported on this device";
  }

  if ('ondevicemotion' in window) {
    window.addEventListener('devicemotion', onMotion);
  } else {
    document.getElementById("support-status-text").innerHTML = "Not supported on this device";
  }
<div id="container">
  <p id="support-status-text">Loading...</p>
  <p id="y-acceleration-text">nothing</p>
</div>

On my phone, which has both motion and orientation support, the top text reads “Supported on this device” with the incoming accelerometer data displayed below it (after flashing “Loading…” and “nothing” before non-null events start firing, which is fine for now). However, on my laptop, which does not have motion support, I just see “Loading…” rather than the expected “Not supported on this device”. On my tablet, which I believe has motion support but not orientation support, I see “Loading…” rather than the expected “Orientation not supported on this device”.

Destructure if not null or return out of the function

I am coding in typescript but I think this is a generic javascript issue.

I have a function that returns an array or undefined (from a remote service).

So to consume the code I do something like:

async function myFunction() {

   const result = await whatever();

   if (result == null) {
      return;
   }

   const [actual, data, here] = result;
   // process the destructured
}

Now as whatever() is called a lot the following if...return...const triad is repeated a few times. Is there a way to do this as a one liner?

I know that I can do something like const [actual, data, here] = result || ['default', {}, 'data']; but there are many a time that I don’t have defaults and literally want to exit out of the whole function if the overarching array is null (as it specifically denotes that we couldn’t get data for one reason or another).

The requested resource isn’t a valid image Next.JS monorepo

Need help understanding why next.js can’t resolve my static image.

I have a monorepo next.js structure so I can share components between projects, and this is my folder structure.

.
├── apps
│   └── web
│       ├── components
│       ├── node_modules
│       ├── pages
│       └── styles
├── node_modules
└── packages
    ├── eslint-config
    └── typescript-config

I have tried to put my public folder in the root of the entire repo, and in the apps/web/ folder. I have tried to reference the image via /public/<file_path>.png and without it -> /<file_path>.png

                <Image src={`/static/haroombe_logo.png`} alt='logo' width="64" height="64" />

In both cases it throws a variation of the following error.

The requested resource isn't a valid image for / received text/html; charset=utf-8

The image is less than 200 KB so I am wondering if it is a config or alias issue I didn’t set up.

Eslint 9 Not working properly in Next JS 15.2.2

currently I’m working on a NextJs project and I’m trying to configure all the rules correctly for the team to follow them. However, when trying to trigger the react/hooks eslint rules, the server seems not to recognize them even though they are included in the next extension for eslint (docs).

package.json

"dependencies": {
        "@emotion/cache": "^11.14.0",
        "@emotion/react": "^11.14.0",
        "@emotion/styled": "^11.14.0",
        "@hookform/resolvers": "^4.1.3",
        "@lukemorales/query-key-factory": "^1.3.4",
        "@mui/icons-material": "^6.4.4",
        "@mui/material": "^6.4.7",
        "@mui/material-nextjs": "^6.4.3",
        "@mui/x-charts": "^7.27.1",
        "@tanstack/react-query": "^5.67.2",
        "@types/lodash": "^4.17.16",
        "axios": "^1.8.1",
        "lodash": "^4.17.21",
        "next": "15.2.2",
        "next-intl": "^3.26.3",
        "react": "^19.0.0",
        "react-dom": "^19.0.0",
        "react-hook-form": "^7.54.2",
        "zod": "^3.24.2"
      },
      "devDependencies": {
        "@eslint/compat": "^1.2.7",
        "@eslint/eslintrc": "^3.3.0",
        "@next/eslint-plugin-next": "^15.2.2",
        "@tanstack/eslint-plugin-query": "^5.68.0",
        "@types/node": "^20",
        "@types/react": "^19",
        "@types/react-dom": "^19",
        "eslint": "^9.22.0",
        "eslint-config-next": "^15.2.2",
        "eslint-config-prettier": "^10.1.1",
        "eslint-plugin-next": "^0.0.0",
        "eslint-plugin-react": "^7.37.4",
        "eslint-plugin-react-hooks": "^5.2.0",
        "eslint-scope": "^8.3.0",
        "postcss": "^8",
        "tailwindcss": "^3.4.1",
        "typescript": "^5"
      }

eslint.config.mjs

import { FlatCompat } from "@eslint/eslintrc";
import pluginQuery from "@tanstack/eslint-plugin-query";

const compat = new FlatCompat({
  baseDirectory: import.meta.dirname,
});

const eslintConfig = [
  ...compat.extends("prettier", "next/core-web-vitals", "next/typescript"),
  ...pluginQuery.configs["flat/recommended"],
  {
    rules: {
      "no-console": "warn",
    },
  },
];

export default eslintConfig;

Hook where I’m trying to trigger the rule

  useEffect(() => {
    if (defaultValues) {
      form.reset(defaultValues);
    }
  });

Javascript Navbar Shrink

I have a big problem with my javascript code.
What am I doing wrong?

I just want to create with my js code that the image in the navbar shrinks and that my classes float with the class hidden-box. The float in works, but the navbar image does not get smaller when I´m scrolling. I´m trying it for 5 hours now, with google, chatgpt, etc.

HTML

<nav class="navbar navbar-expand-lg fixed-top" id="navbar">
<div class="container">
<a class="navbar-brand" href="#">
<img src="img/logo550x305.png" class="logo" id="logo" alt="Logo">
</a>
<button class="navbar-toggler" type="button" data-bs-toggle="collapse" data-bs-target="#navbarNav">
<span class="navbar-toggler-icon"></span>
</button>
<div class="collapse navbar-collapse" id="navbarNav">
<ul class="navbar-nav ms-auto">
<li class="nav-item"><a class="nav-link" href="#">item1</a></li>
<li class="nav-item"><a class="nav-link" href="#">item2</a></li>
<li class="nav-item"><a class="nav-link" href="#">item3</a></li>
<li class="nav-item"><a class="nav-link" href="#">item4</a></li>
<li class="nav-item"><a class="nav-link" href="">item5</a></li>
</ul>
</div>
</div>
</nav>

CSS

.navbar {
    background: white;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    border-bottom: 5px solid;
    border-image: linear-gradient(to right, var(--primary-red), var(--primary-blue)) 1;
    padding: 5px 0;
    transition: all 0.3s ease-in-out;
}

.navbar-brand img {
    width: 300px !important;
    height: auto;
    transition: width 0.3s ease-in-out !important;
}

.navbar.shrink .navbar-brand img {
    width: 200px !important;
}

JS

"use strict";

document.addEventListener("DOMContentLoaded", () => {
    const observer = new IntersectionObserver((entries) => {
        entries.forEach((entry) => {
            if (entry.isIntersecting) {
                entry.target.classList.add("show");
            }
        });
    });

    document.querySelectorAll(".hidden-box").forEach((el) => observer.observe(el));

    let navbar = document.querySelector(".navbar");

    window.addEventListener("scroll", function () {
        if (window.scrollY > 50) {
            navbar.classList.add("shrink");
        } else {
            navbar.classList.remove("shrink");
        }
    });
});

BTW I´m using the framwork bootstrap.

Please help <3

I want that my navbar img shrink by scrolling.

Why is the div’s height not equal to the sum of the table cell heights, even though they compare equal when logged to the console?

I’m trying to construct a table dynamically, with a size determined by the current width of the browser window.

Since the table cells’ sizes and their containing div’s size are both being set relative to the window’s width, the cells should fit exactly within the div. This is working perfectly for the width, but not for the height. The last row of cells appears to overhang the bottom of the div by a fractional amount.

Logging the sizes of the div and one of the table cells shows that they ought to align correctly, as the cell’s height is exactly 1/10 of the div’s height, and there are 10 rows of cells. However, the visual doesn’t match, even though the math works out as expected.

What is causing the discrepancy between the calculated and displayed heights?

const pageWidth = document.documentElement.scrollWidth;
const nRows = 10; const nColumns = 10;
const tableDiv = document.getElementById("tableDiv");
tableDiv.style.width = 0.7*pageWidth + "px";
tableDiv.style.height = 0.7*pageWidth + "px";
tableDiv.style.backgroundColor = "yellow";
        
// Dynamically generate a table of the specified dimensions
function constructTable(nR, nC) {
    const tbl = document.createElement("table"); tbl.id = "test table";
    var tRow; var tCell;
    for (let r = 0; r < nR; r++) { // Use 'let,' not 'var,' or else all row/column numbers will be set to the final (maximum) values of r and c
        tRow = document.createElement("tr");
        tbl.appendChild(tRow);
        for (let c = 0; c < nC; c++) {
            tCell = document.createElement("td"); tCell.className = "testing"; tRow.appendChild(tCell);
        }
    }
    return tbl;
}
        
function showTable(t) {
    tableDiv.innerHTML = "";
    tableDiv.appendChild(t);
    const dynamicSizeCells = document.getElementsByClassName("testing");
    for (var i = 0; i < dynamicSizeCells.length; i++) {
        dynamicSizeCells[i].style.width = 0.7*pageWidth/nColumns + "px";
        dynamicSizeCells[i].style.height = 0.7*pageWidth/nRows + "px";
        dynamicSizeCells[i].style.backgroundColor = "green";
    }
    console.warn("Div width is " + tableDiv.style.width + ", div height is " + tableDiv.style.height + "; cell width is " + dynamicSizeCells[0].style.width + ", cell height is " + dynamicSizeCells[0].style.height);
}
        
const theTable = constructTable(nRows, nColumns);
showTable(theTable);
body {
    background-color: darkblue;
}
#tableDiv {
    margin-left: 15%;
    margin-top: 5%;
}
.testing {
    background-color: "green";
}
<div id="tableDiv"></div>

Using Google App Script to update spreadsheet from gmail, javascript not running

I’m trying to update my file status on spreadsheet from “past due” to “ready”, and i want to do so by letting user click a modal sent through gmail that confirm the file’s status will be changed.
When running the script, email is sent and I am able to see the modal, however clicking “yes” button which should update the file status on spreadsheet, does not work. I added some console log but nothing shows up (like javascript isn’t running at all), and only
“1904984383-warden_bin_i18n_warden.js:120 Net state changed from IDLE to BUSY
1904984383-warden_bin_i18n_warden.js:120 Net state changed from BUSY to IDLE” shows up. But innerHTML changes when clicking “yes”. I am very confused, any help is appreciated, here the code snippet:

<body onload="load()">
  <!-- The Modal -->
  <div id="modalDiv" class="modal">

    <!-- Modal content -->
    <div class="modal-content">
      <div id="question">
        <p>Are you sure the review of <span style="color:rgb(0,120,211);"><?= getDocument_()['name'] ?></span> has finished and its content is up to date?</p>
        <button id="yes">Yes</button>
        <button id="no">No</button>
      </div>
    </div>

  </div>
  <script>
    console.log("JavaScript is running!");
    const modal = document.getElementById("modalDiv");
    console.log("Modal Element:", modal);
    const yesBtn = document.getElementById("yes");
    console.log("Yes Button:", yesBtn);
    const noBtn = document.getElementById("no");
    console.log("No Button:", noBtn);
    const question = document.getElementById("question");
    const content = document.getElementsByClassName("modal-content")[0];

    const load = function () {
      console.log("Modal loaded.");
      modal.style.display = "block";
    }

    yesBtn.addEventListener('click', () => {
      alert("Yes button clicked!");
      console.log("Yes button clicked.");
      question.style.display = "none";
      const yesResponse = document.createElement('p');
      yesResponse.innerHTML = 'Thanks for completing the review/update of the   document. We have updated the status of your document <span style="color:rgb(0,120,211);"><?= getDocument_()['name'] ?></span> to Ready and reset your next review date. You will no longer receive notifications for this review period. Have a great day!';
      content.appendChild(yesResponse);
      
      try {
      const documentData = <?= JSON.stringify(getDocument_()) ?>;
      console.log("Sending document data to setDocumentAsReady:", documentData);

      if (!documentData.name || !documentData.url) {
        console.error("Error: Document data is missing!", documentData);
        return;
      }

      google.script.run
        .withSuccessHandler(() => console.log("setDocumentAsReady() executed successfully."))
        .withFailureHandler(error => console.error("Error calling setDocumentAsReady:", error))
        .setDocumentAsReady(documentData);

    } catch (err) {
      console.error("JavaScript Error:", err);
    }

      // google.script.run.setDocumentAsReady(<?= JSON.stringify(getDocument_()) ?>);
    });

    noBtn.addEventListener('click', () => {
      console.log("No button clicked.");
      question.style.display = "none";
      const noResponse = document.createElement('p');
      noResponse.innerHTML = 'Ok. Please come back again when the review of <span style="color:rgb(0,120,211);"><?= getDocument_()['name'] ?></span> finishes and its content is up to date';
      content.appendChild(noResponse);      
    });

  </script>
</body>`
function setDocumentAsReady(documentStr) {
  try {
    console.log(`setDocumentAsReady received request: ${documentStr}`);
    const documentObj = JSON.parse(documentStr);
    console.log(`Setting document ${documentObj.name} with url ${documentObj.url} as Ready`)
    const scriptProperties = PropertiesService.getScriptProperties();
    scriptProperties.setProperty(documentObj.url, 'Ready');    
  } catch (err) {
    console.log(`Failed with error ${err.message}`)
  }
}

I suspect there is something wrong in setDocumentAsReady(), so I tried adding in console.log(setDocumentAsReady received request: ${documentStr}); and it gives me back: setDocumentAsReady received request: undefined, so it means frontend is not documenting the file that needs to be updated

I also tried clicking “yes” in modal to update file status, then rerunning the script, but spreadsheet still isn’t updated.

How can I handle Tone.js pitch shifting with multiple articulations and dynamics?

I am creating a Digital Audio Workspace in nextjs. I have audio samples for every third note of each instrument, and luckily Tone.js automatically handles this:

“Multiple samples can also be combined into an instrument. If you have audio files organized by note, Tone.Sampler will pitch shift the samples to fill in gaps between notes. So for example, if you only have every 3rd note on a piano sampled, you could turn that into a full piano sample.”

The problem is, I also have different articulations and dynamics for each note. Just for violin theres multiple articulations, and then each articulation has a different dynamic. If I want to take advantage of the automatic pitch shifting the keys have to be exact note names like C3 or A4, but these can only map to one sound file and I have multiple.

I also considered using Tone.PitchShift to do the shifting manually but it seems that is only for pitching an entire audio channel and I need many different notes pitched differently simultaneously. My choices from what I know at this point seem to be 10s of samplers, 10s of pitch shift channels, or to speed up/ slow down the audio which I also dont want to do. Is there a performant solution to this problem?

Example:

// if a#3 is played, the g3 sample should play pitched up by 3 semitones
0: {lowkey: 'g3', highkey: 'a#3', key: 'g3', file: 'instrumentSounds/Samples/1st Violins/1st-violins-col-g3-p.mp3', dynamic: 'p'}
// here is the same but at a different dynamic level. If i want to use automatic pitch shifting there can only be one g3. Also this is only for one articulation (col legno) and there are many combinations
1: {lowkey: 'g3', highkey: 'a#3', key: 'g3', file: 'instrumentSounds/Samples/1st Violins/1st-violins-col-g3-pp.mp3', dynamic: 'pp'}

cv is undefined using jscanify v1.4.0

I’m trying to use Javascript to extract and unwarp a picture of a piece of paper.

Running on Node.js v22.13.1 w/ jscanify v1.4.0, this is my main.js file.

When run through node main.js, the following snippet keeps raising a “cannot read property of undefined” error:

const imageProcessor = require('jscanify');
const { loadImage } = require('canvas');
const fileSystem = require('fs');

const processor = new imageProcessor();

loadImage('images/test.png').then((originalImage) => {
    // extract and highlight the papers
    const paperExtracted = processor.extractPaper(originalImage, 50, 100);
    const paperHighlighted = processor.highlightPaper(originalImage);

    // convert result to JPG file
    const extractedBuffer = paperExtracted.toBuffer('image/jpeg');
    const highlightedBuffer = paperHighlighted.toBuffer('image/jpeg');

    // write it to file
    fileSystem.writeFileSync('images/test-extracted.png', extractedBuffer);
    fileSystem.writeFileSync('images/test-highlighted.png', highlightedBuffer);
});

The full stack trace:

C:...node_modulesjscanifysrcjscanify-node.js:155
    const img = cv.imread(image);
                   ^

TypeError: Cannot read properties of undefined (reading 'imread')
    at jscanify.extractPaper (C:...node_modulesjscanifysrcjscanify-node.js:155:20)
    at C:...main.js:8:38
    at process.processTicksAndRejections (node:internal/process/task_queues:105:5)

I’m not quite familiar with this library. It appears that cv is undefined, which makes no sense to me. Any ideas on how to fix this?