Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

118
Visualizações
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 Respostas
Responde à pergunta

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 Relatório

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 Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda