How i can solve this issue mix with installing web3.js?

npm install web3
npm ERR! code ETIMEDOUT
npm ERR! syscall connect
npm ERR! errno ETIMEDOUT
npm ERR! network request to http://registry.npmjs.org/web3 failed, reason: connect ETIMEDOUT 2606:4700::6810:1323:80
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network ‘proxy’ config is set properly. See: ‘npm help config’

npm ERR! A complete log of this run can be found in:
npm ERR! /home/lord/.npm/_logs/2022-04-13T16_43_18_886Z-debug-0.log

how to download a pdf file with url link in Reactjs

import LocalPdf from '../../assets/img/news_pdf/local.pdf
<a href={LocalPdf} download>download here</a>

above anchor tag working fine but if we provide a link to “href”. The pdf file opens but not downloading. How can I make it download with “URL” as above lines.

<a href="https://awsExample.com/awsPdf/loacalToaws.pdf" download>download here</a>

jQuery Pjax and javascript problem when clicking a link for the second time

In my php website I am using pjax with a container #view
and I am using this code to load the js scripts based on the [ui-script] attribute that I have attached to the html dom as show below:

<div class="padding" ui-script="dashboard">

and then pjax looks for that attribute and loads that dashboard.js script.

(function ($, MODULE_CONFIG) {
"use strict";

$.fn.uiScript = function(){

    var lists  = this;

    lists.each(function()  {
        var $self = $(this);
        var scripts = $self.attr('ui-script').replaceAll(' ', '');
        if(scripts.indexOf(",") > -1) {
            scripts = scripts.split(",");

            $.each(scripts, (i, script) => {
                console.log(script)
                uiLoad.load(MODULE_CONFIG[script]);
            })
        } else {
            uiLoad.load(MODULE_CONFIG[$self.attr('ui-script')]);
        }
    });

    return lists;
}

})($, MODULE_CONFIG);

MODULE_CONFIG is an object that holds all the scripts src paths.

and the uiLoad function is as shown below:

var uiLoad = uiLoad || {};

(function($, $document, uiLoad) {
"use strict";

var loaded = [], promise = false, deferred_ = $.Deferred();

uiLoad.load = function (srcs) {
    if(typeof srcs != "undefined") {
        srcs = Array.isArray(srcs) ? srcs : srcs.split(/s+/);
        if(!promise) { promise = deferred_.promise(); }

        $.each(srcs, function(i, src) {
            promise = promise.then(function() { return loadScript(src); });
        });
        deferred_.resolve();
        return promise;
    }
};

// ----------------------------- //

var loadScript = function (src) {
    if(loaded[src]) {
        console.log("reloaded " + src);
        return loaded[src].promise();
    }

    var deferred = $.Deferred();
    var script = $document.createElement('script');
    script.src = src;
    script.onload = function(e) {
        console.log("loaded " + src);
        deferred.resolve(e);
    };
    script.onerror = function (e) {
        console.log("failed to load " + src);
        deferred.reject(e);
    };
    $document.body.appendChild(script);
    loaded[src] = deferred;
    console.log(loaded[src])

    return deferred.promise();
};

})(jQuery, document, uiLoad);

And then I use this code to reinit the js scripts on pjax:end

$(document).on('pjax:end', function(e) {
    $("body").find('[ui-script]').uiScript();
});

But all the scripts work only once .. the first time. when revisiting the same page again for the second time they don’t work. like they aren’t recognizing the new DOM. any idea why?

Get active iframe header and favicon and set variables

I am attempting to get an iframe header and favicon to display on my site, I already have the display setup but I am having trouble getting the header and favicon url and set them to variables, and every time the iframe website/url changes I need the variables to update. I have also tried basic iframe requests but have had trouble getting them to work.
Currently I am using a javascript iframe.

Make config file available to js file in public folder in express app

I have an express app with the following folder structure

app
│        
│
└───config
│   │   config.js
│           
│   
└───public
│   │   
│   └───javascripts
│       │   exportable.js
│   

The exportable.js is a .js file that renders and displays a table in the frontend of the app.
I have a request to add another information to the table which includes a link to a filesystem of ours. Depending on the environment the app is running in (e.g. prod or dev) the ip address of the link changes accordingly as it does with all the other systems that the app is connected to.

All the system information is stored in the config.js file which for the other files outside of the public folder I can normally import via require(./config).

Unfortunately, this way doesn’t work for the files which are inside the public folder.
If I try importing the config.js file the same way, I receive an Uncaught ReferenceError: require is not defined error.

In other threads if came across the suggestion of import the file something through the likes of <script src="config.js"></script>. However, this is not working neither. Trying this, I receive the error: Uncaught SyntaxError: Unexpected token '<'

Is there any other solutions making the information located in the config.js file available to the exportable.js file?

DiscordJS v12 Enable/Disable Event Quick.db

I am trying to make a command that if args[0] is on it stores it in the quick.db database as enabled and if off it stores it as disabled to turn off or on an event

