My website appears for few mili seconds then preloader then website

My website preloader is not showing properly first the website appears for a few mili seconds then preloader then the website.

I am using Elementor WordPress, I have added the preloader code in my theme file editor here is the code snippet

“add_action(‘wp_footer’, ‘Allprocoding_Preloader’);

function Allprocoding_Preloader() {
if (!is_admin() && $GLOBALS[“pagenow”] !== “wp-login.php”) {

    $delay = 1; // seconds
    $desktop_loader = 'https://spoky.co/wp-content/uploads/2024/02/Group-1171275193-1.gif';
    $mobile_loader = 'https://spoky.co/wp-content/uploads/2024/02/mobile-.gif';
    $overlayColor = '#ffffff';
    ?>
    <script>
        document.addEventListener("DOMContentLoaded", function () {
            var preloader = document.createElement('div');
            preloader.style.position = 'fixed';
            preloader.style.top = '0';
            preloader.style.bottom = '0';
            preloader.style.left = '0';
            preloader.style.right = '0';
            preloader.style.backgroundColor = '<?php echo esc_js($overlayColor); ?>';
            preloader.style.zIndex = '100000';
            preloader.style.display = 'flex';
            preloader.style.alignItems = 'center';
            preloader.style.justifyContent = 'space-around';

            var loaderImg = document.createElement('img');
            loaderImg.src = '<?php echo esc_url($desktop_loader); ?>';
            loaderImg.alt = '';
            loaderImg.style.height = '30vw';

            preloader.appendChild(loaderImg);
            document.body.appendChild(preloader);

            document.body.style.overflow = "hidden";
            var mediaQuery = window.matchMedia("only screen and (max-width: 760px)");

            function handleMediaChange(event) {
                if (event.matches) {
                    loaderImg.src = '<?php echo esc_url($mobile_loader); ?>';
                    loaderImg.style.height = '20vw';
                } else {
                    loaderImg.src = '<?php echo esc_url($desktop_loader); ?>';
                    loaderImg.style.height = '15vw';
                }
            }

            mediaQuery.addListener(handleMediaChange);
            handleMediaChange(mediaQuery);

            window.addEventListener("load", function () {
                // Remove the preloader after the delay
                setTimeout(function () {
                    preloader.remove();
                    document.body.style.overflow = "visible";
                }, <?php echo esc_js($delay * 1000); ?>);
            });
        });
    </script>
    <?php
}

}

what to do to make the prelaoder appears perfectly fine

I have tried adding code to inline css and and preload css and JavaScript files but there is no change in the scenario. What are other possible ways to figure out this issue?

When loggin in with Cypress, I get a 403 error related to a CSRF token

I get a 403 while using Cypress custom commands to login into a webpage I’m testing.

If I log in manually, it doesn’t returns any kind of error, but with Cypress I always get the same state:

“403 Forbiden

Login Failed: Unable to find a valid CSRF token. Please try again.

Request ID: f88dd507-22e4-4776-9113-d2e5fbc3f8ec”

Gladly, there’s a “Login” button at the page that allows me to continue:

403 error

So, I think I must create a test with any cookies used at the moment of the login to bypass this issue?

Here’s the test I’m doing:

Cypress.Commands.add('login', (email, password) => {
    cy.session([email, password], () => {
       cy.visit('baseURL')
       cy.get('[data-test="email"]').type(email);
       cy.get('.has-right-element').type(password)
       cy.get('button[type="submit"]').click()
       cy.get(':nth-child(2) > form > .button').click() // The "Login" button at the 403 error
     })
 })

Nothing out of the ordinary.

I’ve also used another one to capture the cookies that are being used at the moment of the login:

Cypress.Commands.add('loginAndSaveCookies', (email, password) => {
   cy.visit('baseURL')
   cy.get('[data-test="email"]').type(email)
   cy.get('.has-right-element').type(password)
   cy.get('button[type="submit"]').click()
   cy.get(':nth-child(2) > form > .button').click()

   cy.getCookies().then((cookies) => {
       cy.writeFile('cypress/fixtures/cookies.json', cookies)
   })
})

Here are the cookies that are being sent:

