A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

Showing posts with label chrome. Show all posts
Showing posts with label chrome. Show all posts

How to automate chrome with playwright

First open Chrome like this:

C:\Program Files\Google\Chrome\Application\chrome.exe 

--remote-debugging-port=9222

--user-data-dir="C:\Users\User\AppData\Local\Google\Chrome\User Data\Profile 2"

--save-storage


Find the profile dir with  chrome://version/

Then manually log in to the website you want to automate.

Now run:  npx playwright codegen --target=javascript -o script.js https://example.com

...and it will record your actions.


After that, Playwright can connect to chrome and repeat the actions.


More notes

  • If you need exact mouse trajectories or raw timestamps: Use rrweb to record events in-page and replay to produce precise input traces. Or capture DevTools Protocol Input events (use a small recorder that listens to Input.dispatchMouseEvent and Input.dispatchKeyEvent) and convert to Playwright calls (page.mouse.move + page.mouse.down/up + page.keyboard.type).

Chrome extensions: Download manager reviews


  • DownThemAll: Queues, but doesn't intercept
  • Thunder Download Manager: Intercepts, but doesn't queue
  • Free Download Manager: Just says "Loading..." (on Ubuntu)
  • Chrono Download Manager: Intercepts and queues! And resumes. Perfect!

How to copy off images from Chrome's cache (on Mac)

How to find Chrome cache on Mac

export YOU=your_username
export PROFILE=Default

mkdir ~/chrome_images
cp /Users/$YOU/Library/Caches/Google/Chrome/$PROFILE/Cache/* ~/chrome_images/
for k in `/bin/ls`; do mv $k $k.jpg; done # rename all files to jpg

open ~/chrome_images

# Now browse the image folder and find the images you want

# More sophisticated renaming example:

if [[ `file $filename | grep JPEG` ]]; then mv $filename{,.jpg} ; fi

URLs open in Safari instead of Chrome from Mac OSX Terminal

To set the correct default browser on OSX, go to System preferences | General | Default web browser.

If the default browser is correct but Terminal is still not behaving correctly, then change the default browser, and change it back again.

TIOA-TIOA FTW

(source)

Android: Don't refresh page when no signal

chrome://flags/#enable-offline-mode

and

chrome://flags/#enable-offline-load-stale-cache

Unfortunately this doesn't work anymore - those flags were experimental.
In fact I've switched to Firefox (which is also much faster on Android) because Chrome tabs kept annoyingly reloading when the phone had no signal.

Redirects behave weirdly in Chrome

Chrome (un)helpfully caches redirects sometimes.
Try using an incognito window and the behaviour should make more sense.