Animated dashed css circulating border

I want to create div with dashed border all round and once the user hovers over it it dashed borders move around / circulates in the same way they’re they just move round the edges not leaving their position.

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>
<style> 
   .animated-border {
  width: 200px;
  height: 100px;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  border: 4px dashed transparent;
}

.animated-border::before {
  content: "";
  position: absolute;
  top: -4px;
  left: -4px;
  right: -4px;
  bottom: -4px;
  border: 4px dashed black;
  clip-path: polygon(0% 0%, 100% 0%, 100% 100%, 0% 100%);
  animation: borderMove 2s linear infinite paused;
}

.animated-border:hover::before {
  animation-play-state: running;
}

@keyframes borderMove {
  0% {
    clip-path: inset(0 0 90% 0);
  }
  25% {
    clip-path: inset(0 90% 0 0);
  }
  50% {
    clip-path: inset(90% 0 0 0);
  }
  75% {
    clip-path: inset(0 0 0 90%);
  }
  100% {
    clip-path: inset(0 0 90% 0);
  }
}

</style>
<body>
    <div class="animated-border">Your Content</div>
</body>
</html>

The code above is working a bit well but the only issue is that the borders are not round it its just half but they’re going round though.

React native navigation error with .replace() and .reset()

<TouchableOpacity
style={styles.button}
onPress={() => {
navigation.reset({
index: 0,
routes: [{ name: 'ProfilePage' }],
});
}}
>
<Text style={styles.buttonText}>Test Navigation</Text>
</TouchableOpacity>

This code crashes my app whenever I click on the Test Navigation button. I’ve read on multiple posts on reddit, github and stackexchange that the fix is to install react-native-reanimated, and to add

import react-native-reanimated;

to the top of the App.js file. I did both those things and it doesn’t work. I’ve got no clue what to do

After open bootstrap modal and close i can’t reopen again why?

I open bootstrap modal and close it without any issue

when I try to reopen again for second time after closing it

it not open so how to fix issue

so how to solve this issue

I can open bootstrap modal for display data and can close it without any issue

but when try to reopen again it not accept and not open bootstrap modal

<button id="BtnAddDisplay" class="btn custom-button col-12" type="button" onclick="INSERT_REQUEST_DEGREE_EQUATION_MODAL(); return false;">
        ارسال الى جهه جديده
    </button>
<div class="modal fade" id="INSERT_REQUEST_DEGREE_EQUATIONModal" tabindex="-1" aria-labelledby="INSERT_REQUEST_DEGREE_EQUATIONModalLabel" aria-hidden="true">
  <div class="modal-dialog custom-modal-dialog">
    <div class="modal-content">
      <div class="modal-header btn-dark text-center w-100">
        <h5 class="modal-title text-white w-100" id="INSERT_REQUEST_DEGREE_EQUATIONModalLabel">اضافه جهه جديده</h5>
        <button type="button" class="close text-white" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body">
               <div class="row">
                    <div class="col-12">
                        <div class="card">
                            <div class="card-header">
                                <h6 class="card-subtitle line-on-side text-muted text-center font-small-4 pt-1">دراسة مواد للشهادة ذاتها بجامعات أخرى</h6>
                            </div>
                            <div class="card-body">
          
                                <div id="dvTransfersInputs" class="row transfers">
                                    <div class="col-12 col-md-4">
                                        <div class="form-group">
                                            <label class="control-label">
                                                <asp:Literal Text="<%$ Resources:Resource1, P_COUNTRY_ID %>" runat="server" />
                                            </label>
                                              <asp:DropDownList ID='ddlP_COUNTRY_ID_equation' runat='server' 
                                    CssClass='chosen-select chosen-rtl form-control' 
                                    data-placeholder="<%$ Resources:Resource1, ddl-placeholder %>" 
                                    ClientIDMode='Static' 
                                    onchange="handleDropdownChange_country(this)">
                                    <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                                </asp:DropDownList>
                                        </div>
                                    </div>
                                    <div class="col-12 col-md-4">
                                        <div class="form-group">
                                            <label class="control-label">
                                                <asp:Literal Text="<%$ Resources:Resource1, P_UNIVERSITY_ID %>" runat="server" />
                                            </label>
                                            <asp:DropDownList ID='ddlP_UNIVERSITY_ID_equation' runat='server' CssClass='chosen-select chosen-rtl form-control' data-placeholder="<%$ Resources:Resource1, ddl-placeholder %>" ClientIDMode='Static'  onchange="handleDropdownChange_university(this)">
                                                <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                    </div>
                                    <div class="col-12 col-md-4">
                                        <div class="form-group">
                                            <label class="control-label">
                                                <asp:Literal Text="<%$ Resources:Resource1, P_OFFICE_ID %>" runat="server" />
                                            </label>
                                            <asp:DropDownList ID='ddlP_OFFICE_ID_equation' runat='server' CssClass='chosen-select chosen-rtl form-control' data-placeholder="<%$ Resources:Resource1, ddl-placeholder %>" ClientIDMode='Static' onchange="handleDropdownChange_office(this)">
                                                <asp:ListItem Value="" Text="" Selected="True"></asp:ListItem>
                                            </asp:DropDownList>
                                        </div>
                                    </div>
                          
                                </div>
                            </div>
                 
                        </div>

                    </div>
                </div>
      </div>
      <div class="modal-footer justify-content-center">
       <button type="button" onclick="INSERT_UPD_E_TRANS_REQUEST_DEGREE_EQUATION_TRANSFARED()" class="btn btn-success">اضافه</button>
       <button type="button" class="btn btn-danger" data-dismiss="modal">الغاء</button>
      </div>
    </div>
  </div>
