I'm currently working on a Chrome extension using Angular and Typescript, and I have encountered an issue with accessing the document element by its id from the active tab. While this works perfectly fine in JavaScript, I am facing difficulties in achieving the same functionality in TypeScript. It seems like "document.getelementbyId" does not work for HTML elements in TypeScript.
As a workaround, I have implemented the following code snippet:
chrome.tabs.onUpdated.addListener( function (tabId, changeInfo, tab) {
if (changeInfo.status == 'complete' && tab.active) {
if (tab.url == 'https://dashboard.stripe.com/login') {
// THIS IS THE METHOD FOR GETTING THE ELEMENT BY ID, BUT IT'S NOT WORKING
(<HTMLInputElement>document.getElementById('email')).value = "VALUE";
}
}
});
If anyone can assist me in resolving this issue, I would greatly appreciate it. Thank you.