Toggle ON/OFF Command:

        db.get(`unknown_${message.guild.id}`)
        if (args[0]) {
            if (args[0].toLowerCase() === "off") {
                let disabled = new Discord.MessageEmbed()
                    .setColor(ee.color)
                    .setAuthor('Unknown Command Response', client.user.avatarURL())
                    .setThumbnail('https://icons.iconarchive.com/icons/dtafalonso/android-lollipop/512/Settings-icon.png')
                    .addFields(
                        { name: '__**Status**__', value: ':white_circle: Disabled', inline: true },
                    )

                db.set(`unknown_${message.author.id}`, 'disabled')

                return message.channel.send(disabled)
            }
        }
        if (args[0]) {
            if (args[0].toLowerCase() === "on") {
                let enabled = new Discord.MessageEmbed()
                    .setColor(ee.color)
                    .setAuthor('Unknown Command Response', client.user.avatarURL())
                    .setThumbnail('https://icons.iconarchive.com/icons/dtafalonso/android-lollipop/512/Settings-icon.png')
                    .addFields(
                        { name: '__**Status**__', value: ':green_circle: Enabled', inline: true },
                    )

                    db.set(`unknown_${message.author.id}`, 'enabled')

                return message.channel.send(enabled)
            }
        }

Event:

    else {
      db.get(`unknown_${message.guild.id}`)
      if (db.has(`unknown_${message.guild.id}`, 'enabled')) {
        return message.channel.send(new Discord.MessageEmbed()
          .setColor(ee.wrongcolor)
          .setFooter(ee.footertext, ee.footericon)
          .setTitle(`<:warning:943421375526355024> Unkown command, try: **`${prefix}help`**`)
          .setDescription(`.setup has a list of info you might need`)
        ).then(msg => msg.delete({ timeout: 5000 }).catch(e => console.log("Couldn't Delete".gray)));
      }
      else if (db.has(`unknown_${message.guild.id}`, 'disabled')) {
        return
      }
    }

Getting CORS error in frontend with Django backend

From my frontend http://127.0.0.1:5500/index.html I am calling Django REST POST API http://127.0.0.1:8000/api. I have installed django-cors-headers and my frontend’s image_upload.js, backend’s settings.py, and views.py, project level urls.py and app level urls.py are as follows, API is working in postman but I am getting CORS error in chromes console,

Chrome console

enter image description here

Django console

enter image description here

image_upload.js

const image_input = document.querySelector("#image_input");
const display_image = document.querySelector("#display-image");
image_input.addEventListener("change", (event) => {
  console.log(event.target.files[0]);
  // console.log(URL.createObjectURL(event.target.files[0]));
  display_image.src = URL.createObjectURL(event.target.files[0]);

  const url = "http://127.0.0.1:8000/api";
  const data = event.target.files[0];

  axios
    .post(url, JSON.stringify(data), {
      method: "POST",
      headers: {
        "Content-Type": "application/json",
        "Access-Control-Allow-Origin": "*",
      },
    })
    .then(function (response) {
      console.log(response);
    })
    .catch(function (error) {
      console.log(error);
    });
});

settings.py

"""
Django settings for model project.

Generated by 'django-admin startproject' using Django 2.2.

For more information on this file, see
https://docs.djangoproject.com/en/2.2/topics/settings/

For the full list of settings and their values, see
https://docs.djangoproject.com/en/2.2/ref/settings/
"""

import os


# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))


# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/2.2/howto/deployment/checklist/

# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'pd^*8)+5$qr_q9(a+n)(meh22&m=0+qn7a^g8$#&)(+fv!1wgc'

# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True

ALLOWED_HOSTS = ['http://127.0.0.1:5500']


# Application definition

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',

    # 3rd party
    'rest_framework',
    "corsheaders",

    # Local
    'apis.apps.ApisConfig',
]

REST_FRAMEWORK = {
    'DEFAULT_PERMISSION_CLASSES': [
        'rest_framework.permissions.AllowAny',
    ],
}

MIDDLEWARE = [
    'django.middleware.security.SecurityMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    "corsheaders.middleware.CorsMiddleware",
    'django.middleware.common.CommonMiddleware',
    'django.middleware.csrf.CsrfViewMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    'django.contrib.messages.middleware.MessageMiddleware',
    'django.middleware.clickjacking.XFrameOptionsMiddleware',
]


# CORS_ALLOWED_ORIGINS = [
#     'http://127.0.0.1:8000',
# ]

# CSRF_TRUSTED_ORIGINS = [
#     'http://127.0.0.1:8000',
# ]

ROOT_URLCONF = 'model.urls'

TEMPLATES = [
    {
        'BACKEND': 'django.template.backends.django.DjangoTemplates',
        'DIRS': [],
        'APP_DIRS': True,
        'OPTIONS': {
            'context_processors': [
                'django.template.context_processors.debug',
                'django.template.context_processors.request',
                'django.contrib.auth.context_processors.auth',
                'django.contrib.messages.context_processors.messages',
            ],
        },
    },
]