</div>
i open it using 
function INSERT_REQUEST_DEGREE_EQUATION_MODAL() {
    debugger;
    //$('.chosen-select').chosen({
    //    no_results_text: "No results matched",
    //    width: "100%"
    //});
    // check values of country
    $('#ddlP_OFFICE_ID_equation').val('').trigger('chosen:updated');
    $('#ddlP_UNIVERSITY_ID_equation').val('').trigger('chosen:updated');
    $('#ddlP_COUNTRY_ID_equation').val('').trigger('chosen:updated');
    var hiddenCountryValue = $('#HiddenCountry').val();
    var countries = JSON.parse(hiddenCountryValue);

    // Clear the dropdown and add a default empty option
    var $ddlCountry = $('#ddlP_COUNTRY_ID_equation');
    $ddlCountry.empty();
    $ddlCountry.append($('<option>', {
        value: '',
        text: 'اختر من القائمه'
    }));

    // Populate the dropdown with the JSON data
    $.each(countries, function (index, country) {
        $ddlCountry.append($('<option>', {
            value: country.COUNTRY_ID,
            text: country.COUNTRY_NAME
        }));
    });

    // Set the selected index to 0 (default option)
    $ddlCountry.prop('selectedIndex', 0);

    // Trigger the chosen update if you are using the chosen plugin
    $ddlCountry.trigger('chosen:updated');

    //========== Check university
    // Get the JSON data from the hidden field for Universities
    var hiddenUniversityValue = $('#HiddenUniversity').val();
    var universities = JSON.parse(hiddenUniversityValue);

    // Clear the University dropdown and add a default empty option
    var $ddlUniversity = $('#ddlP_UNIVERSITY_ID_equation');
    $ddlUniversity.empty();
    $ddlUniversity.append($('<option>', {
        value: '',
        text: 'اختر من القائمه'
    }));

    // Populate the University dropdown with the JSON data
    $.each(universities, function (index, university) {
        $ddlUniversity.append($('<option>', {
            value: university.UNIVERSITY_ID,
            text: university.UNIVERSITY_DESC
        }));
    });

    // Set the selected index to 0 (default option)
    $ddlUniversity.prop('selectedIndex', 0);

    // Trigger the chosen update for University dropdown
    $ddlUniversity.trigger('chosen:updated');

    //=========== Check office
    var hiddenOfficeValue = $('#HiddenOffice').val();
    var offices = JSON.parse(hiddenOfficeValue);

    // Clear the Office dropdown and add a default empty option
    var $ddlOffice = $('#ddlP_OFFICE_ID_equation');
    $ddlOffice.empty();
    $ddlOffice.append($('<option>', {
        value: '',
        text: 'اختر من القائمه'
    }));

    // Populate the Office dropdown with the JSON data
    $.each(offices, function (index, office) {
        $ddlOffice.append($('<option>', {
            value: office.OFFICE_ID,
            text: office.OFFICE_NAME
        }));
    });

    // Set the selected index to 0 (default option)
    $ddlOffice.prop('selectedIndex', 0);

    // Trigger the chosen update for Office dropdown
    $ddlOffice.trigger('chosen:updated');

    //============
    $('#INSERT_REQUEST_DEGREE_EQUATIONModal').find('input:text, select').val('').trigger('chosen:updated');

    // Optionally, if you are using other plugins or components, reset their states here

    // Show the modal
    $('#INSERT_REQUEST_DEGREE_EQUATIONModal').modal('show').on('hidden.bs.modal', function () {
        // Perform any clean-up if necessary when the modal is hidden
        // Reset dropdowns or other inputs here if needed
        populateDropdown($('#ddlP_COUNTRY_ID_equation'), countries, 'اختر من القائمه');
        populateDropdown($('#ddlP_UNIVERSITY_ID_equation'), universities, 'اختر من القائمه');
        populateDropdown($('#ddlP_OFFICE_ID_equation'), offices, 'اختر من القائمه');
    });
    //if ($.fn.chosen) {
    //    $ddlCountry.chosen('destroy'); // Destroy previous instance if any
    //    $ddlCountry.chosen({
    //        // Custom Chosen Options if required
    //        'width': '100%', // adjust as needed
    //        'no_results_text': 'لا توجد نتائج' // Example
    //    });

    //    $ddlUniversity.chosen('destroy'); // Destroy previous instance if any
    //    $ddlUniversity.chosen({
    //        // Custom Chosen Options if required
    //        'width': '100%', // adjust as needed
    //        'no_results_text': 'لا توجد نتائج' // Example
    //    });

    //    $ddlOffice.chosen('destroy'); // Destroy previous instance if any
    //    $ddlOffice.chosen({
    //        // Custom Chosen Options if required
    //        'width': '100%', // adjust as needed
    //        'no_results_text': 'لا توجد نتائج' // Example
    //    });
    //}
/*    $('#INSERT_REQUEST_DEGREE_EQUATIONModal').modal('hide');*/

    // Reset input fields (optional, since they'll be reset when hidden)
    //$('#ddlP_OFFICE_ID').val('').trigger('chosen:updated');
    //$('#ddlP_UNIVERSITY_ID').val('').trigger('chosen:updated');
    //$('#ddlP_COUNTRY_ID').val('').trigger('chosen:updated');
    //$('#INSERT_REQUEST_DEGREE_EQUATIONModal').modal('show');
    return false; 
}
and i close it using 
         $('#INSERT_REQUEST_DEGREE_EQUATIONModal').modal('hide');

