What causes long and unclear codes in chrome extension source code

recently i worked with a freelancer to build me a chrome extension to scrap reviews from listings and export them to a csv file. This is the only function about the whole extension.

When he provided me with the source code it was the most complex unclear javascript code i’ve seen in my whole life. Exactly 15050 line of code for that basic and simple extension, and he made it all in less than 2 days.

I built a whole order tracking system before finally for way less than that amount of lines.

My question, is there any tool to build chrome extensions easier that i don’t know about? Or what might be the explanation of that messy long code?
Obviously the freelancer didn’t tell me I don’t know why but I believe its my right to get a clear vision about my extensions development process

The code is too long but i will include a part of it so i can better show the matter

Also all of the file names was(popup.*) idk if that rings any bells

) => {
  var e,
    t = {
      702: (e, t, n) => {
        "use strict";
        var r = {};
        n.r(r),
          n.d(r, {
            BaseTransition: () => Or,
            BaseTransitionPropsValidators: () => Rr,
            Comment: () => Di,
            DeprecationTypes: () => Js,
            EffectScope: () => me,
            ErrorCodes: () => fn,
            ErrorTypeStrings: () => Hs,
            Fragment: () => Mi,
            KeepAlive: () => qr,
            ReactiveEffect: () => _e,
            Static: () => Ui,
            Suspense: () => sr,
            Teleport: () => Li,
            Text: () => Bi,
            TrackOpTypes: () => cn,
            Transition: () => ra,
            TransitionGroup: () => Ga,
            TriggerOpTypes: () => ln,
            VueElement: () => Va,
            assertNumber: () => un,
            callWithAsyncErrorHandling: () => pn,
            callWithErrorHandling: () => dn,
            camelize: () => L,
            capitalize: () => B,
            cloneVNode: () => ss,
            compatUtils: () => Gs,
            computed: () => Bs,
            createApp: () => Ac,
            createBlock: () => Gi,
            createCommentVNode: () => ls,
            createElementBlock: () => Yi,
            createElementVNode: () => ns,
            createHydrationRenderer: () => Si,
            createPropsRestProxy: () => Lo,
            createRenderer: () => wi,
            createSSRApp: () => Tc,
            createSlots: () => uo,
            createStaticVNode: () => cs,
            createTextVNode: () => as,
            createVNode: () => rs,
            customRef: () => tn,
            defineAsyncComponent: () => Ur,
            defineComponent: () => Br,
            defineCustomElement: () => Ua,
            defineEmits: () => wo,
            defineExpose: () => So,
            defineModel: () => Co,
            defineOptions: () => Eo,
            defineProps: () => _o,
            defineSSRCustomElement: () => ja,
            defineSlots: () => xo,
            devtools: () => zs,
            effect: () => Ce,
            effectScope: () => ge,
            getCurrentInstance: () => bs,
            getCurrentScope: () => ve,
            getTransitionRawChildren: () => Mr,
            guardReactiveProps: () => is,
            h: () => Ds,
            handleError: () => mn,
            hasInjectionContext: () => ei,
            hydrate: () => Cc,
            initCustomFormatter: () => Us,
            initDirectivesForSSR: () => Nc,
            inject: () => Zo,
            isMemoSame: () => $s,
            isProxy: () => Ft,
            isReactive: () => It,
            isReadonly: () => Pt,
            isRef: () => Ht,
            isRuntimeOnly: () => Ns,
            isShallow: () => Lt,
            isVNode: () => Ji,
            markRaw: () => Bt,
            mergeDefaults: () => Io,
            mergeModels: () => Po,
            mergeProps: () => ds,
            nextTick: () => Cn,
            normalizeClass: () => Z,
            normalizeProps: () => ee,
            normalizeStyle: () => Y,
            onActivated: () => zr,
            onBeforeMount: () => Zr,
            onBeforeUnmount: () => ro,
            onBeforeUpdate: () => to,
            onDeactivated: () => Wr,
            onErrorCaptured: () => co,
            onMounted: () => eo,
            onRenderTracked: () => ao,
            onRenderTriggered: () => so,
            onScopeDispose: () => be,
            onServerPrefetch: () => io,
            onUnmounted: () => oo,
            onUpdated: () => no,
            openBlock: () => Vi,
            popScopeId: () => $n,
            provide: () => Xo,
            proxyRefs: () => Zt,
            pushScopeId: () => jn,
            queuePostFlushCb: () => kn,
            reactive: () => Tt,
            readonly: () => Rt,
            ref: () => zt,
            registerRuntimeCompiler: () => Os,
            render: () => xc,
            renderList: () => lo,
            renderSlot: () => fo,
            resolveComponent: () => Xn,
            resolveDirective: () => tr,
            resolveDynamicComponent: () => er,
            resolveFilter: () => Ys,
            resolveTransitionHooks: () => Ir,
            setBlockTracking: () => Wi,
            setDevtoolsHook: () => Ws,
            setTransitionHooks: () => Fr,
            shallowReactive: () => kt,
            shallowReadonly: () => Ot,
            shallowRef: () => Wt,
            ssrContextKey: () => hr,
            ssrUtils: () => Ks,
            stop: () => Ae,
            toDisplayString: () => ue,
            toHandlerKey: () => D,
            toHandlers: () => po,
            toRaw: () => Mt,
            toRef: () => sn,
            toRefs: () => nn,
            toValue: () => Qt,
            transformVNodeArgs: () => Xi,
            triggerRef: () => Gt,
            unref: () => Jt,
            useAttrs: () => ko,
            useCssModule: () => qa,
            useCssVars: () => Ea,
            useModel: () => Ro,
            useSSRContext: () => dr,
            useSlots: () => To,
            useTransitionState: () => Tr,
            vModelCheckbox: () => oc,
            vModelDynamic: () => fc,
            vModelRadio: () => sc,
            vModelSelect: () => ac,
            vModelText: () => rc,
            vShow: () => _a,
            version: () => Vs,
            warn: () => qs,
            watch: () => vr,
            watchEffect: () => pr,
            watchPostEffect: () => mr,
            watchSyncEffect: () => gr,
            withAsyncContext: () => Fo,
            withCtx: () => qn,
            withDefaults: () => Ao,
            withDirectives: () => Er,
            withKeys: () => vc,
            withMemo: () => js,
            withModifiers: () => gc,
            withScopeId: () => Vn,
          });
        var o = {};
        function i(e, t) {
          const n = new Set(e.split(","));
          return t ? (e) => n.has(e.toLowerCase()) : (e) => n.has(e);
        }
        n.r(o),
          n.d(o, {
            hasBrowserEnv: () => Cd,
            hasStandardBrowserEnv: () => Ad,
            hasStandardBrowserWebWorkerEnv: () => kd,
          });
        const s = {},
          a = [],
          c = () => {},
          l = () => !1,
          u = (e) =>
            111 === e.charCodeAt(0) &&
            110 === e.charCodeAt(1) &&
            (e.charCodeAt(2) > 122 || e.charCodeAt(2) < 97),
          f = (e) => e.startsWith("onUpdate:"),
          h = Object.assign,
          d = (e, t) => {
            const n = e.indexOf(t);
            n > -1 && e.splice(n, 1);
          },
          p = Object.prototype.hasOwnProperty,
          m = (e, t) => p.call(e, t),
          g = Array.isArray,
          y = (e) => "[object Map]" === A(e),
          v = (e) => "[object Set]" === A(e),
          b = (e) => "[object Date]" === A(e),
          _ = (e) => "function" == typeof e,
          w = (e) => "string" == typeof e,
          S = (e) => "symbol" == typeof e,
          E = (e) => null !== e && "object" == typeof e,
          x = (e) => (E(e) || _(e)) && _(e.then) && _(e.catch),
          C = Object.prototype.toString,
          A = (e) => C.call(e),
          T = (e) => A(e).slice(8, -1),
          k = (e) => "[object Object]" === A(e),
          R = (e) =>
            w(e) && "NaN" !== e && "-" !== e[0] && "" + parseInt(e, 10) === e,
          O = i(
            ",key,ref,ref_for,ref_key,onVnodeBeforeMount,onVnodeMounted,onVnodeBeforeUpdate,onVnodeUpdated,onVnodeBeforeUnmount,onVnodeUnmounted"
          ),
          N = i(
            "bind,cloak,else-if,else,for,html,if,model,on,once,pre,show,slot,text,memo"
          ),
          I = (e) => {
            const t = Object.create(null);
            return (n) => t[n] || (t[n] = e(n));
          },
          P = /-(w)/g,
          L = I((e) => e.replace(P, (e, t) => (t ? t.toUpperCase() : ""))),
          F = /B([A-Z])/g,
          M = I((e) => e.replace(F, "-$1").toLowerCase()),
          B = I((e) => e.charAt(0).toUpperCase() + e.slice(1)),
          D = I((e) => (e ? `on${B(e)}` : "")),
          U = (e, t) => !Object.is(e, t),
          j = (e, t) => {
            for (let n = 0; n < e.length; n++) e[n](t);
          },
          $ = (e, t, n) => {
            Object.defineProperty(e, t, {
              configurable: !0,
              enumerable: !1,
              value: n,
            });
          },
          V = (e) => {
            const t = parseFloat(e);
            return isNaN(t) ? e : t;
          },
          q = (e) => {
            const t = w(e) ? Number(e) : NaN;
            return isNaN(t) ? e : t;
          };
        let H;
        const z = () =>
          H ||
          (H =
            "undefined" != typeof globalThis
              ? globalThis
              : "undefined" != typeof self
              ? self
              : "undefined" != typeof window
              ? window
              : void 0 !== n.g
              ? n.g
              : {});
        const W = {
            1: "TEXT",
            2: "CLASS",
            4: "STYLE",
            8: "PROPS",
            16: "FULL_PROPS",
            32: "NEED_HYDRATION",
            64: "STABLE_FRAGMENT",
            128: "KEYED_FRAGMENT",
            256: "UNKEYED_FRAGMENT",
            512: "NEED_PATCH",
            1024: "DYNAMIC_SLOTS",
            2048: "DEV_ROOT_FRAGMENT",
            [-1]: "HOISTED",
            [-2]: "BAIL",
          },
          K = i(
            "Infinity,undefined,NaN,isFinite,isNaN,parseFloat,parseInt,decodeURI,decodeURIComponent,encodeURI,encodeURIComponent,Math,Number,Date,Array,Object,Boolean,String,RegExp,Map,Set,JSON,Intl,BigInt,console,Error"
          );
        function Y(e) {
          if (g(e)) {
            const t = {};
            for (let n = 0; n < e.length; n++) {
              const r = e[n],
                o = w(r) ? X(r) : Y(r);
              if (o) for (const e in o) t[e] = o[e];
            }
            return t;

Why is my Visual Studio Code getting server error messages when trying to debug

Why am I getting an IIS error when I try to debug a javascript source file in Visual Studio Code? Here is my launch.json file

 // Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
    
    {
        "type": "chrome",
        "request": "launch",
        "name": "Launch Chrome against localhost",
        "url": "http://localhost:8080",
        "webRoot": "${workspaceFolder}"            
    },
    {
        "type": "firefox",
        "request": "launch",
        "name": "Launch firefox against localhost",
        "url": "http://localhost:8080",
        "webRoot": "${workspaceFolder}"
    }
]

And the error message from IIS is: Could not read source map for chrome-error://chromewebdata/: Unexpected 503 response from chrome-error://chromewebdata/neterror.rollup.js.map: Unsupported protocol “chrome-error:”

API is called twice

I have app about hockey statistics, I dont have endpoint with this stats , I have endpoint with team and player stats. I am calling api with first team , select first 2 players save to arr and call api again with another team query, find top players from another team and save it .
Than sort topPlayers and display it.
When I open console.log() => NETWORK i can see API with specific team is called twice.
How to fix it?

const teamQuery = useMemo(() => {
    return [
      "NSH", "TBL", "PIT", "CHI", "VGK", "MIN", "ANA",
      "FLA", "PHI", "WSH", "ARI", "NYI", "SJS", "CGY",
      "BUF", "NYR", "CBJ", "NJD", "DET", "DAL",
      "TOR", "MTL", "BOS", "LAK", "COL", "WPG",
      "SEA", "CAR", "OTT", "EDM", "STL", "VAN"
    ];
  }, []);

  const fetchTeamData = async (teamQuery) => {
    try {
      const queryParam = encodeURIComponent(teamQuery);
      const res = await axios.get(`/api/NHL/findTeam?team=${queryParam}`);
      return res.data.data; 
    } catch (error) {
      console.error(error);
      return null; 
    }
  };



const fetchAllTeamsData = useCallback(async () => {
    setLoad(true);
    const topPlayers = [];

    for (const team of teamQuery) {

      setClub(team);
      const teamData = await fetchTeamData(team);

      if (teamData && teamData.players) {
        const sortedPlayers = teamData.players.sort((a, b) => b.stats.points - a.stats.points);
        const teamTopPlayers = sortedPlayers.slice(0, 2);
        topPlayers.push(...teamTopPlayers);
      }
    }

    // sort players 
    const sortedTopPlayers = topPlayers.sort((a, b) => b.stats.points - a.stats.points);
    setAllTopPlayers(sortedTopPlayers);

    const sortedTopGoals = [...topPlayers].sort((a, b) => b.stats.goals - a.stats.goals);
    setTopGoals(sortedTopGoals);

    const sortedTopAssists = [...topPlayers].sort((a, b) => b.stats.asists - a.stats.asists);
    setTopAssists(sortedTopAssists);

    const sortedMostPIM = [...topPlayers].sort((a, b) => b.stats.penalty - a.stats.penalty);
    setMostPIM(sortedMostPIM);

    setLoad(false);
  }, [teamQuery]);

  useEffect(() => {
    fetchAllTeamsData();
  }, [fetchAllTeamsData]);

HTMX – Trigger event on clicking outside the modal

Here’s my modal in my html:

<div id="modals-here" class="modal modal-blur fade" style="display:none" aria-hidden="false" tabindex="-1" hx-get="/referrallist" hx-trigger="click" hx-target="#search-results">
    <div class="modal-dialog modal-lg modal-dialog-centered" role="document">
    <div class="modal-content"></div>
</div>

here’s the serverside:

app.get("/modal", (req, res) => {
    const html = `<div class="modal-dialog modal-dialog-centered modal-lg">
        <div class="modal-content">
            <div class="modal-header">
                <h5 class="modal-title">Add New Referral</h5>
                <button type="button" id="quit-modal" class="quit-modal hover:bg-blue-400 rounded" data-bs-dismiss="modal" hx-get="/referrallist"
                    hx-trigger="click">
                <img class="w-8" src="/images/cross-button.svg"/>
                </button>
            </div>
            <div class="modal-body">
                ${newReferral()}
            </div>
        </div>
    </div>`;

    res.send(html);
});

newReferral() just makes a form, with a post request on the submit button. Nout fancy. What’s funky is, when I’m typing in the modal… I can see its firing /referrallist in the background. Now I’m guessing that’s because I’m clicking in the modal, which is clicking on modals-here, and it’s registering the tab between elements as another click (I’m new in case you can’t tell!).
The question is though, how exactly can I make /referrallist fire when someone clicks outside the modal (to close it)? I’ve got it firing on the X button just fine, nae worries. I tried adding a second event listener to the original one that fires /referrallist, which looked like:
<div class="divide-y divide-gray-600" id="search-results" hx-get="/referrallist" hx-trigger="load, click from:#quit-modal>
But that didn’t work either, presumably because the #quit-modal div is only rendered after the app.get("/modal"... has fired.
Basically, I’m stumped. Any ideas of how I can do this?

I’ve been searching stackoverflow, reddit, YouTube and all sorts to try and find a solution. I’m not an advanced developer by any means, which could easily be the problem, but I’ve not managed to find or understand a solution yet.

Is there a way to get children element while using Selenium in javascript?

I want to adapt the script I use in Javascript to Selenium(javascript). I tried for a long time but couldn’t find the solution.
I want to explain my question on this image

await chromeDriver.findElement(By.id("nav-search-submit-button")).click();

When I use the above code driver finds the element and click function works.

await chromeDriver.findElement(By.id("nav-search-submit-text").children[0]).click(); 

Then i try to find children element with above code driver can not find children element but chrome console finds element on website. I would appreciate it if you could help me find the children element using Selenium in Javascript.

jQuery modal not opening on toggle(). How to select/bind dynamically created button on a table when using CSS class

On my home.jsp, I have a table, which is created after user clicking search.

Each row of table has anchor tag with image.

Upon click of anchor tag with image, I want to open modal. Modal is not opening. I can’t find why.

$("#searchBtn").click(function() {  // upon click of searchBtn
    var searchString = $("#searchLocation").val();
    $.get("searchHotel/" + searchString, function(res) {  // call searchHotel, get response.
        $("#tblHotel tr:not(:first)").remove();  // remove all but first row which is table header
        $.each(res, function(idx, val) {  // for each row, append data
            $("#tblHotel").append("<tr>" + "<td>" + val.hotelName + "</td>" + "<td>" + val.address + "</td>"
                            + "<td>" + val.city + "</td>" + "<td>" + val.state + "</td>"
                            + "<td>" + val.averagePrice + "</td>"
                            + "<td>" + "<a class='hotelDetailOnImage' href='#'><img length=300 width=200 src='" + val.imageURL + "'></img></a>" + "</td>"
                            + "<td>" + val.starRating + "</td>"
                            + "<td>" + "<button type='button' class='btn btn-primary' data-toggle='modal' data-target='#bookingHotelRoomModal'>Hotel Detail</button>" + "</td>" + "</tr>");
        });
    });
});

To detour the problem, I created button on each row instead of anchor tag to open modal.

Upon click of button, modal is opening. Then I do not know how to select/bind this click event, so I can do something upon the button click.

How do I dynamically bind click event of a class when I’m using CSS class? CSS uses “class” and jQuery also uses “class” to mean two different things? I want to select jQuery class, so upon click of it, I can do something. Should I create custom attribute for the button and do something with it?

// Modal is not opening
$("tblHotel").on('click', '.hotelDetailOnImage', function() {
    $("#bookingHotelRoomModal").toggle();
    return false;
});

// Nothing is happening upon click of button, beside modal being opened.
$("tblHotel").on('click', '.btn btn-primary', function() {
    alert("Not alerting");
    console.log("Not logging");
});

My modal starts such as below.

<div class="modal" id="bookingHotelRoomModal">
  <div class="modal-dialog modal-lg">
    <div class="modal-content">

And following is table.

<div class="col-7 border rounded" style="margin-left:50px;">
    <div style='text-align:center;font-size:20px;font-family:"Trebuchet MS", Helvetica, sans-serif'>List of Hotels:</div>   

    <div id="listHotel">
        <table id="tblHotel" border="1">
            <tr> <th>Name</th> <th>Address</th> <th>City</th> <th>State</th> <th>Price</th> <th>Image</th> <th>Rating</th> <th>Detail</th> </tr>
        </table>
    </div>
    </div>
</div>

jQuery & Bootstrap versions I’m using:

<script src="https://code.jquery.com/jquery-3.7.1.min.js" ...
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/css/bootstrap.min.css">
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.5.0/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css">

How can I make sure that the browser started with Puppeteer is a normal browser and not an automated one?

I’m using Puppeteer to try to create an automation for Nike, but I can’t log in even though I’ve done a lot of things.
I’m using puppeteer-stealth, but despite this the browser realizes it’s an automation.
nike every time I try to log in it gives me an error.

I doubt the problem is in human movements etc, given that the browser notices something strange when opened.

chrome erorr

package.json:

 "dependencies": {
    "puppeteer": "^21.7.0",
    "puppeteer-core": "^21.7.0",
    "puppeteer-extra": "^3.3.6",
    "puppeteer-extra-plugin": "^3.2.3",
    "puppeteer-extra-plugin-anonymize-ua": "^2.4.6",
    "puppeteer-extra-plugin-stealth": "^2.11.2"
  }

part of my code

const puppeteer = require('puppeteer-extra');
const StealthPlugin = require('puppeteer-extra-plugin-stealth');
(async () => {
  const userDataDir = './user-data-dir';
  const chromePath = 'C:\Program Files\Google\Chrome\Application\chrome.exe';

  const userAgents = [
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Edge/91.0.864.37 Safari/537.36',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Safari/537.36',
    'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Firefox/89.0.2',
    'Mozilla/5.0 (Linux; Android 10; SM-G975F) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.124 Mobile Safari/537.36',
    'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/120.0.0.0 Safari/537.36 Edg/120.0.0.0'
  ];

  const randomUserAgent = userAgents[Math.floor(Math.random() * userAgents.length)];

  const options = {
    headless: false,
    defaultViewport: null,
    userDataDir: userDataDir,
    executablePath: chromePath,
    args: [
      '--start-maximized',
      '--disable-gpu',
      '--disable-infobars',
      '--disable-extensions',
      '--disable-dev-shm-usage',
      '--no-first-run',
      '--disable-software-rasterizer',
      '--lang=it-IT',
      '--disable-geolocation',
      `--user-agent=${randomUserAgent}`,
    ],
    ignoreDefaultArgs: ['--enable-automation'],
  };

  const browser = await puppeteer.launch(options);

Need Help: Unable to Share on Instagram Stories in React Native App, Works Fine on Other Platforms

Hey fellow developers,

I’m currently working on a React Native app, and I’m facing an issue with sharing content on Instagram Stories. The sharing feature works perfectly on other platforms, but when it comes to Instagram Stories on iOS, it simply doesn’t function as expected.

Here’s a brief overview of the situation:

Problem:

The sharing functionality in my React Native app is successful on various platforms, including Android.
However, when attempting to share on Instagram Stories on iOS, it doesn’t work as intended.
Code Overview:

I’m using Expo and the Sharing module to handle the sharing functionality.
The code is set up to use the instagram-stories://share scheme for Instagram Stories on iOS.
Despite trying multiple approaches and consulting the Expo and Instagram API documentation, the issue persists.

What I’ve Tried:

Dynamically constructing the Instagram Stories URL using Expo and standard URL building practices.
Checking if the Instagram app is installed before attempting to open it.
Adjusting the image format and MIME type to ensure compatibility.
Request for Assistance:
If anyone has encountered a similar issue or has expertise in working with Instagram Stories sharing in React Native, your insights would be greatly appreciated. I’m open to suggestions, debugging tips, or alternative approaches to achieve successful sharing on Instagram Stories.

Thanks in advance for your help!

https://vimeo.com/902378130?share=copy
This is a link to observe the error occurring on an iOS

error when navigating via nuxt-link: Uncaught (in promise) TypeError: Cannot read properties of null (reading ‘parentNode’)

I encountered a problem that when I go to nuxt-link I get an error:

runtime-dom.esm-bundler.js:39 Uncaught (in promise) TypeError: Cannot read properties of null (reading 'parentNode')
at parentNode (runtime-dom.esm-bundler.js:39:30)
at Object.resolve (runtime-core.esm-bundler.js:1517:15)
at Object.resolve (runtime-core.esm-bundler.js:1547:28)
at runtime-core.esm-bundler.js:1646:20

I use the following packages:

<script setup>
import {useIsLoadingStore} from '~/store/auth.store'

const isLoadingStore = useIsLoadingStore()

</script>

<template>
  <LayoutLoader v-if="isLoadingStore.isLoading"/>
  <div v-else style="min-height: 100vh">
    <header>
      <div class="w-full h-auto max-h-[720px] overflow-hidden">
        <slot name="baner"/>
      </div>
    </header>
    <section>
      <div>
        <slot/>
      </div>
    </section>
    <footer>
      <div class="w-full h-[110px] pt-7 pb-[27px] bg-zinc-800 justify-center items-center inline-flex">
        <div class="self-stretch justify-start items-center gap-5 flex">
          <div class="relative">
            <lazy-nuxt-img src="eDnipro_logo.svg" class="md:size-16 size-10"/>
          </div>
          <div class="text-center text-white md:text-2xl text-lg font-normal font-['DniproCity'] leading-7">Розроблено
            єДніпро
          </div>
        </div>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.grid {
  display: grid;
  grid-template-columns: 1fr 6fr;
}
</style>

Here is the project code itself:

default layout

<script setup>
import {useIsLoadingStore} from '~/store/auth.store'

const isLoadingStore = useIsLoadingStore()
</script>

<template>
  <LayoutLoader v-if="isLoadingStore.isLoading"/>
  <div v-else style="min-height: 100vh">
    <header>
      <div class="w-full h-auto max-h-[720px] overflow-hidden">
        <slot name="baner"/>
      </div>
    </header>
    <section>
      <div>
        <slot/>
      </div>
    </section>
    <footer>
      <div class="w-full h-[110px] pt-7 pb-[27px] bg-zinc-800 justify-center items-center inline-flex">
        <div class="self-stretch justify-start items-center gap-5 flex">
          <div class="relative">
            <lazy-nuxt-img src="eDnipro_logo.svg" class="md:size-16 size-10"/>
          </div>
          <div class="text-center text-white md:text-2xl text-lg font-normal font-['DniproCity'] leading-7">Розроблено
            єДніпро
          </div>
        </div>
      </div>
    </footer>
  </div>
</template>

<style scoped>
.grid {
  display: grid;
  grid-template-columns: 1fr 6fr;
}
</style>

app.vue

      <p class="text-stone-300 md:text-lg text-sm font-normal font-['DniproCity']">
        {{ oneNew.attributes?.created }}
      </p>

      <h3 class="text-white mdL:text-[35px] text-lg font-medium font-['DniproCity'] mt-5"
          style="line-height: normal">
        {{ oneNew.attributes?.title }}
      </h3>
    </div>
  </nuxt-link>
</article>

some article code when clicking on nuxt-link an error appears. I couldn’t localize the cause

<div class="grid items-center grid-cols-12 justify-around gap-6 my-10">
    <article
        class="lg:col-span-4 md:col-span-6 col-span-12 w-full lg:h-[600px] h-[400px] relative bg-black rounded-[20px] overflow-hidden hover:cursor-pointer relative"
        v-for="oneNew in news">
      <nuxt-link :to="'/new/'+oneNew?.id">
        <lazy-nuxt-img
            :src="'http://api.forpost.dniprorada.gov.ua' + oneNew?.attributes?.image?.data?.attributes?.url"
            class="h-full w-full object-cover object-center z-0"/>
        <div class="absolute bottom-0 left-0 w-full lg:h-[300px] h-[200px] bg-black bg-opacity-60 z-40 p-5 h-full">

          <p class="text-stone-300 md:text-lg text-sm font-normal font-['DniproCity']">
            {{ oneNew.attributes?.created }}
          </p>

          <h3 class="text-white mdL:text-[35px] text-lg font-medium font-['DniproCity'] mt-5"
              style="line-height: normal">
            {{ oneNew.attributes?.title }}
          </h3>
        </div>
      </nuxt-link>
    </article>
  </div>

The error also appears when making changes to the code and auto reload. If you need additional files or code fragments, speak up!

Nextjs first load isnt loading the css properly

Issue with the first load of the mobile app version; for some reason, the CSS of my component that encompasses the page is not loaded on the initial screen load. However, when changing the size to desktop and then switching back to mobile, it displays correctly. I noticed that by altering the ID “__next,” it ensures that the styles I want to retain stay on the page. However, the logic to check if the screen size is that of a mobile to display another icon is not functioning. Below are some images for reference:

without __next fix

enter image description here

with __next fix

enter image description here

resize from desktop without fix

enter image description here

_document.tsx

/* eslint-disable @next/next/no-sync-scripts */
import React from 'react'
import Document, { Html, Main, NextScript, Head, DocumentContext } from 'next/document'

class CustomDocument extends Document {
  static async getInitialProps(ctx: DocumentContext) {
    const initialProps = await Document.getInitialProps(ctx);
    return { ...initialProps };
  };

  render() {
    return (
      <Html lang="pt-br" id="html">
        <Head>
          <link rel="preconnect" href="https://fonts.googleapis.com"/>
          <link rel="preconnect" href="https://fonts.gstatic.com"/>
          <link rel="apple-touch-icon" sizes="180x180" href="/favicon/apple-touch-icon.png" />
          <link rel="icon" type="image/png" sizes="32x32" href="/favicon/favicon-32x32.png" />
          <link rel="icon" type="image/png" sizes="16x16" href="/favicon/favicon-16x16.png" />
          <link rel="icon" type="image/png" href="/favicon/favicon.ico" />
          <link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,100;0,200;0,300;0,400;0,500;0,600;0,700;0,800;0,900;1,100;1,200;1,300;1,400;1,500;1,600;1,700;1,800;1,900&display=swap" rel="stylesheet"/>
          <link rel="stylesheet" href="node_modules/react-github-contribution-calendar/default.css" type="text/css" />
          <script src="https://kit.fontawesome.com/1e2ddc5739.js"></script>
        </Head>
        <body>
          <Main />
          <NextScript />
        </body>
      </Html>
    )
  }
}

export default CustomDocument

_app.tsx

import Head from 'next/head';
import { AuthProvider } from '../utils/contexts/AuthContext';
import GlobalStyle from '@/components/ui/styles/globalStyles';
import CssBaseline from '@mui/material/CssBaseline';

import { CacheProvider } from '@emotion/react';
import { createEmotionCache } from '@/utils/createEmotionCache';
import { ToastContainer } from 'react-toastify';
import 'react-toastify/dist/ReactToastify.css';
import { LocalizationProvider } from '@mui/x-date-pickers';
import { AdapterDateFns } from '@mui/x-date-pickers/AdapterDateFns';
import { ModalProvider } from '@/utils/contexts/ModalContext';
import { ptBR } from '@mui/x-date-pickers/locales';
import { pt } from 'date-fns/locale'
import { RecoilRoot } from 'recoil';

const clientSideEmotionCache = createEmotionCache();

interface CustomAppProps {
  Component: any;
  pageProps: any;
  emotionCache: any;
}

const App = ({ Component, pageProps, emotionCache = clientSideEmotionCache }: CustomAppProps) => {
  const getLayout = Component.getLayout ?? ((page: any) => page);
  const locale = ptBR.components.MuiLocalizationProvider.defaultProps.localeText;
  return (
    <RecoilRoot>
      <AuthProvider>
        <CacheProvider value={emotionCache}>
          <LocalizationProvider dateAdapter={AdapterDateFns} localeText={locale} adapterLocale={pt}>
            <ModalProvider>
              <Head>
                <title>
                  Blakbelt
                </title>
                <meta
                  name="viewport"
                  content="initial-scale=1, width=device-width"
                />
              </Head>
              <CssBaseline />
              <GlobalStyle />
              <ToastContainer />
              {getLayout(<Component {...pageProps} />)}
            </ModalProvider>
          </LocalizationProvider>
        </CacheProvider>
      </AuthProvider>
    </RecoilRoot>
  );
};

export default App;

HERE Maps custom markers not staying in correct location

I’m using the latest HERE Maps for Javascript. I’m using a custom SVG icon. When the map first loads, the marker appears in about the right location. However, when I zoom out, it moves farther and farther south and away from the provided lat/lng location.

I’ve found references that say the lower edge, some say the upper left, etc. are the anchor point of the custom marker. However, no where can I find in the official documentation what the true anchor point is. Also, why does H.map.Icon allow for passing an anchor but H.map.DomIcon does not?

<template>
  <div class="shipment-map rounded-borders" ref="mapRef"></div>
  <div class="legend rounded-borders">
    <span class="legend-item"
      ><span v-html="legendStarMarker"></span>Starting Load</span
    >
    <span class="legend-item"
      ><span v-html="legendPointMarker"></span>Pickup/Drop Off Stop</span
    >
    <span class="legend-item"
      ><span v-html="legendFlagMarker"></span>Deliver To</span
    >
    <span class="legend-item"
      ><span v-html="legendTruckMarker"></span>Last Known Location</span
    >
  </div>
</template>

<script lang="ts">
///<reference types="@here/maps-api-for-javascript" />
import getEnv from "src/service/env";
import { defineComponent, onMounted, onUnmounted, ref } from "vue";
import { getPointsData } from "stores/shipmentDetailsDataStore";
import { storeToRefs } from "pinia";

let map: H.Map;

export default defineComponent({
  name: "mapShipment",
  props: ["pointsStart", "pointsDestination", "pointsStops", "pointsCurrent"],

  setup(props) {
    const mapRef = ref();
    const platform = ref();
    const ui = ref();
    const behavior = ref();

    const shipmentDetailStore = getPointsData();
    const points = shipmentDetailStore.pointsMapData;

    const { mapsLoading, locationRequestMade } =
      storeToRefs(shipmentDetailStore);

    const flagMarker =
      `<svg xmlns="http://www.w3.org/2000/svg" style="width: 5em; height: 8em; margin: -14px 0 0 -14px;" viewBox="0 0 248 386">
        <g>
          <g>
            <path fill="#C92F33" fill-rule="nonzero" stroke="#B3B3B3" stroke-width="0.634166" d="M124 187c-34,0 -62,-28 -62,-62 0,-34 28,-62 62,-62 34,0 62,28 62,62 0,34 -28,62 -62,62zm123 -63c0,-68 -55,-123 -123,-123 -68,0 -123,55 -123,123 0,20 5,39 13,56 1,2 2,5 4,7 1,2 3,5 5,7l46 73 55 86 55 -86 46 -73 8 -14c9,-17 13,-36 13,-56z"/>
            <path fill="#B3B3B3" fill-rule="nonzero" d="M166 318l-7 13c17,5 28,12 28,18 0,8 -19,20 -51,22 -4,0 -8,0 -12,0 -4,0 -7,0 -11,0 -32,-2 -52,-14 -52,-22 0,-6 11,-14 29,-19l-7 -13c-22,6 -36,18 -36,31 0,21 32,36 75,37 1,0 2,0 2,0 1,0 2,0 4,0 42,-1 73,-16 73,-37 0,-13 -13,-25 -34,-31z"/>
          </g>
          <g>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M62 231l-4 0c-1,0 -2,-1 -2,-2l0 -194c0,-1 1,-2 2,-2l4 0c1,0 2,1 2,2l0 194c0,1 -1,2 -2,2z"/>
            <path fill="white" fill-rule="nonzero" d="M98 165c-21,0 -29,-10 -29,-11l-1 -1 0 -104 6 5c0,0 15,13 51,1 38,-12 74,-12 75,-12l3 0 0 107 -4 0c-27,-4 -38,0 -57,6 -7,2 -14,4 -23,7 -8,2 -15,3 -20,3z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M75 151c3,3 14,12 42,5 9,-2 17,-4 23,-6 19,-6 31,-9 57,-6l0 -93c-10,0 -40,1 -70,11 -28,9 -44,5 -52,1l0 88zm23 14c-21,0 -29,-10 -29,-11l-1 -1 0 -104 6 5c0,0 15,13 51,1 38,-12 74,-12 75,-12l3 0 0 107 -4 0c-27,-4 -38,0 -57,6 -7,2 -14,4 -23,7 -8,2 -15,3 -20,3z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M104 64l0 32c-23,2 -32,-7 -32,-7l0 -32c0,0 9,9 32,7z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M104 128l0 34c-24,2 -32,-9 -32,-9l0 -31c0,0 1,1 3,2 0,0 0,0 1,0 1,1 3,1 5,2 5,2 13,3 23,2z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M136 88l0 32c-1,0 -3,1 -4,1 -1,0 -2,1 -3,1 -1,0 -2,1 -3,1 -1,0 -1,0 -2,1 -1,0 -1,0 -2,1 0,0 -1,0 -1,0 -1,0 -1,0 -2,0 -1,0 -1,0 -2,0 -1,0 -2,1 -4,1 -1,0 -2,0 -3,1l0 0c-1,0 -2,0 -3,0 -1,0 -2,0 -3,0 -1,0 -2,0 -2,0l0 -32c6,-1 14,-2 22,-5 3,-1 7,-2 10,-3z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M168 50l0 32c-10,1 -21,3 -32,6l0 -32c11,-3 22,-5 32,-6z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M168 114l0 33c-10,1 -20,4 -32,8l0 -34c0,0 1,0 1,0 3,-1 6,-1 9,-2 6,-1 11,-2 16,-3 0,0 1,0 1,0 0,0 1,0 1,0 1,0 2,0 4,0z"/>
            <path fill="#2A2A2C" fill-rule="nonzero" d="M200 80l0 32c0,0 -1,0 -4,0 0,0 -1,0 -1,0 -4,0 -10,0 -17,1 0,0 -1,0 -1,0 -2,0 -5,0 -7,1 0,0 -1,0 -1,0 0,0 0,0 0,0l0 -32c19,-2 32,-2 32,-2z"/>
          </g>
        </g>
       </svg>`;

    const initializeMap = () => {
      platform.value = new H.service.Platform({
        apikey: getEnv("HERE_MAPS_JS_API_KEY"),
      });

      const defaultLayers = platform.value.createDefaultLayers();
      map = new H.Map(mapRef.value, defaultLayers.vector.normal.map, {
        center: {
          lat: 38.5,
          lng: -98.35,
        },
        padding: { top: 50, left: 50, bottom: 50, right: 50 },
        zoom: 4,
      });

      map.getBaseLayer().setMin(3).setMax(7); // min/max map zoom

      ui.value = H.ui.UI.createDefault(map, defaultLayers);
      ui.value.setUnitSystem(H.ui.UnitSystem.IMPERIAL);

      const mapEvents = new H.mapevents.MapEvents(map);
      behavior.value = new H.mapevents.Behavior(mapEvents);
      addEventListener("resize", () => map.getViewPort().resize());
    };

    const addInfoBubble = (
      position: H.geo.IPoint,
      content: HTMLElement
    ): void => {
      const infoBubble = new H.ui.InfoBubble(position, {
        content,
      });
      ui.value.addBubble(infoBubble);
    };

    const group = new H.map.Group();

    const addMarker = (
      coordinates: H.geo.IPoint,
      icon: string | Element,
      bubbleContent?: HTMLElement
    ) => {
      const customIcon = new H.map.DomIcon(icon);
      const pointerMarker = new H.map.DomMarker(coordinates);

      pointerMarker.setIcon(customIcon);
      group.addObject(pointerMarker);
      if (bubbleContent) addInfoBubble(coordinates, bubbleContent);
    };

    const addMarkers = () => {
      try {
        if (
          props.pointsDestination &&
          props.pointsDestination.lat != 0 &&
          props.pointsDestination.lng != 0
        ) {
          console.log(props.pointsDestination);
          const dropOffFlag: H.geo.IPoint = {
            lat: props.pointsDestination.lat,
            lng: props.pointsDestination.lng,
          };
          addMarker(dropOffFlag, flagMarker);
        }
      } catch (error) {
        console.error("Error adding marker:", error);
      }
    };

    const fitMapToMarkers = () => {
      map.addObject(group);

      map.getViewModel().setLookAtData(
        {
          bounds: group.getBoundingBox(),
        },
        true
      );
    };

    const clearMarkers = () => {
      const bubbles = ui.value.getBubbles().slice();
      bubbles.forEach((bubble) => {
        ui.value.removeBubble(bubble);
        bubble.dispose();
      });

      const mapObjects = map.getObjects();
      map.removeObjects(mapObjects);
    };

    onMounted(() => {
      setTimeout(() => {
        initializeMap();
      }, 1000);

      setTimeout(() => {
        clearMarkers();
        addMarkers();
      }, 1000);

      setTimeout(() => {
        fitMapToMarkers();
      }, 1000);
    });

    onUnmounted(() => {
      clearMarkers();
    });

    return {
      mapRef,
      points,
      mapsLoading,
      legendStarMarker,
      legendPointMarker,
      legendTruckMarker,
      legendFlagMarker,
      locationRequestMade,
    };
  },
});
</script>

<style lang="scss">
.shipment-map {
  height: 400px;
  padding: 0.5rem 0.5rem 0;
}

.legend {
  background: var(--app-medium-grey);
  color: #fff;
  display: flex;
  font-weight: bold;
  justify-content: left;
  margin: -2px 0.5rem 0px 0.5rem;
  padding: 0.5rem 1rem;

  .legend-item {
    display: flex;
    align-items: center;
    margin-right: 2rem;

    svg {
      display: flex;
      align-items: center;
      height: 2rem;
      width: 2rem;
      margin-right: 0.4rem;
    }
  }
}
</style>

RequestedBy returning null

Everything is doing fine, but track.requestedBy.tag is returning null and i dont know why. It’s actually a discord bot with music control and what you are seeing is Embed with tracks queue list, im not a expert in js so you might see problems in code

const { useTimeline, useQueue} = require("discord-player")

const {
    EmbedBuilder, time
} = require("discord.js");

module.exports = {
    data: {
        name: `music.queueButton`
    },
    async execute (interaction, client) {
        const timeline = useTimeline(interaction.guildId);
        const queue = useQueue(interaction.guildId);

        await interaction.deferReply({
            ephemeral: true,
            fetchReply: true
        });

        if (!timeline) {
            await interaction.editReply({
                content: "There is no currently playing track"
            });
            return;
        }

        const track = timeline.track;
        const tracks = queue.tracks.toArray();

        const Embed = new EmbedBuilder()
            .setAuthor({ name: `${track.author} - ${track.title} - ${track.duration}` })
            .setTitle("Queue")
            .setDescription("List of tracks currently played:")
            .setImage(track.thumbnail)
            .setFooter({ text: `Requester is ${track.requestedBy.tag} - ${timeline.timestamp}`, iconURL: `${track.requestedBy.avatarURL()}` }) //Here is the error

        if (tracks < 1) {
            Embed.addFields({name: "No tracks", value: "in queue"})
        }

        for (let i = 0; i < tracks.length; i++) {
            const iTrack = tracks[i];
            Embed.addFields(
                { name: `${i+1}. ${iTrack.title}`, value: `${iTrack.author}` }
                )
        }

        await interaction.editReply({
            embeds: [Embed]
        })
    }
}

Really dont know what i’ve could try. I were expecting to see footer: Requester is namecurrent timeline of track

How to use external scripts in bundled React components?

I’m trying to load React and ReactDOM externally instead of providing them in the bundle. You can see my attempt at a solution below but it is not working. It works when I put all React calls in the client.js file but it seems to stop working when I try to import components from other files.

How can I use the external React in my components and avoid bundling it?

client.js:

import App from './App.jsx';

let page_initialised = false;

async function init() {
    if (!window.React || !window.ReactDOM) {
        return;
    }
    if (page_initialised) {
        return;
    }
    page_initialised = true;

    ReactDOM.hydrateRoot(document, <App />);
}

init();
document.querySelector('#react').addEventListener('load', init);
document.querySelector('#react_dom').addEventListener('load', init);

and have to import App like this too to no avail

    const App = await import('./App.jsx');
    ReactDOM.hydrateRoot(document, <App />);

App.jsx:

const Root = React.lazy(() => import('./Root.js'));

export default function App() {
    const [counter, setCounter] = React.useState(0);
  
    return (
      <html>
        <head>
          <script id="react" crossOrigin="anonymous" src="https://unpkg.com/[email protected]/umd/react.development.js" async></script>
          <script id="react_dom" crossOrigin="anonymous" src="https://unpkg.com/[email protected]/umd/react-dom.development.js" async></script>
          <script src="/client.js" async></script>
        </head>
        <body>
          <div id="root">
            <React.Suspense fallback={<>
              <include src="Root_fallback.html"></include>
            </>}>
              <Root />
            </React.Suspense>
          </div>
        </body>
      </html>
    )
  }

enter image description here
Image 1: The error message I’m getting

enter image description here
Image 2: My app structure as seen in the firefox devtools

How extract id from react router with useparams

this is my code why it shows id undefined? i want in the sale component access to both title & id of each book but id is undefined.how can i show the value of id in the Sale component? thank you for your help!
App.js

  <Route path="books" element={<Dashboard />} />
  <Route path="books/:booktitle" element={<BookDetails />} />
  <Route path="books/:booktitle/sale/:id" element={<SaleStore />} />

Dashbaord:

 {books.map((book) => (
                  <div className="col" key={book.id}>
                    <div className="card h-100" >
                      <div className="card-img-top pb-5 mb-5">
                      </div>
                      <div className="card-body">
                        <Link to={`/books/${encodeURIComponent(book.title)}`}>
                          <button type="submit" className="btn custome-btn purple-active-ghost w-100">
                            {book.title}
                          </button>
                        </Link>
// rest of code

Detail:

  const { booktitle, id } = useParams();
  console.log("book Title:", booktitle);
  console.log("book Id:", id);
                     <Link to={`/books/${encodeURIComponent(booktitle)}/sale/${id}`}>
                          <button type="submit" className="btn custome-btn purple-active-ghost w-100">
                              go to sale
                          </button>
                        </Link>

Sale:

  const { booktitle, id } = useParams();
  console.log("book Title:", booktitle);
  console.log("book Id:",id);
  
        <p>{booktitle}</p> // 
      <p>{id}</p> // undefiend

Turn a Svelte Component into HTML, CSS, and JS

My ideal end goal:

Dynamically output HTML, CSS, and JS from a Svelte component so I can host it elsewhere (e.g. S3 bucket).

Context:

  1. I have a Svelte app that collects information from users
  2. From this information, I have to generate a website
  3. The user can select layout options and a color palette
  4. These options will be passed down to the component that needs to be converted into HTML, CSS, and JS.

Questions:

  1. Is this possible? I can see Svelt REPL/W3Schools/etc. have something similar (component on the left, dynamically generated web page on the right)
  2. Can I use a CSS framework like Tailwind in the component?
  3. In the best-case scenario, the user will change the options, and the dynamic website will update in near-real-time. Doable?

Example:

// website.svelte

<script lang="ts">
    export let layout: string;
    export let colors: string[];
    const onClick = () => alert(5);
</script>

<button class="text-bold" on:click={onClick}>{text}</button> // Tailwind class
<section class={layout + colors}>...stuff</section>
// builder.svelte
<script lang="ts">
    import Website from './website.svelte';

    let srcdoc: string;

    const generate = async () => {
        // const props = {layout: 'grid', colors: ['blue', 'green']};
        // const {js, html, css} = new Website(...props).decompile();
        // srcdoc = `<style>${css}</style> ${html} <script>${js}</script>`;
    };
</script>

<button on:click={generate}>Generate</button>
<iframe title="Dynamic website" {srcdoc}></iframe>

Possible solutions

  1. new Website({target: domElement}) and then take the innerHTML. This works only for the HTML. The CSS/JS is nowhere to be seen.
  2. Perhaps I can create a separate Svelte project and invoke the iframe with a src instead of a srcdoc and pass the props in the query string. When the user is happy with their configuration, I will save it to a database and deploy the other Svelte project with that configuration for each user.
  3. Make use of web components somehow.