The latest Chrome browser now shows a puzzle icon and doesn't automatically pin your Chrome Extension. Is there an API to detect if a Chrome Extension has been pinned? Can we detect from Javascript from a web page, or do we have to do the API through the extension itself? (I'm already assuming the extension itself.)
Here's some code you can use to check if your extension is pinned, and if not, send the user to a particular url.
You can put this in your Background.js and it works in Manifest V3.
async function checkIsPinned(){
let userSettings = await chrome.action.getUserSettings();
if(userSettings.isOnToolbar == false){
chrome.tabs.create({ url: 'https://example.com'});
}
}
//Check if extension is pinned
checkIsPinned();
This code is adapted from https://github.com/rustyzone/is-ext-pinned
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With