Obfuscate email address to hide from scrapers?

I want to hide my personal data (email and phone) from scrapers and bots. This data is in the href of anchor tags. Of course, actual users should still be able to have functional clickable links.

I was thinking to use a simple JavaScript function to encrypt and decrypt the data so that patterns matchers (*@*.* etc) who only get the HTML code won’t find the actual email address.

So my encryption function is to convert the string to a list of character codes, incrementing all list elements by 1, and converting it back to a string. See below for the code.

My question: Is this an adequate way to hide data from scrapers? Or does every scraper render JS nowadays?

The code:

function stringToCharCodes(string) {
    // Returns a list of the character codes of a string
    return [...string].map(c => c.charCodeAt(0))
}

function obfuscate(string) {
    // Obfuscate - Use developer tools F12 to run this once and then use the obfuscated string in your website

    // String to character codes
    let charCodes = stringToCharCodes(string);

    // Obfuscate function (+1)
    let obfCharCodes = charCodes.map(e => e += 1);

    // Character codes back to string 
    // Use spread operator ...
    return String.fromCharCode(...obfCharCodes);
}

function deobfuscate(obfString) {
    // String to character codes
    let obfCharCodes = stringToCharCodes(obfString);

    // Deobfuscate function (-1)
    let deobfCharCodes = obfCharCodes.map(e => e -= 1);

    // Character codes back to string 
    // Use spread operator ...
    return String.fromCharCode(...deobfCharCodes);
}

// Result of obfuscate("[email protected]")
let obfEmail = "fybnqmfAfybnqmf/dpn";  
document.getElementById("email").href = "mailto:" + deobfuscate(obfEmail);

// Result of obfuscate("31612345678")
let obfPhone = "42723456789";
document.getElementById("whatsapp").href = "https://wa.me/" + deobfuscate(obfPhone);

See a JSFiddle

Uncaught SyntaxError: missing ) after argument list while using onclick event

I am a beginner in JavaScript and I am facing a problem while using the onclick event
Can you please help me?

movie1.innerHTML = `
                <img src="${IMG_URL + poster_path}" alt="Poster">
                <p class="title">${title}</p>
                <span>Rating : ${vote_average}</span>
                <div class="summary">
                    <p>${overview}</p>
                </div>
              <button class="watchbtn" onclick="passname(${title})" >Watch</button>
            </div>
        `;

In the Above code I get an error which shows “Uncaught SyntaxError: missing ) after argument list”

Move text only when scrolling – Framework?

Hello, everyone!

Is there a framework or something else that makes it easy to move text (to the left or right) when the user scrolls (for example near the footer)? So a pure scroll animation.

Thank you in advance!

I tried Scrollmagic, but i cant handle it. :/

Javascript array reset not working in Angular application

I have the following function on clicking a button. Now even though I clear the array when the button is clicked for the second time, the array value is still there, so I can see two values in the console log. I am doing this in Angular and am not sure how to fix this issue. Any help will be appreciated.

updateLeaveApplication(event) {

    let leaveID = [];
    leaveID.length = 0;

    console.log(leaveID);

    if (_.isArray(event.leave_id)) {
      _.forEach(event.leave_id, function (value) {
        leaveID.push(value.leave_id);
      });
    } else {
      leaveID.push(event.leave_id);
    }
}

How check condition of checkbox when uncheck/check with id of HTML

I’m using css and javascript to check condition of value of partner Code is null and 01

Step 1: if user check checkbox is PARTNER, value of partnerName '01 - Elite' and value of partnerCode is '01' will send when submit
Step 2: if user uncheck checkbox is PARTNER, value of partnerName is 'NULL' and value of partnerCode is 'NULL' will send when submit

this is my code:

     <tr>
          <th scope="row">Partner</th>
          <td colspan="0" style="margin-top: 4px;">
                 <input id="parnerNameCheck" name="parnerNameCheck" type="checkbox"/><span>PARTNER</span>
            </td>
            <td>
                <select id="partnerName" name="partnerName" disabled>
                    <option value="" selected>Choose One</option>
                    <option>01 - Elite</option>
                 </select>
            </td>
            <td>
                <input id="partnerCode" name="partnerCode" type="hidden" value="01" />
            </td>
          </tr>           
          
          <script>
          $('#parnerNameCheck').click(function() {
              console.log('parnerNameCheck  checked:' + $("#parnerNameCheck").is(":checked"));
              $('#partnerName').prop("disabled", !$(this).prop("checked"));
              $('#partnerCode').prop("disabled", !$(this).prop("checked"));     
          });
          </script>