Why do I get value: 1 trying to control generator with parameter?

Here is a code:

function* counter() {
  let counter = 0;
  while (true) {
    counter++;
    const restart = yield counter;
    if (restart === true) {
      counter = 0;
    }
  }
}

const counter1 = counter();
console.log(counter1.next()); //{value: 1, done: false}
console.log(counter1.next()); //{value: 2, done: false}
console.log(counter1.next()); //{value: 3, done: false}
console.log(counter1.next(true)); //{value: 1, done: false}
console.log(counter1.next()); //{value: 2, done: false}
.as-console-wrapper { max-height: 100% !important; }

Logically, the value should be 0 when the ‘true’ parameter is passed, isn’t it? As a counter increment and then it gets reset.

Trying to ask chatGPT it tells me that value is supposed to be 3 or 4 which is incorrect for sure. I can’t get the truth from it.

How can I get rid of the initial delay when I hold down WASD?

So my code most probably isn’t the most optimal way to do this, but if it ain’t broke don’t fix it, right? Anyway, whenever I hold down any of the WASD keys it has a second or so of initial delay before moving the character (currently rectangle) So, how could I fix this?

Here’s my code:

const p1 = document.getElementById("p1");
const p1Height = p1.offsetHeight;
const p1Width = p1.offsetWidth;
const p2 = document.getElementById("p2");
const speed = 20;

if (!p1.style.top) {
  p1.style.top = `${window.innerHeight * 0.4}px`;
}

if (!p1.style.left) {
  p1.style.left = `${window.innerWidth * 0.005}px`;
}

let targetX = parseInt(p1.style.left, 10);
let targetY = parseInt(p1.style.top, 10);
let currentX = targetX;
let currentY = targetY;

let isMoving = false;

