Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

272
Views
Chrome Extension, HTTP request to NodeJS

I want to create a Chrome Extension that works with Facebook. I took random text from https://randomtextgenerator.com/ (first paragraph) and now I want to use it in my source.js to create the extension.I was told that I should send HTTP request to NodeJs to take this text and use, who knows how I can do?

NodeJS / index.js

const PORT=8888;
const axios=require("axios");
const cheerio=require("cheerio");
const express=require("express");
const {response}=require("express");

const app=express();
const url="https://randomtextgenerator.com/";

axios(url)
    .then(response=>{
        const html=response.data
        const $=cheerio.load(html);
        const articles=[];
        $("#randomtext_box", html).each(function () {
            const title=$(this).text()
            articles.push(
                title
            )
        })
        let articles1=articles.join();
        let y;
        for (let i=0; i < articles1.length; i++) {
            if (articles1[i] == ".") {
                if (articles1[i + 1] == " ") {
                    if (articles1[i+2] == "\n") {
                        y=i;
                        break;
                    }
                }
            }
        }

        let newArticles = articles1.substring(0,y+1);
        console.log(newArticles);
       
    }).catch(err=>console.log(err));

app.listen(PORT, ()=>console.log(`server runing on ${PORT}`));



Chrome Extension / source.js

function(newArticles){
    let text= `<div class="text1"></div>`
    document.body.appendChild(text);
    text.innerText=newArticles;
}

I tried it with module.exports, but the error "ERROR,document is not defined".

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!