but when i uncheck checkbox is PARTNER, value of partnerCode is 01 still sending when submit.
So how to fix the problem? thank a lot

React router dom renders a blank page

I am new to react-router-dom for the first time . I am using react-router-dom to switch between pages and it is rendering a blank page, only the navbar component is rendering. When I render the home and auth components individually outside the Routes, they render successfully.Please help me debugging this code.

Here is my App.js

import React from 'react';
import { Container } from '@material-ui/core';
import { BrowserRouter , Route , Routes } from 'react-router-dom'

import Home from './components/Home/Home';
import Navbar from './components/Navbar/Navbar';
import Auth from './components/Auth/Auth';

const App = () => (
  <BrowserRouter>
    <Container maxWidth="lg">
      <Navbar />
      {/* <Home/>
      <Auth/> */}
      <Routes>
        <Route exact path="/"  component={Home} />
        <Route exact path="/auth"  component={Auth} />
      </Routes>
    </Container>
  </BrowserRouter>
);

export default App;

Here is my package.json

{
  "name": "client",
  "version": "0.1.0",
  "private": true,
  "proxy": "http://localhost:5000/",
  "dependencies": {
    "@material-ui/core": "^4.12.3",
    "@material-ui/icons": "^4.11.2",
    "@testing-library/jest-dom": "^4.2.4",
    "@testing-library/react": "^9.3.2",
    "@testing-library/user-event": "^7.1.2",
    "axios": "^0.19.2",
    "moment": "^2.27.0",
    "react": "^16.12.0",
    "react-dom": "^16.12.0",
    "react-file-base64": "^1.0.3",
    "react-google-login": "^5.2.2",
    "react-redux": "^7.2.6",
    "react-router-dom": "^6.2.2",
    "react-scripts": "3.4.1",
    "redux": "^4.0.5",
    "redux-thunk": "^2.3.0"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app"
  },
  "browserslist": {
    "production": [
      ">0.2%",
      "not dead",
      "not op_mini all"
    ],
    "development": [
      "last 1 chrome version",
      "last 1 firefox version",
      "last 1 safari version"
    ]
  },
  "devDependencies": {
    "eslint-config-airbnb": "^18.2.0",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-jsx-a11y": "^6.3.1",
    "eslint-plugin-react": "^7.20.6",
    "eslint-plugin-react-hooks": "^4.1.0"
  }
}


cannot delete document from firebase firestore

I cannot delete documents with the delete() function in firestore. the function doesn’t give an error in the console but doesn’t delete the document. I have no idea what to do please help.

import React from "react";
import { useState, useEffect } from "react";
import { firestore, auth } from "../firebaseConfig";

const containerStyles = {
  display: "flex",
  flexDirection: "column",
  alignItems: "center",
  margin: "10px",
  marginTop: "30px",
};

const requests = () => {
  const [receivedRequests, setReceivedRequests] = useState([]);
  useEffect(() => {
    fetchReceivedRequests();
  }, []);
 const acceptRequest = async (uid, event) => {
    event.preventDefault();
    try {
      firestore
        .collection("users")
        .doc(uid)
        .get()
        .then((doc) => {
          const currentUserRef = firestore
            .collection("users")
            .doc(auth.currentUser.uid);
      

          const sendersRef = firestore.collection("users").doc(uid);
     

          currentUserRef.collection("chats").doc(uid).set({
            email: doc.data().email,
            name: doc.data().name,
            uid: uid,
            phoro: doc.data().photo,
          });
      

          sendersRef.collection("chats").doc(auth.currentUser.uid).set({
            email: auth.currentUser.email,
            name: auth.currentUser.displayName,
            photo: auth.currentUser.photoURL,
            uid: auth.currentUser.uid,
          });
        
          currentUserRef.collection("receivedRequests").doc(uid).delete();
         

          sendersRef
            .collection("sentRequests")
            .doc(auth.currentUser.uid)
            .delete();
        
        });
    } catch (err) {
      console.error(err.message);
    }
  };

  const declineRequest = async (uid, event) => {
    event.preventDefault();
    
    try {
      const currentUserRef = firestore
        .collection("users")
        .doc(auth.currentUser.uid)
        .collection("recievedRequests")
        .doc(uid);
      const docRef = firestore.collection("users").doc(uid);

      await currentUserRef.delete();
      
      await docRef
        .collection("sentRequests")
        .doc(auth.currentUser.uid)
        .delete();
     
    } catch (e) {
      console.error(e.message);
    }
  };

return(
<>
{receivedRequests.length === 0 ? (
          <h2>No Requests</h2>
        ) : (
          receivedRequests.map((request) => (
            <div
              key={request.uid}
              style={{
                display: "flex",
                borderTop: "2px solid grey",
                borderBottom: "2px solid grey",
                alignItems: "center",
                justifyContent: "space-between",
                padding: "9px",
                width: "100%",
                margin: 0,
              }}
            >
              <div
                style={{
                  display: "flex",
                  alignItems: "center",
                }}
              >
                <img
                  src={request.photo}
                  style={{
                    width: "75px",
                    height: "75px",
                    borderRadius: " 50%",
                    marginRight: "10px",
                  }}
                />
                <h2>{request.name}</h2>
              </div>
              <div>
                <button
                  style={{
                    margin: "10px",
                    background: "rgb(07 181 254)",
                    color: "white",
                    padding: "11px",
                    width: "102px",
                    border: "none",
                    borderRadius: "12px",
                    fontWeight: "bold",
                  }}
                  onClick={(e) => acceptRequest(request.uid, e)}
                >
                  Accept
                </button>
                <button
                  style={{
                    margin: "10px",
                    background: "#a5a5a5",
                    color: "white",
                    padding: "11px",
                    width: "102px",
                    border: "none",
                    borderRadius: "12px",
                    fontWeight: "bold",
                  }}
                  onClick={(e) => declineRequest(request.uid, e)}
                >
                  Decline
                </button>
              </div>
            </div>
          ))
        )}
</>
)


}

