I'm going through the Google Chrome Extensions "Getting Started" tutorial, and I came across this code:
chrome.declarativeContent.onPageChanged.removeRules(undefined, function() {
chrome.declarativeContent.onPageChanged.addRules([{
conditions: [new chrome.declarativeContent.PageStateMatcher({
pageUrl: {hostEquals: 'developer.chrome.com'},
})
],
actions: [new chrome.declarativeContent.ShowPageAction()]
}]);
});
I looked at the "declarativeContent" API and this source: https://developer.chrome.com/extensions/declarativeContent#event-onPageChanged
However, I don't understand what action the "onPageChanged" represents. What "rules" are we modifying in this code? I understand this action only occurs when the host equals 'developer.chrome.com', but I can't figure out why we need the ".removeRules" portion.