I want to enable the extension icon under certain conditions using declarativeContent. The manifest is V3.
rule1 is applied when host is nory-soft.web.app and password is entered.
rule2 applies if host ends in .wikipedia.org.
const rule1 = {
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostEquals: "nory-soft.web.app", schemes: ["https"] },
css: ["input[type='password']"]
})
],
actions: [new chrome.declarativeContent.ShowAction()]
};
const rule2 = {
conditions: [
new chrome.declarativeContent.PageStateMatcher({
pageUrl: { hostSuffix: ".wikipedia.org", schemes: ["https"] }
})
],
actions: [new chrome.declarativeContent.ShowAction()]
};
chrome.runtime.onInstalled.addListener(() => {
console.log("onInstalled");
chrome.action.disable();
chrome.declarativeContent.onPageChanged.removeRules(undefined, () => {
chrome.declarativeContent.onPageChanged.addRules([rule1, rule2]);
});
});
chrome.runtime.onStartup.addListener(() => {
console.log("onStartup");
chrome.action.disable();
});
Below is the Test URL for rule1.
https://nory-soft.web.app/password.html
rule2 worked as expected.
When I installed the extension with Test URL open, rule1 was enabled.
After installing the extension without Test URL open, rule1 will not be enabled even if Test URL is opened.
Could this be a Chrome bug?