Load .csv file in drop down list (search field) – how to?

I’m more a designer than a developer. With this being said, here’s my question:
Anyone knows how to fill a search field (first item) in a drop down list with content from a .csv file?

I have made a website and I want to add values (all municipalities from the site plan) from a .csv file that loads when I search a region from my drop down. I guess you will understand when you see the example on my homepage.

The issue at the moment is that the drop down list search tool only suggests items from the menu (list). I would like to add the possibility to search a .csv file and suggest items from that file (all municipalities from our site plan… There are about 300 municipalities). So when the user would start typing a municipality… Montreal for example, the list would show all municipalities starting with Montreal… Like Montreal-Est… Montreal-Ouest… Etc. These are not in the menu (list) but would be in the .csv file.

I thank you in advance for any idea that you could share.

Kind Regard,

Jacques

How to encrypt and encode using crypto-js library?

I am trying to encrypt the string using secret key with the help of crypto-js, there are two issues one its always generating same key which is not expected it shoud be unique eveytime , and second issue is the size of the encrypted key is longer than expected i am trying to print this format and size GwJPNUfPXZZsuc0iqOFhn%2BYhMJKxXBUYl9g3iKqL8CE%3D this always contain 2 percent special character in it.

trying encrpt with sha256 and do the encoding and return the above pattern any help ?

index.js 

const CCrypto = require('crypto-js');

function encryptSHA256(data, secretKey) {
    const secretKeyWordArray = CCrypto.enc.Utf8.parse(secretKey);
    return CCrypto.AES.encrypt(data, secretKeyWordArray, {
        mode: CCrypto.mode.CBC,
        padding: CCrypto.pad.Pkcs7,
        iv: CCrypto.lib.WordArray.create([0]),
    }).toString();
}

function generateEncryptedValue(paymentId, specialtyID, secretKey) {
    const concatString = paymentId.toString() + "_" + specialtyID;
    const encryptedResult = encryptSHA256(concatString, secretKey);
    const base64Result = CCrypto.enc.Base64.stringify(CCrypto.enc.Utf8.parse(encryptedResult));
    const percentEncodedResult = encodeURIComponent(base64Result);
    return percentEncodedResult;
}

// Example usage
const paymentId = 15680298; // paymentId is a number
const specialtyID = '8018290';
const secretKey = "EiD0BVQle0xFjZvYOupQsXCWAcAwBaTjlZ7G7rryNos=";
const result = generateEncryptedValue(paymentId, specialtyID, secretKey);
console.log('Encrypted and Percent Encoded Result:', result);

How do I make an onclick function to stop an animation and start a new one?

I have currently a rocket animation that moves continuously and I want to make it so that when a button is clicked, the moving animation stops and a new animation starts where the rocket flies straight up and navigates the user back to the home page. However I don’t know how to do a onclick function where it stops the current animation and starts the new one. What’s the best approach to do that?

HTML

<div id='FixedSection'>
      <button id='TextBox'>
        <div class='scene'>
          <div class='rocket'>
            <img id='Rocket' src='rocket.png'>
          </div>
        </div>
        <br><br>
        <p id='PopUpMessage'>
          <strong>Thank you for your submission!</strong>
          <br><br> Your response has been received successfully. We appreciate your participation.
        </p>
        <img src='PopUp.png' id='PopUpButton' onclick="flyRocket()">
        <a href='../Website Codes - Main Page/Main Page.html' class='HyperReference' onclick="flyRocket()">
          <p id='PopUpOption'>
            <strong> Return to home </strong>
          </p>
        </a>
      </button>
</div>

CSS

#Rocket {
  height: 100px;
  width: 50px;
}

.scene .rocket {
  position: relative;
  animation: animate 0.5s ease infinite;
}

@keyframes animate {
  0%, 100% {
    transform: translateY(-4px);
  }
  50% {
    transform: translateY(4px);
  }
}

