Click event not working for gmail pages on content script of a chrome extension that I am creating. Here is my manifest.json file:
{
"name": "Append Test Text",
"description": "Add test123 to body",
"version": "1.0",
"permissions": ["activeTab"],
"content_scripts": [
{
"matches": ["https://mail.google.com/*"],
"js": ["jquery-3.4.1.min.js", "content-script.js"],
"all_frames": true
}
],
"browser_action": {
"default_title": "Append Test Text"
},
"manifest_version": 2
}
content-script.js:
var composeBtn = true;
function loop() {
setTimeout(function() {
if ($(".T-I.J-J5-Ji.T-I-KE.L3").length && composeBtn) {
$(".T-I.J-J5-Ji.T-I-KE.L3").on("click", function() {
alert("hello");
});
composeBtn = false;
}
loop();
}, 5000);
}
loop();
$(".T-I.J-J5-Ji.T-I-KE.L3")
is the Compose button in gmail. Cicking on it should show an alert.