I even tried some code that I wrote earlier that worked in the other project but It just doesn’t work in this one. What do I do?

Thanks

The requested module … does not provide an export named

I’m trying to import a default export from a module in Vue 3 and I’m getting the following error –

Uncaught SyntaxError: The requested module '/src/views/FlashcardView.vue?t=1648376545088' does not provide an export named 'FlashcardView'

I’m trying to import this component –

*** Flashcardview.vue ***

<script lang="ts">
  export default {
    name: "FlashcardView",
    methods: {
      flipCard() {
        document.getElementById("flashcard-container").style.backgroundColor = "red";
      }
    }
  }
</script>

into my root component –

<script lang="ts">
  import { RouterView } from "vue-router";
  import FlashcardView  from "./views/FlashcardView.vue";
  export default {
    name: "App",
    components: {
      Router: RouterView,
      FlashcardApp: FlashcardView
    }
  }
</script>

According to this page – Uncaught SyntaxError: The requested module ‘./add.js’ does not provide an export named ‘add’ I’m doing the right thing by importing my default export without the curly braces.

So… What gives?

Socket.IO get current room from socket or data

In my scenario a user can join multiple room. Can I understand from which room the user is sending a message on the server? In the example below, I am sending the ID of the room the user is sending the message to in the package.

Client Side

  ...
    const SendMessage=()=>{
      // Get active room id
      const selectedRoomId = document.getElementById("channelList").value;
      socket.emit('srv-chat-message', 
      { 
        'roomId':selectedRoomId, 
        'message':'Hello world' 
      });
    }
 ...

Server Side

 ...
 socket.on('srv-chat-message', (data) => {     
    io.to(data.roomId).emit('cln-chat-message', {
      message: 'Hello from server'
    }); 
 });
 ...

Accessing Functions, Variables and others from one script and being able to use them in another

If there is a java script file with some functions and some variables and another java script file that wants to access them or use them in what way can it do that?

I have a js file with something like lets say

const info = {
     get: function(){
     console.log("Getting information")
     }
}

And now lets say i want to call that function in my other js script:

info.get()

Yet it does not seem to work as some pointed out it may be because the first script is ran after the second one so that may be the problem.

Im using node.js and js to run my program.

Another way i could do that is manually which is to convert the script into a string with

fs.readfileSync("The path to the script");

then find each line that contains it and then run a function.
That might work but it will not be as great when there are variables involded into the mix. Thats why im asking if there is another, more suitable for long term use way?

As i mentioned it may be because the first script is ran after the second one, and if thats so… how can i make the run before that in the actual project itself? I could combine it into one whole script but that basically defeats the entire point of my question which is.. is there a way i can access them in a seperate file?

Could i require it like a library?:

const firstScript=require("path to first script");

Again it doesn’t seem to function like that. I tried googling it but nothing popped up, everything was just html.

I told you a couple of ways i tried doing things, but if anyone finds a better more suitable way of doing things rather than just .slice .indexOf, manual way please do tell me, i would love to hear what you found