5 ms·
If you're on macOS, you can do a small piece of this natively with AppleScript (or anything that can send apple events) in Chrome or Safari -- namely, you can i
by phillco 4y ago
If you're on macOS, you can do a small piece of this natively with AppleScript (or anything that can send apple events) in Chrome or Safari -- namely, you can iterate through windows or tabs, view their source code, and execute arbitrary javascript you pass (there's a one time security option you have to accept). This can be handy for quick automations if you don't want to install anything.
(Background: I have RSI, so I've been developing some integrations between applications and Talon Voice (https://talonvoice.com/ https://talonvoice.com/). AppleScript ends up being surprisingly valuable/fast/reliable for applications that support it. I also built an integration with iTerm2's Python API before noticing that everything I was trying to do was already supported by its AppleScript dictionary, and was faster. In Google Chrome, the "iterate through tabs and execute javascript in them" is very useful for automating Google Meet muting/unmuting.)
Nothing against this excellent project though; I'm a big fan of Omar's Twitter! And I suspect most here will appreciate the easier scriptability of the filesystem approach than dealing with the atrocious syntax of AppleScript.
- _acnx 4y agoHave you got any suggestions for coping with RSI? I'm having significant issues.
- mokanfar 4y agoDevote a 4 digit budget for a new workspace that relieves RSI causing movements.
- jen729w 4y agoYou don't need to spend that much. I mean, go for it, it sounds fun, but just getting a desk the right height (i.e. probably lower than it is now) and a stable chair solved mine. See sibling comment here. https://news.ycombinator.com/item?id=34852007 https://news.ycombinator.com/item?id=34852007
- chaorace 4y agoIt's all about hardware. I've addressed it quite well with a three-pronged approach: 1. Motorized standing desk - typing from varying postures keeps strain spread out 2. Kensington trackball mouse - less hand sweeping / temptation to drags wrist on table 3. Ortholinear "Planck" keyboard - modifier keys accessible via thumb and programmable layers more generally can completely eliminate painful hand poses and keep fingers on the home-row
- ajolly 4y agoChange is good. I find using a variety of mice helps. Rollermouse, trackpads, rockmouse, carpal tunnel mouse(quadraclicks), mousetrapper. For the dragging wrist problem, I really like the reloot or other similar gliding palm rests. I find upgrading them with ceramic lights makes a big difference.
- smcleod 4y agoPersonally I find the Kensington trackball mouse made my carpel tunnel a LOT worse, they're not for everyone.
- ryukafalz 4y agoWith my particular RSI I also can't use a standard trackball, but I swear by my thumb trackballs. (But every body is different, every injury is different, etc.)
- Scaevolus 4y agoHave you tried a book on the mind body connection of pain? It helps some people with RSI: https://www.amazon.com/Healing-Back-Pain-Mind-Body-Connection-dp-153871261X/dp/153871261X https://www.amazon.com/Healing-Back-Pain-Mind-Body-Connectio...
- nier 4y agoThat’s also how I got rid of my RSI. Once I ended that one bad relationship in my life, my mind stopped messing up the most used part of my body to send me signals that I’m actually chewing on life’s gristle. My wrists have been pain free for 15 years. Without surgery. Without therapy. Without a change in work hours.
- replwoacause 4y agoThe Kinesis Advantage 2 keyboard fixed mine. I also use a Logitech trackball instead of a mouse.
- phillco 4y agoIf you're programming, definitely check out Cursorless: https://www.cursorless.org/ https://www.cursorless.org/. Talon itself provides noise and speech recognition, and provides the framework that allows you to build automations with any program; Cursorless really helps make programming by voice feel comparable to typing. For me, it's a combination of introducing alternate input methods (largely voice, but noises are also very additive -- they very well for fast/discreet actions, whereas voice is higher bandwidth but lower latency), as well as building higher-level and better integrations with applications. But I still have always to go personally. I've been meaning to write up a blog post with everything that I've learned, but you know how it is :)
- wahnfrieden 4y agoSplit vertical keyboards with very very light switches. I use Sofle Choc and have the sides at shoulders width apart I recommend breaks and rest over strengthening exercises when dealing with hand pain. Learn preventative measures
- pmoriarty 4y ago"If you're on macOS, you can do a small piece of this natively with AppleScript (or anything that can send apple events) in Chrome or Safari -- namely, you can iterate through windows or tabs, view their source code, and execute arbitrary javascript you pass (there's a one time security option you have to accept). This can be handy for quick automations if you don't want to install anything." Are there any good examples of doing this?
- phillco 4y agoI believe I modified a version of this - https://gist.github.com/lyallcooper/10f48ab050ac8594fe46335e49c99c46 https://gist.github.com/lyallcooper/10f48ab050ac8594fe46335e...
- cpleppert 4y agosure, for example this pauses every youtube video in every chrome tab: tell application "Google Chrome" repeat with theWindow in every window repeat with theTab in (every tab of theWindow) if (URL of theTab) contains "youtube.com" then execute theTab javascript "document.querySelectorAll('video, audio').forEach(e => e.pause())" end if end repeat end repeat end tell There are lots of examples just by googling. The script editor has a dictionary for every application you can natively script.
- deleted 4y ago[deleted]
- oefrha 4y agoYou don’t need to write AppleScript yourself, someone else has already done the hard work with Scripting Bridge and you can simply enjoy an easy-to-use CLI: https://github.com/prasmussen/chrome-cli https://github.com/prasmussen/chrome-cli Been using this for about a decade now.
- deleted 4y ago[deleted]
- SonicSoul 4y agointeresting, what are your use cases?
- aidos 4y agoI can’t answer that question exactly because that’s driving Chrome, but I wrote an AppleScript the other day to make zoom less dreadful. I annotate on screens all day and there are no useful shortcuts for moving between drawing and erasing. Also the drawing button requires 2 clicks. I’ve wired my wacom tablet so the two buttons fire off shortcuts, they run a service I’ve registered in the menus, they run the applescript, it fishes about for the right windows in zoom and clicks the buttons. It could not have worked but it just happens to because I can trigger a button and then focus moves to the next button (which I can’t otherwise target) and then I can push “space” to get the job done.
- aidos 4y agoHere’s one of the scripts if anyone wants to see how weird it all is. tell application "System Events" repeat with theProcess in processes if not background only of theProcess then tell theProcess set processName to name set theWindows to windows end tell set windowsCount to count of theWindows if processName is "zoom.us" then repeat with theWindow in theWindows tell theWindow set theSize to size set windowName to name end tell if windowName is "annotation panel" then if item 1 of theSize is 776 then tell theWindow to tell button 5 to click key code 49 else tell theWindow to tell button 4 to click key code 49 end if end if end repeat end if end if end repeat end tell
- nbar 4y agoLove to hear more about this. I also suffer from RSI and would love to know if it’s helped changing input to voice
- password4321 4y agoI used to scan all the tabs in open browser windows to list all URLs. See also https://chromedevtools.github.io/devtools-protocol/ https://chromedevtools.github.io/devtools-protocol/ with Playwright et al., even Excel VBA: https://github.com/PerditionC/VBAChromeDevProtocol https://github.com/PerditionC/VBAChromeDevProtocol Many sites fight against automation, see https://github.com/ultrafunkamsterdam/undetected-chromedriver https://github.com/ultrafunkamsterdam/undetected-chromedrive...
- tedmiston 4y agoShameless plug: I've made a set of AppleScripts I call "Tab Transporter" for moving groups of tabs between browsers. The code is painful to write when you're used to a normal programming language, so these examples could be useful for anyone else looking to interact with browser tabs via AppleScript. I've used them daily for 5+ years. https://github.com/tedmiston/tab-transporter https://github.com/tedmiston/tab-transporter
- ayewo 4y agoFunny, I do similar [1] though my solution is very basic compared to yours. The script allows me to quickly move the current tab from Firefox or Safari to Arc Browser [2] (which uses Chrome under the hood). I use the following key-bindings ⌥⌘F or ⌥⌘S in Raycast [3] to activate a tab move to Arc from Firefox or Safari, respectively. 1: https://github.com/ayewo/raycast-script-commands/tree/main/browsers https://github.com/ayewo/raycast-script-commands/tree/main/b... 2: https://arc.net https://arc.net 3: https://www.raycast.com/ https://www.raycast.com/
- phillco 4y agoNice, thank you!
- gymbeaux 4y agoIf I were you I would find out which “RSI” you have. Mine wasn’t from “overuse” per sé, just posture and needing to stretch/exercise. If your RSI is Carpal Tunnel or Cubital Tunnel Syndrome, a quick and easy surgery is the answer. If your RSI is tendinitis (unlikely, for all the times I see people self-diagnose with it) rest is your best bet. If your RSI is arthritis, there are medications and even surgeries out there to help with it, but that’s the easiest one to diagnose because it just requires looking at an x ray of your hand. You may have carpal tunnel syndrome-like symptoms, but that likely just means you have nerve impingement somewhere between your cervical (neck area) spine and your hand. I’m not a doctor, but through personal experience I can tell you, you probably have the power to get rid of your “RSI” without resorting to dictation software and so on.
- dceddia 4y agoRegarding stretching, I found the book Conquering Carpal Tunnel Syndrome to be a huge help. It has lots of suggestions for kinds of stretches to do based on the kind of work you do, but my big takeaway (and according to the author, the most important part) was how to do the stretches: only stretch until you barely feel a stretch, then hold there until you feel a sense of release. In my experience that was more effective than the “stretch until you feel a good strong stretch” strategy. https://www.amazon.com/Conquering-Carpal-Syndrome-Repetitive-Injuries/dp/1572240393 https://www.amazon.com/Conquering-Carpal-Syndrome-Repetitive...
- gymbeaux 4y agoMy personal trainer told me the same- you won't gain flexibility by "forcing" the stretch, only by stretching just beyond where the muscle wants to stop, holding it there for around 30 seconds (and you should feel a "release"), and repeating the next day.
- jen729w 4y agoI have a copy of this which I no longer need. If anyone in Australia wants it hit me up and I'll mail it to you. @johnnydecimal@hachyderm.io. FWIW -- I know this isn't an RSI thread -- mine was 100% fixed by changing my desk. It was too high, and my classic 5-wheeled office chair was unstable. I lowered the desk to about 68cm (I'm 172cm) and bought a chair with wooden legs (Ikea, ~$80), started doing light stretches in the morning, and that fixed it for me. I made the desk from Ikea cabinets and a $100 plain wooden door. So it's a) cheap, b) massive, and c) I can screw things in to the underside.
- scarface74 4y agoIf you had told me in 1992 when AppleScript was first introduced that it would be around for over 30 years across three processor transitions, I would not have believed you. Now they just need to bring back QuickDraw GX, OpenDoc and PowerTalk (please don’t for all that is holy)
- fiddlerwoaroof 4y agoInterestingly, all the AppleScript functionality is built on an objective-c api called ScriptingBridge and it’s relatively easy to use a real programming language for the same sorts of things. JavaScript is natively supported by Script Editor, but there’s bindings for Ruby and Python too. I’ve wrapped it up in Common Lisp for my own use: https://github.com/fiddlerwoaroof/objc-lisp-bridge/blob/master/scripting-bridge.lisp https://github.com/fiddlerwoaroof/objc-lisp-bridge/blob/mast...
- varenc 4y agoJust to show folks how simple this is, here's the JavaScript (JXA) version of the AppleScript code needed to run JS in the current active tab: /usr/bin/osascript -l JavaScript <<EndOfScript var current_tab = Application('Google Chrome').windows[0].activeTab(); current_tab.execute({ javascript: 'alert(1)' }) EndOfScript Once you figure it out it's not too tricky. For example, I have shell utils for converting all links on a page to "in current tab links" by removing the `target` attr on <a> tags: function chromeJS() { INPUT="$1"; INPUT=${INPUT//\"/\\\"} ## escape quotes INPUT=${INPUT//\'/\\\'} /usr/bin/osascript -l JavaScript <<EndOfScript var current_tab = Application('Google Chrome').windows[0].activeTab(); current_tab.execute({ javascript: '$INPUT' }) EndOfScript } ... $ chromeJS "document.querySelectorAll('a').forEach(a => a.removeAttribute('target')); alert('Made all links in-tab links!')"