document.addEventListener("keypress", function(event) {
  switch (event.key) {
    case 'w':
      if (parseInt(p1.style.top) > 0) {
        targetY -= speed;
      } else {
        p1.style.top = "0px";
      }
      break;
    case 'a':
      if (parseInt(p1.style.left) > 0) {
        targetX -= speed;
      } else {
        p1.style.left = "0px";
      }
      break;
    case 's':
      if (parseInt(p1.style.top) + p1Height < window.innerHeight) {
        targetY += speed;
      } else {
        p1.style.top = `${window.innerHeight - p1Height}px`;
      }
      break;
    case 'd':
      if (parseInt(p1.style.left) + p1Width < window.innerWidth) {
        targetX += speed;
      } else {
        p1.style.left = `${window.innerWidth - p1Width}px`;
      }
      break;
  }

  if (!isMoving) {
    isMoving = true;
    requestAnimationFrame(move);
  }
})

function move() {
  const dx = targetX - currentX;
  const dy = targetY - currentY;

  const moveX = dx * 0.1;
  const moveY = dy * 0.1;

  currentX += moveX;
  currentY += moveY;

  p1.style.left = `${currentX}px`;
  p1.style.top = `${currentY}px`;

  if (Math.abs(dx) > 1 || Math.abs(dy) > 1) {
    requestAnimationFrame(move);
  } else {
    isMoving = false;
  }
}

requestAnimationFrame(move);
@font-face {
  font-family: 'Komikaze', monospace;
  src: url('path-to-your-font/Komikaze.ttf') format('truetype');
}

body {
  background-color: azure;
  overflow: hidden;
}

#p1 {
  position: absolute;
  background-color: red;
  height: 10vh;
  width: 5vh;
  top: 45%;
}

#p2 {
  position: absolute;
  background-color: dodgerblue;
  height: 10vh;
  width: 5vh;
  top: 45%;
  left: 97.2%;
}
<div id="p1"></div>
<div id="p2"></div>

It’s probably way simpler than my brain is trying to make it, but thanks for taking a look!

Shepherd.js: Add Padding Between Tour Step and Screen Edge Without Shifting Arrow?

Current Behavior

I am using shepherdjs to build an app tour. Shepherdjs in turn uses floating-ui under the hood.

My problem is that the tour step is positioned too close to the screen edge, making it look unpolished.

Example (Current Behavior):

Image

    {
      attachTo: {
        element: '#top-menu-account-settings-menu-icon',
        on: 'left',
      },
      buttons: [
        {
          action: addLocationTour.next,
          text: 'Next',
        },
      ],
      floatingUIOptions: {
        middleware: [
          offset(12), // Offset from the highlighted element
        ],
      },
      modalOverlayOpeningRadius: 5,
      text: 'This step is attached to the bottom of the <code>.example-css-selector</code> element.',
    },

Attempted Fix

I tried adding shift({ padding: 16 }) to floatingUIOptions. This successfully prevented the step from touching the screen edge but also misaligned the arrow, shifting it downward and away from the icon center.

Example (Misaligned Arrow Issue):

Image

    {
      attachTo: {
        element: '#top-menu-account-settings-menu-icon',
        on: 'left',
      },
      buttons: [
        {
          action: addLocationTour.next,
          text: 'Next',
        },
      ],
      floatingUIOptions: {
        middleware: [
          offset(12), // Offset from the highlighted element
          shift({ padding: 16 }), // Prevents tour from touching screen edges but shifts the arrow
        ],
      },
      modalOverlayOpeningRadius: 5,
      text: 'This step is attached to the bottom of the <code>.example-css-selector</code> element.',
    },

Question

How can I prevent the step from touching the screen edge without affecting the arrow alignment?

How to play the audio automatically at the start of the page in React/Vite?

I am trying to play the audio automatically at the start of the page without the user interaction(click, tap, keypress..). But I am getting this error when I try to play the audio without it.
I know that this error happens because browsers block audio playback unless there has been user interaction with the page.
Is there any way to play the audio automatically at the start of the page without the user interaction? The website is built with React/Vite.

NotAllowedError: play() failed because the user didn’t interact with the document first.

Adding an image blog to the file form element

I am using the Heic2Any javascript library to convert .heic files into JPG like this:

