I am making a Google Chrome extension and I am trying to use the .click()
function within one of my script. The click function should click a link which redirects me to another page. Once I have been redirected, I would like to send a chrome.runtime
message.
document.getElementsByClassName('example-link')[1].click(function() {
console.log("Hello World");
let data = {
type: "example"
}
chrome.runtime.sendMessage({...data});
});
So far the page redirects, but the console.log() doesn't show and the runtime message doesn't send. I am not sure whether I have misunderstood the purpose of the callback function or whether the scripts stops running because I am on a new page.
Any explanation / help would be appreciated.