Not sure whether you trying to do this in background.js or content.js, but if it is the former, you can do so using webNavigation events:
You need to set permissions for webNavigation
in manifest.json:
"permissions": [
"webNavigation"
],
Then in background.js:
chrome.webNavigation.onHistoryStateUpdated.addListener(function(details) {
console.log('Page uses History API and we heard a pushSate/replaceState.');
// do your thing
});
Source: Chrome Extension docs for webNavigation
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…