Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Chrome DevTools: local overrides for JS files from Webpack Source Map

I am not totally happy with the usability of video player on coursera.org (not my own website) and want to change something using the local overrides for my own convenience.

I successfully located the JS file to be changed and enabled local overrides. But after I saved my changes the website still uses the file fetched from the server instead of the local copy containing my changes.

What is the problem and how to resolve this?

like image 952
Gang Fang Avatar asked Jun 17 '20 00:06

Gang Fang


People also ask

How do I use DevTools overrides?

To use Overrides, open the Devtools either from the settings or using the keyboard shortcut CTRL+SHIFT+I . Then, Click on the Sources tab. You'll see at the top of the left menu 3 tabs: Page, Filesystem, and Overrides. Click on Overrides.

How do I change my DevTools location?

Change where DevTools is docked by using the Command Menu Or, press Shift + Ctrl + P on Windows/Linux or Command + Shift + P on macOS. Type dock, and then select a dock command: Dock to bottom. Dock to left.


1 Answers

I realized this might be a bug of the local overrides feature: I could see the local change made to the global JS file but not for files restored by Webpack source maps (files under webpack://).

Here is a workaround:

  1. first locate the file to be changed (using event listener breakpoints);
  2. add a breakpoint to where you want to change. I added a breakpoint to line 24 but more breakpoints are created, which is a bug in DevTools I think. Then check the checkboxes in the right panel and you should see the original webpack-generated file (with the red cross in the tab); enter image description here
  3. right click the tab, select "Reveal in Network panel"; enter image description here
  4. Right click the network call and select "Save for overrides"; enter image description here
  5. Finally, open the saved file and make your changes. Refresh the page and you should see the overridden changes.

Hope this is helpful if you're in a similar situation!

like image 186
Gang Fang Avatar answered Sep 22 '22 03:09

Gang Fang