I have developed extension that generates confirm window on a current open tab after a certain interval of time. Its working fine but I want to change the text "XYZ website says" to my extension name. How can I do this? Is it possible?
Here is my background code:
var notifyTimer = setInterval(func, 5 * 1000);
console.log('setinterval ran');
function func() {
let ActiveTab = getCurrentTab();
console.log(ActiveTab)
}
const confirmWindow = () => {
let result = confirm("You've been working for too long on Chrome. Would you like to take a break?");
return result;
}
async function getCurrentTab() {
let queryOptions = { active: true, lastFocusedWindow: true };
let [tab] = await chrome.tabs.query(queryOptions);
console.log(tab.url)
//alert(" Hello!")
// SOME CODE TO GENERATE CONFIRM WINDOW or ALERT
chrome.scripting.executeScript({
target: { tabId: tab.id },
func: confirmWindow
});
return tab;
}
It's not possible to fully customise this text - since the UI is controlled by the browser it's important that it's correctly attributed, and as a result the browser is responsible for choosing this string. However, you can have your extension name appear here:
alert
from the background page rather than a content script.alert
from an offscreen document. One caveat here is that offscreen documents must be created with a reason and I don't think any of the currently supported reasons are appropriate for alerts. If your alert is part of a larger operation, this could work, but otherwise this approach may not be suitable.