How to Extend Our Browser Filing Script
In another post, we showed you a new script for DEVONthink, that allows you to quickly save your open browser tabs as bookmarks into your database. Here we have a few extra tips on extending the functionality a bit. So for those so inclined to tinker, we hope you enjoy this.
You can download extended versions of the script here:
Unzip the file, then install it in the appropriate location:
- In the Finder, select File > New Finder Window, then hold the Option key (⌥) and choose Go > Library.
- Open Scripts > Applications then go into the folder of your browser, e.g., Safari.
- Drag and drop our script into the browser’s folder.
- Return to your browser and the script will be shown in the global Script menu.
Now, double-click to open it, e.g., in Script Editor.
Always capture all windows
You will notice a line: property allWindows: false
. Change it to true
, if you want to capture the tabs of all open browser windows, effectively saving the browser session. DEVONthink will file each window’s tabs in a separate group. This can also be done in the original version installed from the Support Assistant.
Dynamically capture all windows
If always clipping all tabs isn’t desirable, this version only captures the frontmost window unless the Command key (⌘) is held when you run it.
In this script, you may see it uses AppleScript Objective-C to detect what key is pressed and changes the behavior accordingly. This also detects if the CapsLock key (⇪) is on so the key is still reported.
You may also note a delay 1
. This gives you a second to press the Command key when you execute the script. This is handy if you are launching the script via a utility like Keyboard Maestro. And of course you can remove this or lengthen the time, as needed.
You can also use this delay to find out the codes for the modifier keys. Choose File > New from the menu in Script Editor and paste the following lines:
use framework "Appkit"
delay 1
set n to current application's NSEvent's modifierFlags()
Run this simple script in Script Editor and it will report the code for the keys you’re pressing. Now you can add some additional behaviors to your scripts using specific keys!