首页 > 解决方案 > OnHistoryStateUpdated 仅在访问 Facebook 时创建 chrome 扩展

问题描述

代码在多次使用on-updated事件后改成这个代码。OnHistoryStateUpdated究竟是什么条件?

背景.js

chrome.webNavigation.onHistoryStateUpdated.addListener(function (details) {
            var domain = details.url;
            var google = 'https://www.google.co.kr/';

                var xhr = new XMLHttpRequest();
                xhr.onload = function () {
                    if (xhr.status === 200 || xhr.status === 201) {
                        console.log(xhr.responseText);
                    } else {
                        console.error(xhr.responseText);
                    }
                };
                xhr.open('POST', 'http://soylatte.kr:3000/image/check');
                xhr.setRequestHeader('Content-Type', 'application/x-www-form-urlencoded');
                xhr.send('url=' + domain);


        })

标签: google-chromegoogle-chrome-extension

解决方案


推荐阅读