Get access to or acquire files on Network tab in developer console

北城余情 提交于 2020-03-03 07:28:29

问题


Is possible to access or acquire the files that are passed to the client from the server, the files displayed on the Network tab in the developer console?

I came across this question that suggests obtaining the logs may be possible with browser extension technology, but it is a really old question and answer. I am also interested in obtaining the files, not the logs.

Is it possible?


回答1:


Yes. you can do it by using Service Workers.

Service Worker is a script which runs on your browser separated from your website. It allows to run background javascript functions which is not need any user interaction (Logs / Analytics).

And

Service worker is a programmable network proxy, allowing you to control how network requests from your page are handled.

Learn More Features of Service Workers


Sample Service worker which will be activated for all /sw.js requests from developers.google.com


if ('serviceWorker' in navigator) {
  window.addEventListener('load', function() {
    navigator.serviceWorker.register('/sw.js').then(function(registration) {
      // Registration was successful
      console.log('ServiceWorker registration successful with scope: ', registration.scope);
    }, function(err) {
      // registration failed :(
      console.log('ServiceWorker registration failed: ', err);
    });
  });
}

NOTE : You cannot intercept other website's traffic using service workers. That is browser level control, For that you need to use browser level extensions or packet sniffers such as Wireshark or Brupsuite.



来源:https://stackoverflow.com/questions/59807327/get-access-to-or-acquire-files-on-network-tab-in-developer-console

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