TIL Firefox debugger can edit JavaScript files

I’ll spare you the long story of why I had to edit a JavaScript file, but today I learned that since Firefox 128 you can add a script override in the browser Debugger Panel. This downloads the JavaScript file in question, where you can edit it with your favourite editor.

  1. Open DevTools by hitting F12 and select the Debugger.
  2. Right-click on the JavaScript file in the source list and select “Add script override”.
  3. Save your file somewhere and edit.
  4. Reload the page to apply changes.
  5. Remove the override by right-clicking on the file again and selecting “Remove script override”.

The file I was editing was minified, so Firefox doesn’t save the nicely unminifed file you were looking at, but it’s not too hard to unminify it. It was a small change I was making, so it wasn’t too difficult to find the right place to edit.

The image shows a cat sitting comfortably on a black office chair. The cat has a tabby coat with a mix of brown, orange, and black markings, and it is looking directly at the camera with bright green eyes. The chair appears to be slightly worn, especially on the seat, which shows some signs of use. The background consists of a stone or brick wall, suggesting that the setting might be either outdoors or in an industrial or rustic indoor space. There is also a red and black striped fabric visible to the left side of the image. The overall scene gives off a cozy and relaxed vibe, with the cat being the focal point of attention.

Yes, yes, Chrome has been able to do this for a long time, apparently. Thanks for letting me know.

Howto disable syntax highlighting in Vimdiff

X > Y >> Z

Where X is the population of developers who read this blog, Y is those that use Vim and Z is those that use vimdiff regularly. I guess this post will only be useful to a tiny minority of my readers, but to them it might be the best thing they’ve read all year. (Well, it is 2016, right? It’s been a weird year.)

Vimdiff allows you to open two files in Vim and side by side compare them, pushing changes from one file to another. I’ve been using it as long as I’ve been working on b2/WordPress and even before then too. It’s supremely useful.

Vimdiff

Over the years I’ve used many different terminals, with various settings and colour configurations. My vim settings change over time too as I move from one machine to another. Sometimes the colours look ok in Vimdiff, sometimes they don’t. Sometimes the colours are ok for one file type while conflicting in others.
The problem is that Vimdiff has it’s own colours it uses to show what parts of the files are different or missing. Those colours can sometimes hide actual text in the files. I find myself highlighting those lines with SHIFT-V to see the text.

I could pick a different colour scheme but then there’s no guarantee that a different part of text will be hidden by Vimdiff’s colour scheme. The easiest way to fix this is by disabling syntax highlighting completely when in Vimdiff and you do it like this. Open up your ~/.vimrc and add these lines:

if &diff
syntax off
endif

With that in there Vimdiff goes from looking like this to the simplified appearance below.

Vimdiff

Vimdiff

Ironically, the theme I’m currently using in Vim in the screenshots above isn’t that problematic, but here are two screenshots that show the problem from another machine. In the second screenshot I have highlighted (with SHIFT-V) the line with the function name in the left side. As you can see, the text “function” is still invisible in the right side of the screenshot.

Vimdiff Vimdiff

If you don’t want to edit your .vimrc for whatever reason you can also manually do :set syntax=off from within the editor but you’ll have to do that for each of your files.

All the code above is GPLed WordPress code. Thanks to user hildred on Stackexchange for that one. Hopefully someone else will find this useful.

PHP – oo stuff

BDKR has a rant here about OO in PHP. I agree with some of what he says. There’s lots of bad code and design out there (I can’t promise to be perfect either!) but that permeates functional and procedural programming too.
I happen to like working with objects and structuring code in that way. It was a hell of a thing to get used to in college though, Before that I had done a lot of work coding in ASM on the C64. Actually having structures to work with was a real boon!
On a related topic, John mentioned a ObjectView, a PDF magazine about OO for developers. May take a look at it later.