WSGI_APPLICATION = 'model.wsgi.application'


# Database
# https://docs.djangoproject.com/en/2.2/ref/settings/#databases

DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.sqlite3',
        'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
    }
}


# Password validation
# https://docs.djangoproject.com/en/2.2/ref/settings/#auth-password-validators

AUTH_PASSWORD_VALIDATORS = [
    {
        'NAME': 'django.contrib.auth.password_validation.UserAttributeSimilarityValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.MinimumLengthValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.CommonPasswordValidator',
    },
    {
        'NAME': 'django.contrib.auth.password_validation.NumericPasswordValidator',
    },
]


# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/

LANGUAGE_CODE = 'en-us'

TIME_ZONE = 'UTC'

USE_I18N = True

USE_L10N = True

USE_TZ = True

CORS_ORIGIN_ALLOW_ALL: True

# CORS_ALLOW_CREDENTIALS = True

# CORS_ALLOWED_ORIGINS = [
#     'http://127.0.0.1:8000/api/',
#     'http://127.0.0.1:5500',
# ]

CORS_ORIGIN_WHITELIST = [
    'http://127.0.0.1:5500',
    # 'http://127.0.0.1:8000',
]

# CORS_ALLOW_HEADERS = ['*']

# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.2/howto/static-files/

STATIC_URL = '/static/'

views.py

from email import message
from tkinter import image_names
from django.shortcuts import render
from django.http.response import JsonResponse
from rest_framework.parsers import JSONParser
from rest_framework import status
from rest_framework.decorators import api_view

from tensorflow.keras.models import load_model
import urllib.request

# Create your views here.

@api_view(['GET', 'POST'])
def PostRequests(request):
  print(request.body)
  # ing_url = ''
  # img_name = "tumor_image.jpg"
  # img = urllib.request.urlretrieve(img_url,img_name)
  # print(img)
  # loaded_model = load_model("vgg16_model_with_90_acc.h5")
  return JsonResponse({'message': "It Worked!"}, safe=False)

Project level urls.py

from django.contrib import admin
from django.urls import path, include

urlpatterns = [
    path('admin/', admin.site.urls),
    path('api/', include('apis.urls')),
]

App level urls.py

from django.urls import path


from apis import views


urlpatterns = [
  path('', views.PostRequests),
]

how to control youtube with chrome extension manifest v3

I have a finals project in which i want to have a synced up video running on seperate computers via a web socket server – in the past week i tried to figure out how to control youtube over the webpage with a js script but nothing works – Ive seen that there is no information to how to do it in the most basic way – i am new to js and html and would love some help
i get csp errors every time i try to use the external api of youtube when i try to work with an embeded video and when i try to control youtube itself i just didnt figure out how

i saw that the line “script-src ‘self’ http://xxxx ‘unsafe-inline’ ‘unsafe-eval’;” will help but i dont know where to implement it. Thank you in advance <3that the error ive been geting when trying to work with embeded

Connection between AngularJS and React using single-spa

I’m trying to connect two applications.
First is written in AngularJS. It’s a big application with many parts adding with bower from other repositories. All these parts are written in AngularJS.
Second application is microfrontend written in React as single-spa microfrontend (I want to replace AngularJS with React).

Microfrontend is listening on url and after that loads the project. Problem is that whole page (written in angularJS) is replaced by microfrontend (React app) when this url is changed.

I’m looking for a way how to display AngularJS app, but replace only one part of this AngularJS app with component from microfrontend written in React.

Has anyone had a similar problem and resolved that in some way?

net::ERR_FILE_NOT_FOUND, no typos and files are in the same directory

I have an index.html file with <script src=”sc2.js”></script> in the head section. In the same directory I have file sc2.js that has some really simple JavaScript code I wanted to test to see what it prints. The html displays correctly in my browser, but the console says:

index.html:8 GET file:///Users/myname/projectfile/%E2%80%9Dsc2.js%E2%80%9D net::ERR_FILE_NOT_FOUND

Am I missing something to make it possible to run the code in my browser? I can still run old JavaScript projects in the browser with no problems. I also tried to move the script tag around and add the full path, which made no difference. The code works in jsfiddle.net. I’m using Chrome Canary.

API error when someone deletes message reacted by bot Discord.JS

I’m new to the programming world and I decided to start learning JavaScript, first with Discord bots. How can I fix my bot that stops working when someone deletes or edits the message?

    if (message.channel.id === 'ChannelID') {
        message.react('✅')
                .then(() => { 
        message.react('❌')
                });
}
    if (message.channel.id === 'ChannelID') {
        message.react('⭐');
}
    if (message.channel.id === 'ChannelID') {
        message.react('⬆️')
                .then(() => {
        message.react('⬇️')
                });
    }
});```