3 ms·
Instead of doing work, I got stuck modding this to get better behavior for Mac. First I tried to figure out what the $restartNetworkingCommand mac equivalent wa
by keeganpoppen 15y ago
Instead of doing work, I got stuck modding this to get better behavior for Mac. First I tried to figure out what the $restartNetworkingCommand mac equivalent was (dscacheutil -flushcache for those who are curious). This works pretty well for non-Chrome browsers (i.e. browsers that don't have absurd caching behavior). Then, given that Chrome (which maintains its own DNS cache-- a decidedly not absurd caching behavior, I acknowledge) is my browser of choice, I also set out to fix it so I didn't need to restart Chrome. This endeavor I have accomplished using one of my favorite jank-tastic tactics: running applescript from the command line.
So here is my (Mac OS X 10.6+?) change:
$restartNetworkingCommand = 'dscacheutil -flushcache; osascript <<EOF
tell application "Google Chrome"
make new tab at end of tabs of window 1 with properties {URL:"chrome://net-internals/#dns"}
activate
delay .5
set URL of active tab of window 1 to "javascript:document.getElementById(\'clearHostResolverCache\').click()"
end tell
delay .5
tell application "System Events" to keystroke "w" using {command down}
EOF';
This, of course is made even more jank-tastic by manually sending command-w to close the window-- googling the proper command was more difficult than just doing it live :).
So yeah-- clearly I needed this script before reading this post, but if I had it probably would have done some terrible things to the space-time continuum... I guess I'll just amortize the one-time cost by actually using the script. Starting now.
- keeganpoppen 15y agoyikes-- that formatting got butchered... anyone know if there's a better way to put code in comments?