Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

162
Vistas
chrome extension works on refresh/on land but not on 'internal navigation'

So simply when I land a page on youtube which starts with w* (meaning that a specific video with its ID) I'm firing alert(url) and it works however it only works when I land that page from the URL and/or on refresh. What I'm trying to achieve is to fire that alert when navigating to that page (watch?=...) FROM another youtube page meaning that I'm navigating internally.

as an example: www.youtube.com -> this is the landing page of youtube I click on a video and I navigate to: www.youtube.com/watch?=aiFUQ9981Qk

this DOES NOT trigger my alert HOWEVER when I refresh, it does trigger. how do i trigger even when i navigate 'FROM' 'WITHIN' youtube ? Any input would be appreciated. manifest and Content.js attached below...

manifest.json

{
    "manifest_version": 2,
    "name": "youtest",
    "version": "1.0.0",
    "content_scripts": [
        {
            "matches": ["https://*.youtube.com/watch?*"],
            "js": ["Content.js"]
        }
    ]
}

Content.js

console.log(window.location.href);
alert(window.location.href);
about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

function runScript() {
    if (window.location.href.indexOf('watch?') > -1) {
        alert('this is a video');
        let videoID = window.location.href.slice(
            window.location.href.lastIndexOf('/')
        );
        alert(videoID);
    } else {
        alert('not a video');
    }
}

document.addEventListener('yt-navigate-start', runScript);
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda