31 lines
No EOL
890 B
JavaScript
31 lines
No EOL
890 B
JavaScript
chrome.tabs.onActivated.addListener((activeInfo) => {
|
|
chrome.tabs.query({
|
|
active: true,
|
|
currentWindow: true
|
|
}, tabs => {
|
|
const supportedUrls = [
|
|
'medium.com',
|
|
'youtube.com',
|
|
'github.com'
|
|
];
|
|
|
|
let supportedSite = false;
|
|
|
|
for (const i in supportedUrls) {
|
|
//console.log(supportedUrls[i]);
|
|
const pattern = new URLPattern({ hostname: `{*.}?${supportedUrls[i]}` });
|
|
console.log(tabs[0].url);
|
|
supportedSite = pattern.test(tabs[0].url);
|
|
if (supportedSite) {
|
|
break;
|
|
}
|
|
}
|
|
|
|
if (supportedSite) {
|
|
chrome.action.setBadgeText({text: ':o'});
|
|
chrome.action.setBadgeBackgroundColor({color: "#8F8"});
|
|
} else {
|
|
chrome.action.setBadgeText({});
|
|
}
|
|
});
|
|
}); |