I am developing a small Chrome extension in which i am not able to get the current URL of tab.
Below is the JS code this if(tab_id.includes("facebook"))
not working:
var tab_id = null;
function click(e) {
chrome.tabs.getCurrent(function (tab) {
tab_id = tab.url;
window.alert(tab_id);
});
if (tab_id.includes("facebook")) {
chrome.tabs.executeScript(null,
{
code: "try {document.querySelector('[type=password]').value ='10p14ej0016_';" +
"document.querySelector('[type=email]').value = '97sujeetkumar@gmail.com';" +
"}catch(e){}"
});
window.close();
}
}
document.addEventListener('DOMContentLoaded', function () {
var divs = document.querySelectorAll('Button');
for (var i = 0; i < divs.length; i++) {
divs[i].addEventListener('click', click);
}
});