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);