$('#image-input').on('change', function(ev) {
    var blob = ev.target.files[0];
    heic2any({
        blob: blob,
        toType: "image/jpeg",
    })
    .then(function (resultBlob) {
        
    })
    .catch(function (x) {
        var error = "Error code: " + x.code + " " + x.message;
        console.log(error);
    });
});

But how do I insert the new jpg image into the input form element or otherwise make it available so I can upload it to a PHP script and access it in $_FILES?

Using Nextjs (latest version) and MUI (latest version) and getting Uncaught Error: Cannot read properties of undefined (reading ‘appBar’)

I am trying to figure out the issue as to why I am getting the undefined error below.

Uncaught Error: Cannot read properties of undefined (reading ‘appBar’)

I’m doing a simple setup for testing purposes and running into this error has put a halt on progress.

Here is the code snippets below.

Layout.tsx

import type { Metadata } from "next";
import { Roboto } from "next/font/google";
import "./globals.css";
import { AppRouterCacheProvider } from '@mui/material-nextjs/v15-appRouter';
import { ThemeProvider } from "@mui/material";
import {themeOptions} from '../theme/theme';
import NavAppBar from "@/components/header/header";

const roboto = Roboto({
  variable: "--font-roboto",
  subsets: ["latin"],
});

export const metadata: Metadata = {
  title: "Create Next App",
  description: "Generated by create next app",
};

export default function RootLayout({children,}: Readonly<{
  children: React.ReactNode;
}>) {


  return (
    <html lang="en">
      <body className={`${roboto.className}`}>
        <AppRouterCacheProvider>
          <ThemeProvider theme={themeOptions}>
            <NavAppBar />
            {/* <CssBaseline /> */}
            {children}
          </ThemeProvider>
        </AppRouterCacheProvider>
      </body>
    </html>
  );
}

header.tsx file

"use client";
import * as React from 'react';
import AppBar from '@mui/material/AppBar';
import Box from '@mui/material/Box';
import Toolbar from '@mui/material/Toolbar';
import IconButton from '@mui/material/IconButton';
import Typography from '@mui/material/Typography';
import Menu from '@mui/material/Menu';
import MenuIcon from '@mui/icons-material/Menu';
import Container from '@mui/material/Container';
import Avatar from '@mui/material/Avatar';
import Button from '@mui/material/Button';
import Tooltip from '@mui/material/Tooltip';
import MenuItem from '@mui/material/MenuItem';
import AdbIcon from '@mui/icons-material/Adb';

const pages = ['Products', 'Pricing', 'Blog'];
const settings = ['Profile', 'Account', 'Dashboard', 'Logout'];

export default function NavAppBar() {
  const [anchorElNav, setAnchorElNav] = React.useState<null | HTMLElement>(null);
  const [anchorElUser, setAnchorElUser] = React.useState<null | HTMLElement>(null);

  const handleOpenNavMenu = (event: React.MouseEvent<HTMLElement>) => {
    setAnchorElNav(event.currentTarget);
  };
  const handleOpenUserMenu = (event: React.MouseEvent<HTMLElement>) => {
    setAnchorElUser(event.currentTarget);
  };

  const handleCloseNavMenu = () => {
    setAnchorElNav(null);
  };

  const handleCloseUserMenu = () => {
    setAnchorElUser(null);
  };

  return (
    <AppBar position='static' sx={{ bgcolor: 'primary.main' }}>
      <Container maxWidth="xl">
        <Toolbar disableGutters>
          <AdbIcon sx={{ display: { xs: 'none', md: 'flex' }, mr: 1 }} />
          <Typography
            variant="h6"
            noWrap
            component="a"
            href="#app-bar-with-responsive-menu"
            sx={{
              mr: 2,
              display: { xs: 'none', md: 'flex' },
              fontFamily: 'monospace',
              fontWeight: 700,
              letterSpacing: '.3rem',
              color: 'inherit',
              textDecoration: 'none',
            }}
          >
            LOGO
          </Typography>

          <Box sx={{ flexGrow: 1, display: { xs: 'flex', md: 'none' } }}>
            <IconButton
              size="large"
              aria-label="account of current user"
              aria-controls="menu-appbar"
              aria-haspopup="true"
              onClick={handleOpenNavMenu}
              color="inherit"
            >
              <MenuIcon />
            </IconButton>
            <Menu
              id="menu-appbar"
              anchorEl={anchorElNav}
              anchorOrigin={{
                vertical: 'bottom',
                horizontal: 'left',
              }}
              keepMounted
              transformOrigin={{
                vertical: 'top',
                horizontal: 'left',
              }}
              open={Boolean(anchorElNav)}
              onClose={handleCloseNavMenu}
              sx={{ display: { xs: 'block', md: 'none' } }}
            >
              {pages.map((page) => (
                <MenuItem key={page} onClick={handleCloseNavMenu}>
                  <Typography sx={{ textAlign: 'center' }}>{page}</Typography>
                </MenuItem>
              ))}
            </Menu>
          </Box>
          <AdbIcon sx={{ display: { xs: 'flex', md: 'none' }, mr: 1 }} />
          <Typography
            variant="h5"
            noWrap
            component="a"
            href="#app-bar-with-responsive-menu"
            sx={{
              mr: 2,
              display: { xs: 'flex', md: 'none' },
              flexGrow: 1,
              fontFamily: 'monospace',
              fontWeight: 700,
              letterSpacing: '.3rem',
              color: 'inherit',
              textDecoration: 'none',
            }}
          >
            LOGO
          </Typography>
          <Box sx={{ flexGrow: 1, display: { xs: 'none', md: 'flex' } }}>
            {pages.map((page) => (
              <Button
                key={page}
                onClick={handleCloseNavMenu}
                sx={{ my: 2, color: 'white', display: 'block' }}
              >
                {page}
              </Button>
            ))}
          </Box>
          <Box sx={{ flexGrow: 0 }}>
            <Tooltip title="Open settings">
              <IconButton onClick={handleOpenUserMenu} sx={{ p: 0 }}>
                <Avatar alt="Remy Sharp" src="/static/images/avatar/2.jpg" />
              </IconButton>
            </Tooltip>
            <Menu
              sx={{ mt: '45px' }}
              id="menu-appbar"
              anchorEl={anchorElUser}
              anchorOrigin={{
                vertical: 'top',
                horizontal: 'right',
              }}
              keepMounted
              transformOrigin={{
                vertical: 'top',
                horizontal: 'right',
              }}
              open={Boolean(anchorElUser)}
              onClose={handleCloseUserMenu}
            >
              {settings.map((setting) => (
                <MenuItem key={setting} onClick={handleCloseUserMenu}>
                  <Typography sx={{ textAlign: 'center' }}>{setting}</Typography>
                </MenuItem>
              ))}
            </Menu>
          </Box>
        </Toolbar>
      </Container>
    </AppBar>
  );
}

Simply put I am trying to see the ends and outs of using MUI with Nextjs.

oidc-client-ts Popup Login Fails with “No window.opener” Error on Callback

Problem Statement

I’m using oidc-client-ts to implement OAuth2 PKCE authentication with a popup login flow. However, when the authentication provider redirects back to my popup callback page, I get the following error (see source code):

No window.opener. Can't complete notification.

What I’m Doing

I initiate the login flow using signinPopup() in my main app:

const userManager = new UserManager({
  authority: "https://your-oidc-provider.com",
  client_id: "your-client-id",
  redirect_uri: window.location.origin + "/callback",
});

async function loginWithPopup() {
  try {
    await userManager.signinPopup();
  } catch (error) {
    console.error("Popup login failed:", error);
  }
}

I handle the popup callback on a separate page (/callback):

const userManager = new UserManager({
  authority: "https://your-oidc-provider.com",
  client_id: "your-client-id",
  redirect_uri: window.location.origin + "/callback",
});

await userManager.signinCallback();

