Google Chrome Plugin development - Monitor network requests?

孤人 提交于 2020-01-04 07:52:35

问题


Is it possible to monitor network traffic with a google chrome plugin for the local page? For example, I want to monitor every time a web page requests a specific file (based on regex match), and if a user clicks the plugin, it opens a new tab to that file.


回答1:


The "proper" way would be to use webRequest API, but it is still experimental:

//background.html
chrome.experimental.webRequest.onCompleted.addListener(function(details) {
    console.log("resource", details.url);
});

Meanwhile you can catch resources that are loading with the following code:

document.addEventListener("beforeload", function(event) {
    console.log("resource", event.url);
}, true);

This needs to go into a content script that runs with "run_at": "document_start".



来源:https://stackoverflow.com/questions/6685503/google-chrome-plugin-development-monitor-network-requests

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!