.scene .rocket::before {
    content: '';
    position: absolute;
    bottom: -40px;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 50px;
    background: linear-gradient(#00d0ff, transparent);
}

.scene .rocket::after {
    content: '';
    position: absolute;
    top: 5;
    left: 50%;
    transform: translateX(-50%);
    width: 10px;
    height: 50px;
    background: linear-gradient(#00d0ff, transparent);
    filter: blur(20px);
}

if condition isn’t executed even thought the condition satisfies

 const handleApproveOpen = (item) => {

setItem(item);

console.log('item', item.approver1, 'empid', empid)
console.log('s', item?.isApprover1)
if (item?.approver1 === empid && item?.isApprover1 === false) {
  console.log('approver1')
  setIsApprover1(true)
  setIsApprover2(item?.isApprover2)
  setIsApprover3(item?.isApprover3)
  setIsApprover4(item?.isApprover4)

}
if (item?.approver2 === empid && item?.isApprover2 === false) {
  console.log('approver2')
  setIsApprover2(true)
  setIsApprover1(item?.isApprover1)
  setIsApprover3(item?.isApprover3)
  setIsApprover4(item?.isApprover4)

}
if (item?.approver3 === empid && item?.isApprover3 === false) {
  setIsApprover3(true)
  setIsApprover1(item?.isApprover1)
  setIsApprover2(item?.isApprover2)
  setIsApprover4(item?.isApprover4)

  console.log('approver3')
}
if (item?.approver4 === empid && item?.isApprover4 === false) {
  console.log('approver4')
  setIsApprover4(true)
  setIsApprover2(item?.isApprover2);
  setIsApprover3(item?.isApprover3)
  setIsApprover1(item?.isApprover1)
}

setOpenApprove(true)

}

const handleApproveClose = () => {

setOpenApprove(false)

}

const handleSet = async (item) => {

}

const handleApprove = async () => {
console.log(item?.isApprover1)

console.log('item', item)


try {
  console.log('isAPrrover1', isApprover1)
  console.log('isAPrrover2', isApprover2)
  console.log('isAPrrover3', isApprover3)
  console.log('isAPrrover4', isApprover4)
  console.log(item?.approver2, empid, item?.isApprover2)
  console.log(typeof (item?.isApprover2), typeof (item?.isApprover3), typeof (item?.isApprover4))



  const data = {
    purchaseRequisitionNo: item?.purchaseRequisitionNo,
    supplierCode: item?.supplierCode,
    supplierName: item?.supplierName,
    departmentCode: item?.departmenttCode,
    departmentName: item?.departmentName,
    address: item?.address,
    state: item?.state,
    city: item?.city,
    pincode: item?.pincode,
    purchaseRequisitionDate: item?.purchaseRequisitionDate,
    deliveryDate: item?.deliveryDate,
    approver1: item?.approver1,
    approver2: item?.approver2,
    approver3: item?.approver3,
    approver4: item?.approver4,
    isApprover1: isApprover1,
    isApprover2: isApprover2,
    isApprover3: isApprover3,
    isApprover4: isApprover4,
    mobileNo: item?.mobileNo,
    remark: item?.remark,
    purchaseRequisitionLists: item?.purchaseRequisitionLists,
    id: item?.id
  }

  const res = await serverInstance('store/edit-purchaseRequisition ', 'put', data)
  if (res.status) {

    setOpenApprove(false)
    Swal.fire('Approved!', res.msg, 'success')

  }

  if (res.status === false) {
    setOpenApprove(false)
    Swal.fire('Error!', res?.msg, 'error')
  }

} catch (err) {
  Swal.fire('Error!', 'Something went wrong', 'error')
  console.log(err)
}

}

I have a approver system wher i have 4 approver there are two fields approver 1,2 ,3.4 .adn isapprover1,2… fields in the database in approver 1,2… i have saved the empID(employeeID) and in isApprover1,2..i will save the data in boolean if that approver has approved or not but the result im getting is unexpected.

The if condition doesn’t gets executed even though the conditions are met.

Am i doing something wrong trying to style using focus-within and Tailwind?

i’m trying to style the label of an input using the pseudo-class “focus-within” with Tailwind but it doesn’t seems to work. Here’s the code (it’s part of a React component) :

            <label className='focus-within:text-primary mb-2 font-medium text-sm text-secondary'>{label}</label>
            <div className='relative'>
                <input
                    className={`${width} h-12 text-center text-sm text-secondary p-2 border-2 border-primary outline-none rounded-[12px] focus:shadow-focus transition-shadow duration-300`}
                    type={getPasswordInputType()}
                />
                {isPassword && (
                    <div className='absolute top-3 right-3 bg-white cursor-pointer' onClick={togglePasswordVisibility}>
                        {showPassword ? (
                            <EyeIconOpen />
                        ) : (
                            <EyeIconClosed />
                        )}
                    </div>
                )}
            </div>

Am i doing something wrong here ?

Nonce verification fails on second ajax request, why?

I am trying to update the user password through a ‘form’, everything works correctly. However, if I try to update the password again without reloading the page, the nonce verification fails and I can’t understand why. I have tried regenerating the nonce but it doesn’t solve the problem. The only thing that allows the nonce verification to pass for subsequent requests is refreshing the tab of my plugin or the entire page, but the goal here is to update the user data without reloading the page.

The first request is successful and the page is updated but subsequent ones fail:

// 1. nonce verification
      if ( ! isset($_POST['security_nonce']) || ! wp_verify_nonce( $_POST['security_nonce'], 'update_user_security_nonce' ) ) {
         // Nonce invalido, mostra un messaggio d'errore
         $error_message = $this->get_message_html('error', 'Nonce Verification Failed');
         wp_send_json_error(array('message' => $error_message));
         return;
      }

P.S: My form is dynamically loaded with an ajax request because it is located within a specific tab of my plugin.

Handle_User_Form.php

// Handle Ajax Request server side
   public function update_security_password() {
      
      // Password Var...
      $current_password = sanitize_text_field($_POST['current_password']);
      $new_password = sanitize_text_field($_POST['new_password']);
      $confirm_password = sanitize_text_field($_POST['confirm_password']);
      $passwordRegex = '/^(?=.*[a-z])(?=.*[A-Z])(?=.*d)(?=.*[@$!%*#?&])[A-Za-zd@$!%*#?&]{8,}$/';

      // 1. nonce verification
      if ( ! isset($_POST['security_nonce']) || ! wp_verify_nonce( $_POST['security_nonce'], 'update_user_security_nonce' ) ) {
         // Nonce invalido, mostra un messaggio d'errore
         $error_message = $this->get_message_html('error', 'Nonce Verification Failed');
         wp_send_json_error(array('message' => $error_message));
         return;
      }

      // 2. other verification
      if (empty($current_password)) {
         $error_message = $this->get_message_html('error', 'msg error');
         wp_send_json_error(array('message' => $error_message));
         return;
      }

      // 3. other verification
      if (empty($new_password)) {
         $error_message = $this->get_message_html('error', 'msg error');
         wp_send_json_error(array('message' => $error_message));
         return;
      }
     
      // 4. other verification
      if (!empty($current_password)) {
         $user = get_user_by('id', get_current_user_id());
         
         // Se la password attuale è corretta procedi con i controlli sottostanti
         if ($user && wp_check_password($current_password, $user->data->user_pass, $user->ID)) {
            
            // Se new_password è diversa da confirm_password mostra un msg d'errore
            if ($new_password !== $confirm_password) {
               $error_message = $this->get_message_html('error', 'msg error');
               wp_send_json_error(array('message' => $error_message));
               return;
            }

            // other verification
            if ($new_password === $current_password) {
               $error_message = $this->get_message_html('error', 'msg error.');
               wp_send_json_error(array('message' => $error_message));
               return;
            }
            
            // regex verification
            if (!empty($new_password) && !preg_match($passwordRegex, $new_password)) {
               $error_message = $this->get_message_html('error', 'msg error.');
               wp_send_json_error(array('message' => $error_message));
               return;
            }

         } else {
            $error_message = $this->get_message_html('error', 'msg error.');
            wp_send_json_error(array('message' => $error_message));
         }
      }

      // Array with new data
      $userdata = array( 
         'ID' => get_current_user_id(), 
      );

      // Update Data
      $user_id = wp_update_user( $userdata );

      // Update correctly
      if ( !is_wp_error( $user_id ) ) {
         // Restituisci un messaggio di successo
         wp_send_json_success( array(
            'message' => $this->get_message_html('success', 'Updated.')));
      } else {
         // If update fail
         wp_send_json_error( array('message' => $this->get_message_html('error', $user_id->get_error_message())));
      }
   }

User_Form.js

jQuery(document).ready(function($) {

   $(document).on('click', '#update_password_btn', function() {

      var current_password = $('#current_password').val();
      var new_password = $('#new_password').val();
      var confirm_password = $('#confirm_password').val();
      var security_nonce = $('#security_nonce').val();

      // Data Object
      var data = {
         action: 'update_security_password', // Sostituisci con l'azione corretta
         current_password: current_password,
         new_password: new_password,
         confirm_password: confirm_password,
         security_nonce: security_nonce,
      };

      // Ajax Request
      $.ajax({
         url: adminAjax.ajax_url,
         type: 'POST',
         dataType: 'json',
         data: data,
         success: function(response) {
            // Controlla se la risposta ha successo.
            if (response.success) {  
              
               // Success Message
               $('#info_message').attr('class', 'success').html(response.data.message).show();

               // Clear Password Field
               $('#current_password').val('');
               $('#new_password').val('');
               $('#confirm_password').val('');
     
            } else {
               // Error Message
               $('#info_message').attr('class', 'error').html(response.data.message).show();
               vibrate(document.getElementById('info_message'));
            }
         },
         error: function(xhr, textStatus, errorThrown) {
            // Handle Other Error
            console.error('Errore AJAX:', textStatus, errorThrown);
            $('#info_message').attr('class', 'error').html('Errore nella richiesta, riprova.').show();
         }
      }); 
   });
});

Template_User_Form.php

<!-- Dati D'accesso -->
   <div class="wrap_form_block">

      <!-- Campo Nonce -->
      <input type="hidden" id="security_nonce" name="security_nonce" value="<?php echo wp_create_nonce('update_user_security_nonce'); ?>">

   <!-- Update Password Section -->
   <div class="wrap_form_block password">
      
      <!-- Campi per la modifica della password -->
      <div class="container_form_fields">
         <div class="form_fields">
            <label for="current_password">Current Attuale</label>
            <div class="wrap-input">
               <input class="password-input" id="current_password" type="password" name="current_password" />
               <span class="toggle-password fa-light fa-eye"></span>
            </div>   
         </div> 

         <div class="form_fields">
            <label for="new_password">New Password</label>
            <div class="wrap-input">
               <input class="password-input" id="new_password" type="password" name="new_password" />
               <span class="toggle-password fa-light fa-eye"></span>
            </div>
            <div id="password-strength"></div>
         </div>  

         <div class="form_fields">
            <label for="confirm_password">Confirm Password</label>
            <div class="wrap-input">
               <input class="password-input" id="confirm_password" type="password" name="confirm_password" />
               <span class="toggle-password fa-light fa-eye"></span>
            </div>
         </div>
      </div>

      <!-- Update Button -->
      <div class="wrap_form_button">
         <button class="btn_m button_blue" type="button" id="update_password_btn">Salva Modifica Password</button>
      </div>
   </div>

“Failed to load resource: net::ERR_FILE_NOT_FOUND ” while creating chrome extension

I want to import and use a function in popup.js from fetchTabDataFunc , but when I try to do so it shows me the error “Failed to load resource: net::ERR_FILE_NOT_FOUND”

Things that I have done.

In my html file (popup.html) I have added <script src="popup.js" type ="module" ></script>, in which I have added the attribute type=”module” to connect the js file with html file.

My manifest.json file

 {
  "name": "club-tab",
  "description": "to club active tabs",
  "version": "1.0.0",
  "manifest_version": 3,
  "background": {
    "service_worker": "background.js",
    "type": "module"
  },
  "action": {
    "default_popup": "popup.html"
  },
  "permissions": ["tabs", "activeTab"],
  "host_permissions": ["http://*/*", "https://*/*"]
}

My folder structure is as follow:
file structure

fetchTabDataFunc file code

const  fetchTabDataFunc = async ( linkContainer)=>{
    try {
        console.log("i am in fetch func")
        const response = await chrome.tabs.query({});
        tabData = await response
        const ul = document.createElement('ul');
        linkContainer.appendChild(ul)
        if (tabData) {
            ul.innerHTML = tabData.map((tab) => {
                return `<li>${tab.title}</li>`
            }).join('')
        }
        console.log(tabData);
    } catch (error) {
        console.log(error);
    }
}

export default fetchTabDataFunc

popup.js file code

import fetchTabDataFunc from "./fetchTabDataFunc";
const btn = document.querySelector('.btn');
const linkContainer = document.querySelector('.link-container');

let tabData = [];


btn.addEventListener('click', async () => {
    console.log("i am in popup.js btn")

    if (tabData.length == 0) {
        fetchTabDataFunc(linkContainer)
    }

});

How to modify the content and CSS of a HTML element when another HTML element is active

On my website I have a hamburger menu button that brings up a full-screen white background when clicked.

My issue is that when this white background is active, you cannot see my site logo because that is also white.

Therefore, I want to change the site logo image to one that is a different colour so that it stands out against the white background when the hamburger menu is active. When the hamburger menu is active I also want to modify the CSS of the site logo.

I’m wondering whether this functionality can be achieved using just CSS, but I presume that JS is needed here? I have basic CSS knowledge and very very basic JS knowledge, and so would be grateful if someone could help me out with this.

Thanks and please let me know if I have explained myself clearly!

I tried changing the element when the hamburger menu is active using the :active psuedo-class . I have very basic web design knowledge and so require help.

The requested module ‘./models/User.js’ does not provide an export named ‘User’ [duplicate]

I’m getting this error when I import a module into my index file. I feel like this is a very simple fix but I can’t seem to figure it out. Anyone spot what I’m doing wrong?

File Structure:

├──models

├ ├──User.js

├──index.html

import { User } from './models/User.js'
         ^^^^
SyntaxError: The requested module './models/User.js' does not provide an export named 'User'
    at ModuleJob._instantiate (node:internal/modules/esm/module_job:132:21)
    at async ModuleJob.run (node:internal/modules/esm/module_job:214:5)
    at async ModuleLoader.import (node:internal/modules/esm/loader:329:24)
    at async loadESM (node:internal/process/esm_loader:28:7)
    at async handleMainPromise (node:internal/modules/run_main:113:12)

User.js

// https://mongoosejs.com/docs/geojson.html
import mongoose from 'mongoose'

const pointSchema = new mongoose.Schema({
    type: {
        type: String,
        enum: ['Point'],
        required: true
    },
    coordinates: {
        type: [Number],
        required: true
    }
});

const UserSchema = new mongoose.Schema({
    username: { default: 'guest' },
    location: {
        type: pointSchema,
        required: true
    }
});

const User = mongoose.model("User", UserSchema)
module.exports = User 

index.js

import express from "express";
import axios from 'axios'
import { User } from './models/User.js'
...

Get IV from Django backend

I want to obtain IV from Python backend to Sveltekit and use it to check if the token is the same. I use CryptoJS and pycryptodome. Key is the same.

Python:

key =  bytes(os.environ['KEY'], "utf-8")
iv = None
def generate_iv():
    rand = os.urandom(4)
    return struct.unpack('B' * len(rand), rand)

    
def encrypt(username, password):
    global iv
    if iv == None:
        iv = generate_iv()
    byte_data = b''.join(struct.pack('<I', index) for index in iv)
    cipher = AES.new(key, AES.MODE_CBC, iv=byte_data)
    data = f"{username}:{password}".encode()
    padded_data = pad(data, AES.block_size, style='pkcs7')
    encrypted_data = cipher.encrypt(padded_data)
    print(base64.b64encode(encrypted_data).decode('utf-8'))
    return base64.b64encode(encrypted_data).decode('utf-8')

class IV(APIView):
    def get(self, request):
        global iv
        if iv == None:
            iv = generate_iv()
        return Response({'iv': f'{iv}'}, status=status.HTTP_200_OK)

JS:

let iv;
  let numbers = [];
  onMount(async () => {
    const response = await fetch("http://127.0.0.1:8000/api/authapi/iv");
    const data = await response.json();
    const ivNumbers = data.iv.slice(1, -1).split(",").map(Number);
    numbers = ivNumbers;
    console.log(numbers);
    iv = CryptoJS.lib.WordArray.create(new Uint8Array(numbers));
    console.log(iv);
  });

  function encrypt(username, password) {
    const key = "pR@QvK3oM&9t#S8X";
    const data = `${username}:${password}`;
    const encryptedData = CryptoJS.AES.encrypt(
      data,
      CryptoJS.enc.Utf8.parse(key),
      {
        mode: CryptoJS.mode.CBC,
        padding: CryptoJS.pad.Pkcs7,
        iv: iv,
      }
    );
    console.log(encryptedData.toString());
    return encryptedData.toString();
  }

My API responds with e.g.:

{
    "iv": "(246, 72, 5, 222)"
}

But the outcome returns two different values

data: fA6ifpnK8NCLBRi7EYPf4zyDumGFeBwVnZC0vliN06I= (from JS)

token: PAwNhCecq4lJRKizJWCMhknk9gleAPRXV2owj29XD2k= (actual token)

Refused to execute inline script because it violates the following CSP directive

I am trying to integrate Stripe to my website, the problem is that I receive the following error:

js.stripe.com/v3/hcaptcha-invisible-078b5f9fb44d244a9ec072f93a216630.html#debugMode=false&parentOrigin=http%3A%2F%2Flocalhost:3 [Report Only] Refused to execute inline script because it violates the following Content Security Policy directive: “script-src ‘self'”. Either the ‘unsafe-inline’ keyword, a hash (‘sha256-CBu0w5uiOaPgb2R6Zgf7E0+STJHF4lcPIdhZzQXE6yk=’), or a nonce (‘nonce-…’) is required to enable inline execution.

I tried to solve it using the Stripe directives in this way but because the location of the file that is given the error is on the Stripe server, I think that those rules of the are not applied to that file.

I have made other integrations of give the same approach error to make sure, and I have solved it by putting the directives in the and it works, but I have not been able to solve the error described above.

If you want to see the same error, you just have to go to this Stripe link and inspect the browser in the console.

Link

Cursor coordinates when zooming canvas js

Good afternoon!
When writing the function of scaling inside the canvas there was a problem with the calculation of coordinates. If the cursor is in the center of the canvas, scaling occurs evenly in all directions, but if the cursor is in any other point, the image is scaled incorrectly and goes to the side. What is the correct way to redefine the coordinates so that at any position of the cursor the image is scaled evenly in all directions?

function scale() {
        var canvas = document.getElementById('canvas');
        var context = canvas.getContext('2d');
        const canvas_width = document.documentElement.scrollWidth;
        const canvas_height = document.documentElement.scrollHeight;

        canvas.addEventListener("wheel", onmousewheel, false);
        canvas.addEventListener("DOMMouseScroll", onmousewheel, false);
    
        var position = {x: 0, y: 0};
    
        function onmousewheel(event) {
            var x = event.clientX - position.x + canvas_width/2;
            var y = event.clientY - position.y + canvas_height/2;
            const delta = event.type === "wheel" ? event.wheelDelta : -event.detail;
            const increment = delta > 0 ? 1.1 : 0.9;
    
            const previous_scale = scale;
            scale *= increment;
    
            position.x -= x * (scale / previous_scale - 1);
            position.y -= y * (scale / previous_scale - 1);

            context.clearRect(0, 0, canvas.width, canvas.height);
            context.setTransform(scale, 0, 0, 0, scale, position.x, position.y);
            CANVAS.draw(); // separate function for drawing all elements on the canvas
            event.preventDefault();
        }
    }

Also interested, how can I make the animation of the canvas at the moment of zooming smoother and without sharp jerks?

Thank you in advance for the answer.

Commercelayer drop-in.js acessToken error [duplicate]

enter image description hereI am trying to setup Commercelayer drop-in.js and can not fix error : SdkError: Undefined 'accessToken' parameter.

Docs in https://commercelayer.github.io/drop-in.js/?path=/docs/getting-started--docs maybe not correct. Something dont make sense.

Here you have my sample file with truncated clientId and scope from commercelayerConfig object.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    
</head>
<body>
<cl-price code="TSHIRTMS000000FFFFFFLXXX">
    <cl-price-amount></cl-price-amount>
</cl-price>

<cl-price code="5PANECAP000000FFFFFFXXXX">
    <cl-price-amount type="compare-at"></cl-price-amount>
    <cl-price-amount type="price"></cl-price-amount>
</cl-price>

<script type="module" src="https://cdn.jsdelivr.net/npm/@commercelayer/[email protected]/dist/drop-in/drop-in.esm.js"></script>
<script>

    (function() {
        window.commercelayerConfig = {
            clientId: 'jkhdsjkh',
            slug: 'drop-in-js',
            scope: 'market:11196',
            debug: 'all', // default is 'none'
            orderReturnUrl: 'https://example.com', // optional
        }
    }());
</script>
</body>
</html>

CommerceLayer , drop-in.js AcessToken

I am trying to setup Commercelayer drop-in.js and can not fix error : SdkError: Undefined 'accessToken' parameter.

Docs in https://commercelayer.github.io/drop-in.js/?path=/docs/getting-started--docs maybe not correct. Something dont make sense.

Here you have my sample file with truncated clientId and scope from commercelayerConfig object.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    
</head>
<body>
<cl-price code="TSHIRTMS000000FFFFFFLXXX">
    <cl-price-amount></cl-price-amount>
</cl-price>

<cl-price code="5PANECAP000000FFFFFFXXXX">
    <cl-price-amount type="compare-at"></cl-price-amount>
    <cl-price-amount type="price"></cl-price-amount>
</cl-price>

<script type="module" src="https://cdn.jsdelivr.net/npm/@commercelayer/[email protected]/dist/drop-in/drop-in.esm.js"></script>
<script>

    (function() {
        window.commercelayerConfig = {
            clientId: '2E5DNf5rXy8mi6IcvboaD2HUotCuC6fQqYH5PHz8RlM',
            slug: 'drop-in-js',
            scope: 'market:16496',
            debug: 'all', // default is 'none'
            orderReturnUrl: 'https://example.com', // optional
        }
    }());
</script>
</body>
</html>

Cannot read properties of undefined (reading ‘onClicked’)

I am creating an extension and for starter I want to print “hello world” (as of now), when user click on the icon of my extension.

I created a popup.js file and wrote the following code

chrome.browserAction.onClicked.addListener('click', ()=>{
console.log("hello world")
 })

then i was faced with the error “Cannot read properties of undefined (reading ‘onClicked’)” when i try to click my extension icon. Don’t know what to do now.

Can chrome.browserAction.onClick.addEventListener() cannot run in popup.js script??

Here’s my manifest.json file of the chrom extension.
P.S I have linked popup.js file with my popup.html file.

{
 "name": "club-tab",
  "description": "to club active tabs",
 "version": "1.0.0",
  "manifest_version": 3,
  "background": {
  "service_worker": "background.js",
  "type": "module"
},
  "action": {
  "default_popup": "popup.html"
 },
 "permissions": ["tabs", "activeTab"],
 "host_permissions": ["http://*/*", "https://*/*"]
}