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

117
Views
Load a chrome extension and find current website javascript

I'm currently trying to make a chrome extension but I'm a bit lost -_-

I have two questions, my first one is how do I go about seeing if a user is on a certain website and execute the code ?

I have this so far:

if(href == "instagram") {
    console.warn("You are on instagram !!")
}

But it doesn't seem to be working.

my second question is how do I add a chrome extension, I followed a tutorial but I it does not match what i see on my screen

about 4 years ago · Juan Pablo Isaza
2 answers
Answer question

0

First question answer

As for your first question, "href == " doesn't work, you need window.location.href and match, like so:

if(window.location.href.match("www.instagram") {
    console.warn("You are on instagram !!")
}

If you're going to be using this a lot I recommend putting it into a variable like url = window.location.href, so then you can just use url.match

Second question answer

To add your chrome extension, go to chrome://extensions and click "developer mode" in the top right. Then you should see something called "load unpacked" - once you press this locate the folder for your chrome extension and add it.

about 4 years ago · Juan Pablo Isaza Report

0

At the moment, you are doing href == "instagram". What this does, is compare them directly. But the href is actually going to be something like instagram.com or https://instagram.com/something, so the statement won't work.

You probably want to do

if (window.location.href.includes('instagram') {
    console.log('You are on Instagram!');
}

For your second question, it's a longer answer than SO is really meant for. Try taking a look at this: https://webkul.com/blog/how-to-install-the-unpacked-extension-in-chrome/

about 4 years ago · Juan Pablo Isaza Report
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!