Chrome://inspect without internet connection

折月煮酒 提交于 2021-02-07 09:58:44

问题


I have been developing a website for a project targeting mobile phones and tablets, currently focusing on using the chrome browser. Much of this development has been done on one phone using a laptop. I had been using the "chrome://inspect/#devices" quite painlessly until I came to test on a different phone, when clicking "inspect" resulted in a white page. The problem seemed to be that as I happened to have no network connection at the time, chrome couldn't access some repository and so didnt load the page. After chrome visited this page, I no longer needed an internet connection to inspect my phone.

My problem is that now I have to migrate my project onto a computer which sits behind a firewall (which I have no access to) which is stopping navigation to the "chrome-devtools-appspot" link to pull whatever it needs to generate the page when I click on "inspect".

Is there a way to somehow download this repository and make it available locally on the machine so that regardless of what phone / browser version I use, the inspect page does not depend on an internet connection?


回答1:


Its all about the Cache. When you chrome://inspect and click on "Inspect" the window requests the inspector tools from some google URL (looks something like this: chrome-devtools://devtools/bundled/inspector.html?isSharedWorker=true&remoteBase=https://chrome-devtools-frontend.appspot.com/serve_file/@f87f641eOabefed98578934of1d5ca79651bf82/&dockSide=undocked).

The solution is to do that first fetch on environment with internet connection, then copy the cache files of google chrome and paste them on the standalone environment.

These cache file are located on AppData/Local/Google/Chrome/User Data/Default/Cache.

I did the following and it worked: On the machine with the internet connection:

  1. Clean Chrome Cache (with 3rd app like CCleaner or just manually delete all files on Cache folder)
  2. Open Emulator and open dummy app or chrome tab
  3. Open Chrome then redirect to chrome://inspect then inspect the device.
  4. Wait for it to load (to downalod the needed files) see new files on Cache folder.
  5. Close Chrome.

At that point you can ZIP the Cache folder. On the not- connected machine go to the Chrome Cache folder (listed above for windows users) & extract the Zip file there.

That's it you can now use the inspect without it fetching the files. Again it did work for me, I am not sure if it has anythign to do with the SDK running on the emulator (IE Android 6/7 etc, maybe you need diffrent cache for each).

Hope it helps.

EDIT: It does have to do with Chrome, for each version of the browser the cache files needed are different. After some research the numbers after the @ tag is just a commit number from google-chrome-repository. So, to clarify, The chrome tab you open on the device (mentioned above) must be same as the target you are trying to imitate. Meaning that is doesn't meter which android version you are using but which chrome APK you are using. You can just download Chrome APK to the version you need. The version you need is what is written on chrome://inspet.



来源:https://stackoverflow.com/questions/33632793/chrome-inspect-without-internet-connection

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