Google Docs introduced Document Tabs in a recent update. I'm having issues with the caret keeping its styling when tabs are switched for my Chrome Extension. I've tried multiple times to detect the URL changes and update but I wasn't able to get it to work.
...
// Check if user is in Google Docs
chrome.tabs.query({ active: true, currentWindow: true }, (tabs) => {
const currentUrl = tabs[0].url;
const isGoogleDocs = currentUrl.includes("
docs.google.com/document");
if (!isGoogleDocs) {
// Show message and button if not in Google Docs
infoMessage.innerHTML = `<p>${chrome.i18n.getMessage("notInDocsMessage")}</p>`;
redirectContainer.style.display = 'block';
optionsContainer.style.display = 'none';
saveButton.style.display = 'none';
upgradeButton.style.display = 'none';
// Event listener for "Open Google Docs" button
document.getElementById('redirectButton').addEventListener('click', () => {
window.open('
https://docs.google.com/document', '_blank');
});
} else {
// Hide redirect message if in Google Docs
redirectContainer.style.display = 'none';
}
});