I have a Google Chrome extension that will parse parts of a Google Mail email for the sender's email address and validate it based on an email API. The extension is up and running however, the content.js script will only work when I refresh the page after opening an email. I have my manifest.json set to match on https://mail.google.com/* and I want it to run every time the subdirectory changes.
Basically, I want to be able to run the content script every time the URL changes from https://mail.google.com/mail/u/0/#inbox/FMfcgzGpFWLJXXbptnzzBMFCmMqFVTsz
to
https://mail.google.com/mail/u/0/#inbox/FMfcgzGmvpHMHxJwNhRgHdFNMHTDKnNq
How would I enable my content.js to detect whenever the URLs subdirectory is changed?
Also would it be better to change my manifest.json set to match https://mail.google.com/mail/u/0/#inbox/* instead of https://mail.google.com/*
content.js
window.addEventListener('load', function () {
/* Logic to parse email */
}
manifest.json
"content_scripts": [{
"matches": ["https://mail.google.com/*"],
"js": ["jQuery.js", "content.js"]
}],
"permissions": ["tabs", "https://*/"]