[
  {
    "name": "_oauth2_proxy_csrf",
    "value": "sxvnE7akcD26gzrK2N8w3q0EENUsPIxBTPNbbI6QxvLBSSJ6ufkmSeOwST3vEkBqOt9R_O1-XGcSX7w0GynDLLoW6x4e5JEo6noGBBUEiUPNotwrRb5b9PE=|1710311225|AjqwRehQxbfOul4wQTmj2_F9C2NSdtgJZ3K5prAxEso=",
    "path": "/",
    "secure": true,
    "hostOnly": true,
    "httpOnly": true,
    "expiry": 1710312125,
    "domain": "webpage being tested",
    "sameSite": "lax"
  },
  {
    "name": "_oauth2_proxy",
    "value": "8uThtxIW4Mkrw2KtjHvPXAMUKtqUeYeK4SHWm8CBuvFSg50UDx84-Iec26tJhlO0W40hbGV-nCLLL2ZyZb14YTce8XvV7-9CrzLriMeGFCcFve3ytzhYS5Cp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TeQ2D7DDlMrM9G9ctZy7jHzPiYkYc-T0py6-eEGBOdO3bCGmSBbPLWB3biz43CxRngB0byusBISQyMQSli87mo|1710311226|tzcI0q_ZL29dYQfhGq8eotRiaxyNO9qedY5wWbracdY=",
    "path": "/",
    "secure": true,
    "hostOnly": true,
    "httpOnly": true,
    "expiry": 1710916026,
    "domain": "webpage being tested",
    "sameSite": "lax"
  }
]

In chorme horizontal scroll work , but in safari browser its not work

here is my code
this code not work on safari.

targetPosition i set the scroll value, for example , 11 , 22, 33 , where i scroll

  function ScrollToActiveTab(item, id, useraction) {
    if (item !== null && item !== undefined && useraction) {
      dispatch(addCurrentMenu(item));
    }
  
    requestAnimationFrame(() => {
      // Ensure this runs after any pending layout changes
      var scrollableDiv = document.getElementById('scrollableDiv');
      let tempId = 'targetId-' + id;
      var targetElement = document.getElementById(tempId);
  
      if (targetElement) {
        var targetPosition = targetElement.offsetLeft + targetElement.clientWidth / 2 - window.innerWidth / 2;
  
        // Perform the scroll
        scrollableDiv.scrollLeft = targetPosition;
      }
    });
  }

Please guide my why ° scrollableDiv.scrollLeft = targetPosition;° not work on safari. Thanks

i want work scrollableDiv.scrollLeft = targetPosition , in safari also
see attachment , i have a menu list once i click i update tragetPosition

menu Tab

Double axis Y in Chart.js

i want to ask for some questions about chart.js. I have been create my dashboard with chart.js for showing my database on user interface, but. I have a little bug on Axis Y in chart.js, like double category. This is my dashboard picture
none
And this my syntax.

<script>
        const canvas = document.getElementById('myChart');
        const ctx = canvas.getContext('2d');

        
        var chartData = {}; // Menyiapkan objek untuk menyimpan data chart

        var myChart = new Chart(ctx, {
            type: 'bar', // Menggunakan chart jenis bar
            data: {
                datasets: [{
                    label: 'Statistik Karyawan',
                    data: [],
                    backgroundColor: ['skyblue'], // Warna untuk masing-masing kategori
                    borderWidth: 1
                }],
                labels: ['Jan', 'Feb', 'Mar', 'Apr', 'Mei', 'Jun', 'Jul', 'Agu', 'Sep', 'Okt', 'Nov', 'Des']
            },
            options: {
                scales: {
                    y: {
                        beginAtZero: false,
                        ticks: {
                            callback: function(value, index, values) {
                                // Menampilkan label kategori sesuai index
                                return getCategoryLabel(value);
                            }
                        }
                    }
                },
                responsive: true, // Membuat chart responsif
                maintainAspectRatio: true // Mengatur rasio aspek chart
            }
        });

        // Fungsi untuk mendapatkan label kategori
        function getCategoryLabel(value) {
            // Menentukan label kategori sesuai nilai
            if (value >= 0 && value <= 1) {
                return 'Ringan';
            } else if (value >= 2 && value <= 3) {
                return 'Sedang';
            } else if (value >= 4) {
                return 'Berat';
            } else {
                return '';
            }
        }

        // Fungsi untuk mengupdate chart dengan data baru
        function updateChart(newData) {
            myChart.data.datasets[0].data = newData.allData;
            myChart.update();
        }

        // Fungsi untuk mengubah data chart saat terjadi perubahan
        function onDataChanged() {
            var newData = {
                allData: [0, 1, 2, 3, 4, 5, 6, 7]
            };

            // Menggunakan objek untuk melacak kategori yang sudah ditambahkan
            var addedCategories = {};

            // Memproses data baru dan menambahkannya ke chart
            newData.allData.forEach(function(value) {
                var categoryLabel = getCategoryLabel(value);

                // Menambahkan kategori ke chart hanya jika belum ada
                if (!addedCategories[categoryLabel]) {
                    addedCategories[categoryLabel] = true;
                    myChart.data.datasets[0].data.push(value);
                }
            });

            updateChart(newData);
        }

        onDataChanged();
    </script>

I’m so confused about this bug, please help me.

Ball rolling to the right only?

I’m relatively new to coding, and I’ve been experimenting with creating a bouncing ball animation. While most aspects of the coding have been okay, I’ve encountered a peculiar issue that has left me scratching my head. I’ve managed to get the ball to bounce, but for some reason, it seems to only roll to the right until it collides with the right side of the viewport. I’m really confused, and I’m eager to delve deeper into understanding what might be causing this unexpected behavior and how I can rectify it. Here’s the snippet of my JavaScript file:

var ball = document.querySelector('.ball'),
    isDragging = false,
    isAnimating = false,
    isAnimationAllowed = true, // New flag to control animation while dragging
    offsetX,
    offsetY,
    velocityX = 0,
    velocityY = 0,
    friction = 0.95,
    gravity = 0.5,
    floorLevel = 500,
    animationFrame;

ball.addEventListener('mousedown', startDragging);
ball.addEventListener('touchstart', startDragging);

function startDragging(event) {
    isDragging = true;
    isAnimating = false; // Reset isAnimating to false
    isAnimationAllowed = false; // Disable animation while dragging
    offsetX = event.clientX - ball.getBoundingClientRect().left;
    offsetY = event.clientY - ball.getBoundingClientRect().top;
  
    document.addEventListener('mousemove', drag);
    document.addEventListener('mouseup', stopDragging);
    
    document.addEventListener('touchmove', drag);
    document.addEventListener('touchend', stopDragging);
  }

function drag(event) {
  if (!isDragging) return;

  event.preventDefault();

  var newX, newY;

  if (event.type === 'mousemove') {
    newX = event.clientX - offsetX;
    newY = event.clientY - offsetY;
  } else if (event.type === 'touchmove') {
    newX = event.touches[0].clientX - offsetX;
    newY = event.touches[0].clientY - offsetY;
  }

  ball.style.left = newX + "px";
  ball.style.top = newY + "px";

  velocityX = newX - ball.offsetLeft;
  velocityY = newY - ball.offsetTop;
}

function stopDragging() {
  isDragging = false;
  isAnimationAllowed = true; // Enable animation after dragging stops

  document.removeEventListener('mousemove', drag);
  document.removeEventListener('mouseup', stopDragging);

  document.removeEventListener('touchmove', drag);
  document.removeEventListener('touchend', stopDragging);

  if (!isAnimating) {
    animate();
  }
}

function animate() {
  if (!isAnimationAllowed) return; // Check if animation is allowed
  
  isAnimating = true;

  animationFrame = requestAnimationFrame(animate);

  velocityX *= friction;
  velocityY += gravity;

  var newX = ball.offsetLeft + velocityX;
  var newY = ball.offsetTop + velocityY;

  if (newY >= floorLevel - ball.offsetHeight) {
    newY = floorLevel - ball.offsetHeight;
    velocityY *= -0.6; // Bounce effect
  }

  if (newX < 0) {
    newX = 0;
    velocityX *= -0.6; // Bounce effect for the left boundary
  } else if (newX > window.innerWidth - ball.offsetWidth) {
    newX = window.innerWidth - ball.offsetWidth;
    velocityX *= -0.6; // Bounce effect for the right boundary
  }

  ball.style.left = newX + "px";
  ball.style.top = newY + "px";

  if (Math.abs(velocityX) < 0.1 && Math.abs(velocityY) < 0.1 && newY >= floorLevel - ball.offsetHeight) {
    cancelAnimationFrame(animationFrame);
    isAnimating = false;
  }
}

Improve regex performance

I need help to improve regex performance (speed of execution) for ECMAscript (JavaScript on NodeJS 20) of:

/[u0000-u001fu0022u005cud800-udfff]|[ud800-udbff](?![udc00-udfff])|(?:[^ud800-udbff]|^)[udc00-udfff]/

This regular expression is designed to match certain Unicode characters in a string. Let’s break it down:

  • /[u0000-u001fu0022u005cud800-udfff]/: This part matches any
    character in the range of u0000 to u001f, the characters
    u0022 (quotation mark ") and u005c (backslash ), and any
    character in the range of ud800 to udfff. This range
    ud800-udfff covers surrogate pairs, which are used in UTF-16
    encoding for characters outside of the basic multilingual plane
    (BMP).
  • |: OR operator
  • [ud800-udbff](?![udc00-udfff]): This part matches the first
    part of a surrogate pair (ud800 to udbff) but only if it’s not
    followed by the second part of a surrogate pair (udc00 to
    udfff). This ensures that only valid surrogate pairs are matched.
  • |: Again, an OR operator.
  • (?:[^ud800-udbff]|^)[udc00-udfff]: This part matches the second
    part of a surrogate pair (udc00 to udfff) but only if it’s not
    preceded by the first part of a surrogate pair or if it’s at the
    beginning of the string. The ^ inside the square brackets [^]
    denotes negation, meaning any character other than the ones
    specified.

In summary, this regular expression is used to match and handle surrogate pairs correctly in Unicode strings, ensuring proper validation and handling of UTF-16 encoded characters.

regex101

Speed test over a string of 1000 chars

const REGEX = /[u0000-u001fu0022u005cud800-udfff]|[ud800-udbff](?![udc00-udfff])|(?:[^ud800-udbff]|^)[udc00-udfff]/

const start = performance.now()
console.log(REGEX.test('A'.repeat(10000) + '"')) // true
console.log(performance.now() - start)

Are there improvements that can be made?

The purpose is to have a very fast check for strings that do not need escaping while not being much slower than JSON.stringify() in case the input requires escaping.

How to highlight a word on mouseover in text in a React app

How to highlight a word on mouseover in text in a React app

const text = data[data.length - 1] !== undefined ? data[data.length - 1].taskText : null;

 const [hilightWord, setHilightWord] = useState(false);

  const hightlight = (text, hilightWord) => {
    if (!hilightWord) return text;

    const regex = new RegExp(`(${hilightWord})`, "gi");

    return text.split(regex).map((substring, i) => {
      return (
        <span className={styles.highlight} key={i}>
          {substring}
        </span>
      );
    });
  };


<p className={styles.text} onMouseMove={() => setHilightWord(true)} onMouseLeave={() => setHilightWord(false)}>{hightlight(text, hilightWord)}</p>

Sticky Section Not Working in Elementor Stacked Card Scroll

I’m trying to create a stacked card scroll effect in Elementor using custom CSS and JavaScript (based on a YouTube tutorial). However, the section above the cards (main container) isn’t sticking to the top during the scroll animation; it moves with the scroll.

The tutorial- [https://www.youtube.com/watch?v=7RhQq-DfIqI&list=PLJ2-MeNkZFN5E9KCLvbwSv2Uu7lElogPt&index=33&t=360s]

I’ve followed the tutorial steps carefully but still encounter this issue. I’ve searched online for solutions but haven’t found anything relevant.

As a beginner, inspecting every line of code is challenging. Could you please help identify potential issues in the CSS or JavaScript code that might be causing the sticky section to malfunction? Any suggestions on where to modify the code to achieve the desired effect (sticky section until animation starts) would be greatly appreciated.

Code Snippets:

CSS

selector{
    --card-scroll-height: 400;
    --card-rotate: 12;
}
selector .mdw-active-card{
    transform: translateY(-100vh) rotate(-60deg) !important;
    transition:1s;
    visibility: hidden;
    transform-origin: bottom left;
}
selector > .e-con,
selector > .e-container,
selector > .e-con-inner > .e-con,
selector > .e-con-inner > .e-container{
    position: sticky;
    top:0;
}

JavaScript

<script src="https://code.jquery.com/jquery-3.7.1.js"></script>

<script>

if(!MDWNonce100){
    
var MDWNonce100 = true

$(document).ready(function() {
    
var previousScrollTop = [],
cards = [],
cardScrollHeight = [],
cardRotate = [],
cardContainer = [],
stickyTop = [],
stickyCon = []


// Sliding crads on scroll

function cardSlideUp(){

$('.mdw-stacked-card-area').each(function(i){
    
    var $this = $(this),
    scrollTop = $(document).scrollTop(),
    cardAreaTop = $this.offset().top,
    index = Math.floor((scrollTop - cardAreaTop - stickyTop[i]) / cardScrollHeight[i]),
    totalCards = cards[i].length
    
    cards[i].removeClass('mdw-active-card')
    cards[i].each(function(j){
        if( j <= index ) {
            $(this).addClass('mdw-active-card')
        }
        if(index >= -1 && index < totalCards - 1){
            $(this).css({
                'transform': `rotate(${ -1*j*cardRotate[i] + (index+1)*cardRotate[i] }deg)`
            })
        }
    })
    
    previousScrollTop[i] = scrollTop
})

}


function setValues(){

$('.mdw-stacked-card-area').each(function(i){
    
    var $this = $(this)
    
    stickyTop[i] = 0
    
    if(stickyCon[i].outerHeight() > $(window).height()){
        stickyTop[i] = cardContainer[i].offset().top - stickyCon[i].offset().top - $(window).height()/2
    }
    stickyCon[i].css('top', -1*stickyTop[i])
    
    cardScrollHeight[i] = $this.css('--card-scroll-height') ? parseInt($this.css('--card-scroll-height').trim()) : 400
    cardRotate[i] = $this.css('--card-rotate') ? parseInt($this.css('--card-rotate').trim()) : 9
    
    
    // Rotating cards
    
    cards[i].each(function(j) {
        $(this).css({
            'transform': `rotate(-${j * cardRotate[i]}deg)`,
            'z-index': cards[i].length - j
        })
    })


    // Card area height
    
    $this.css('height', stickyCon[i].outerHeight() +  ((cards[i].length - 1) * cardScrollHeight[i]) + 'px' )
})

}

$(document).on('scroll', cardSlideUp)
$(window).on('resize', function(){
    setValues()
    cardSlideUp()
})


function init(){

$('.mdw-stacked-card-area').each(function(i){
    
    var $this = $(this)
    
    cards[i] = $this.find('.mdw-stacked-cards > .e-con, .mdw-stacked-cards > .e-container, .mdw-stacked-cards > .e-con-inner > .e-con, .mdw-stacked-cards > .e-con-inner > .e-container')
    stickyCon[i] = $this.children('.e-con, .e-container').eq(0)
    
    stickyCon[i].parents().each(function(){
        if( !$(this).is('html') ){ $(this).css('overflow', 'visible') }
    })
    
    previousScrollTop[i] = $(document).scrollTop()
    cardContainer[i] = $this.find('.mdw-stacked-cards')
})

setValues()
cardSlideUp()

}

init()
    
})
}
</script>

The Goal:
The goal is for a section to remain sticky at the top until the scrolling animation starts. However, the sticky section isn’t behaving as expected.

Functionality: During scrolling, the cards should rotate individually, creating a flowing animation. The parent container holding the cards container should remain fixed at the viewport until all cards have completed their rotation animations. This means cards will appear to ‘flow up’ when scrolling down and return to their original positions when scrolling back up.

the effect i’m trying to achive

Problem: The main section, intended to stay fixed at the top of the screen (sticky), isn’t working as expected. While the cards are animating correctly during scrolling, the main section and all its child elements are moving with the scroll instead of remaining fixed.
**
Additional Information:
Elementor version: 3.20.0
(i’m using Elemntors latest flex box container)

What could be causing the sticky section to malfunction in this scenario? Are there any adjustments in the CSS or JavaScript that might resolve the issue?

I’m aiming to achieve a smooth scrolling animation with a section remaining sticky until the card effects end.

ref.current.contains(event.target) always returns false

I have a component like this:

const ColumnTaskPrompt = () => {
 const promptRef = useRef<HTMLDivElement>(null);

 useClickOutside(promptRef, () => {
   console.log("do something";)
 });

 return (
   <div ref={promptRef} className={styles.prompt}>>
     <p>Some prompt 1</p>
     <p>Some prompt 2</p>
     <p>Some prompt 3</p>
   </div>
 );
};

And the standard hook useClickOutside (added console.log for clarity):

const useClickOutside = <T extends HTMLElement = HTMLElement>(
  ref: RefObject<T>,
  callback: () => void
) => {
  useEffect(() => {
    const handleClickOutside = (event: Event) => {
      if (ref.current && !ref.current.contains(event.target as Node)) {
        console.log(
          ref.current,
          event.target,
          ref.current.contains(event.target as Node)
        );

        callback();
      }
    };
    document.addEventListener("mousedown", handleClickOutside);
    return () => {
      document.removeEventListener("mousedown", handleClickOutside);
    };
  }, [ref]);
};

Every time I click on the layout inside this ColumnTaskPrompt component – ref.current.contains(event.target), it returns false.

It also returns false when I click on any part of the layout outside of this component (which is correct).

first rectangle - ref.current, second - event.target, "contains" method returns false

I tried using createRef instead of useRef, however that did not work.

Trying to make a screen that fades in and out with a button click

Clicking a button should call mobileMenuToggle(), toggling an animation for mobileMenu to either fade in or fade out depending on the current status of the menu screen. When mobileMenu display is none, it should fade in, however when mobileMenu is a block, clicking the button should result in mobile menu fading out. When mobileMenu is active (block), mainBody should disappear. When mainBody is active (block), mobileMenu should disappear. Before any clicks, mobileMenu is set to “display: none”

It works the first two times the button is clicked, but on the third time it breaks. It starts playing only the fadeIn animation but both mobileMenu AND mainBody disappear. I suspect it has something to do with the event listener, but I am not really sure. Any help figuring this out would be greatly appreciated.

JS:

function mobileMenuToggle(){
    if (document.getElementById("mobileMenu").style.display == "none"){
        document.getElementById("mobileMenu").style.animationName = "fadeIn"
        document.getElementById("mobileMenu").style.display = "block"
        document.getElementById("mainBody").style.display = "none"
    }
    else if(document.getElementById("mobileMenu").style.display == "block"){
        document.getElementById("mainBody").style.display = "block"
        document.getElementById("mobileMenu").style.animationName = "fadeOut"
        document.getElementById("mobileMenu").style.display = "block" //trigger animation

        mobileMenu.addEventListener("animationend", () => {
            document.getElementById("mobileMenu").style.display = "none"
          });
    }
}

Remix No route matches URL

I have brand new Remix SPA project with simple nested route

  1. Home
  2. Protocol
  3. Protocol/[protocolId]

And I setup the project as shown in the repo https://stackblitz.com/~/github.com/pavankjadda/remix-vite-spa

All routes work except nested route protocol/[protocolId]. I did follow instructions from official docs: https://remix.run/docs/en/main/file-conventions/routes#folders-for-organization. You can see same Stackblitz preview.

Why is this Scraping Function returning an empty array?

const unirest = require("unirest");
const cheerio = require("cheerio");

const getOrganicData = () => {
  return unirest
    .get("https://www.google.com/search?q=apple+linkedin&gl=us&hl=en")
    .headers({
      "User-Agent":
        "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/101.0.4951.54 Safari/537.36",
    })
    .then((response) => {
      let $ = cheerio.load(response.body);

      let titles = [];
      let links = [];
      let snippets = [];
      let displayedLinks = [];

      $(".yuRUbf > a > h3").each((i, el) => {
        titles[i] = $(el).text();
      });
      $(".yuRUbf > a").each((i, el) => {
        links[i] = $(el).attr("href");
      });
      $(".g .VwiC3b ").each((i, el) => {
        snippets[i] = $(el).text();
      });
      $(".g .yuRUbf .NJjxre .tjvcx").each((i, el) => {
        displayedLinks[i] = $(el).text();
      });

      const organicResults = [];

      for (let i = 0; i < titles.length; i++) {
        organicResults[i] = {
          title: titles[i],
          links: links[i],
          snippet: snippets[i],
          displayedLink: displayedLinks[i],
        };
      }
      console.log(organicResults)
    });
};

getOrganicData();

I’m trying to write a function that will successfully scrape the first few links of a google search (for example, I can pass through the query “Javascript” and I want to get the first few results when that term is searched).

I found this blog https://serpdog.io/blog/scrape-google-search-results/ and followed it.
I ran the code on the website and it returned a blank array []. (I am using node js)
I attached the code, but it’s exactly the same as on the blog.

Any ideas on how to fix this? Or do you have a better way to get the first few search results from a search term?

Thanks!

I tried several different methods of getting the top search results, none of which worked.

My app is unable to write a docx file after being converted into a .exe file

I’ve written a simple program in Node.js / electron that reads an excel spreadsheet and then writes the data onto a docx template and creates a new docx file with when done. When I run my program with npm start it works perfectly but once I converted it into an exe file it is unable to do this function and i dont know why? The program will open and take me to the landing page i designed but these functions do not run. please help. thanks!

I’ve tried changing the permissions on the exe file to allow it access to read and write but that didnt work.