Javascript History.js不';无法在内容脚本中工作

Javascript History.js不';无法在内容脚本中工作,javascript,history.js,Javascript,History.js,我尝试在google play store的内容脚本中使用history.js,但当状态发生变化时,该函数不会执行 我尝试了适配器绑定方法 在舱单中: "js": [ "js/jquery/jquery.js", "js/jquery.knob.js", "js/jquery.history.js", "src/inject/inject.js" ] 然后在内容脚本中 History.Adapter.bind(win

我尝试在google play store的内容脚本中使用history.js,但当状态发生变化时,该函数不会执行 我尝试了适配器绑定方法 在舱单中:

"js": [
        "js/jquery/jquery.js",
        "js/jquery.knob.js",
        "js/jquery.history.js", 
        "src/inject/inject.js"
      ]
然后在内容脚本中

History.Adapter.bind(window,'statechange',function(){ // Note: We are using statechange instead of popstate
    var State = History.getState(); // Note: We are using History.getState() instead of event.state
    alert();
});
什么都没发生

而且这个解决方案也不起作用

 (function(history){
    var pushState = history.pushState;
    history.pushState = function(state) {
        if (typeof history.onpushstate == "function") {
            history.onpushstate({state: state});
        }
        // ... whatever else you want to do
        // maybe call onhashchange e.handler
        return pushState.apply(history, arguments);
    }
})(window.history);


history.onpushstate=function(){alert()}

我认为这可能与内容脚本运行的范围有关。问题是内容脚本和页面的窗口对象不同,因此这会导致问题。到目前为止,我还没有找到在chrome的内容脚本中使用history.js的方法。 我使用了变异观察者,即检查DOM子树的变化来解决这个问题