Notes

  • window.opener = null inside the popup console meaning the popup doesn’t recognize the main page
  • window.crossOriginIsolated = false (https://github.com/authts/oidc-client-ts/issues/31#issuecomment-896749759 suggests the popup doesn’t work if it’s true)
  • Note I’m integrating with many different providers so creating a singleton UserManager instance isn’t feasible

What am I doing wrong?

Unable to Extract Data from Dynamically Loaded Content Using Splash

I’m trying to scrape funding opportunity data from https://marie-sklodowska-curie-actions.ec.europa.eu/funding. The data I need includes:

  • Title of the funding opportunity
  • Status (e.g., open, closed)
  • Deadline
  • Link to the opportunity

The website uses dynamic content loading (likely via JavaScript), and I’m using Scrapy with Splash to render the page. However, my current code isn’t extracting any data. Here’s the code I’m using:

import scrapy
from notices.items import MarieCurieItem
from scrapy_splash import SplashRequest

class MscaSpider(scrapy.Spider):
    name = "msca"
    
    def start_requests(self):
        url = 'https://marie-sklodowska-curie-actions.ec.europa.eu/funding'
        yield SplashRequest(url=url, callback=self.parse)

    def parse(self, response):
        msca_item = MarieCurieItem()
        for funding in response.css('article.eac-calls-teaser'):
            msca_item['title'] = funding.css('h3::text').get()
            msca_item['status'] = funding.css('span.deadline-time::text').get()
            msca_item['link'] = funding.css('a::attr(href)').get()
            yield msca_item

Problem:

  1. The response.css selectors aren’t matching any elements, even though the data is visible in the browser.
  2. When I inspect the page, the funding opportunities are loaded dynamically (likely via an API or JavaScript).

What I’ve Tried:

  1. I used Splash to render the page, but the data still isn’t accessible.
  2. I checked the Splash logs and confirmed that the page is loading, but the dynamic content isn’t being captured.

Questions:

  1. How can I modify my Splash script to wait for the dynamic content to load?
  2. Are there better selectors I should use to extract the required data?
  3. Should I directly target the API endpoint instead of rendering the page with Splash? If so, how can I identify the correct API endpoint?

Additional Information:

  • When I inspect the page, the funding opportunities are inside a <eac-faceted-search> component.
  • I tried increasing the wait time in Splash, but it didn’t help.

Any guidance or suggestions would be greatly appreciated!

How to return metadata when using .invoke() and .withStructuredOutput

I’m using LangChain 0.3 (JS/TS) with a gpt-4o model.

const llm = new AzureChatOpenAI({
  azureOpenAIApiDeploymentName: openaiModel,
  temperature: 0,
  maxTokens: undefined,
  timeout: 10 * 60 * 1000,
  maxRetries: 4,
});

const structuredLlm = llm.withStructuredOutput(response_format, { includeRaw: true });
const completion = await structuredLlm.invoke(prompt);
console.log('Completion:', completion);

My problem is that completion only includes the json object the llm has generated. I also would like it to return the request’s metadata, such as the id, number of tokens used, etc.

In the docs I read that adding includeRaw: true should take care of this. But it doesn’t seem to work, as completion still has no metadata inside it. Any idea what I might be doing wrong?

Chrome Extension UserScript Execute Without Refresh Page

Does anyone know a way to make a script registered with chrome.userScript execute immediately without having to refresh the page? In manifest v3 the accepted way to execute user script is through the userScript API. But when a script is registered with this API it only actually executes when the page is reloaded.

I am trying to render a video to my react native mobile app but it come up as blank

const renderPost = ({ item }) => {
const mediaUri = http://10.50.99.238:5001${item.media_url};

return (
  <View
    style={{ padding: 10, borderBottomWidth: 1, borderBottomColor: "#ccc" }}
  >
    <Text style={{ fontWeight: "bold" }}>{item.user_id}</Text>
    {item.media_url &&
    item.media_url.endsWith(".mp4") &&
    isValidUrl(mediaUri) ? (
      <View style={{ width: "100%", height: 200 }}>
        <VideoView
          source={{ uri: mediaUri }}
          style={{ width: "100%", height: 300 }}
          useNativeControls // Use native controls for play/pause etc.
          resizeMode="contain"
          shouldPlay // Start playing as soon as it's loaded
          isLooping // Loop the video
          onError={(error) => console.log("Video Error:", error)}
          onLoadStart={() => console.log("Loading video...")}
          onLoad={() => console.log("Video loaded successfully")}
        />
      </View>
    ) : item.media_url && isValidUrl(mediaUri) ? (
      <Image
        source={{ uri: mediaUri }}
        style={{ width: "100%", height: 200, marginVertical: 10 }}
        resizeMode="contain"
      />
    ) : (
      <Text>Invalid media URL</Text>
    )}
    <Text>{item.caption}</Text>
  </View>
);

};

I am new to react native development and trying to render video on my React native app, the video uri is coming from my nodeJs backend which stores the media files in /uploads folder using multer. While the images are shown the video does not show, it just shows a blank space. Please help, thanks in advance