Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Two keyboard maestro macros to emulate continuous undo of closed tabs / windows in Safari (initial attempt)
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
<array>
<dict>
<key>Actions</key>
<array>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteJavaScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>window.location.href;</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>safari_tmp</string>
<key>WebBrowser</key>
<string>Safari</string>
</dict>
<dict>
<key>Conditions</key>
<dict>
<key>ConditionList</key>
<array>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>safari_tmp</string>
<key>VariableConditionType</key>
<string>IsNot</string>
<key>VariableValue</key>
<string>topsites://</string>
</dict>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>safari_tmp</string>
<key>VariableConditionType</key>
<string>IsNot</string>
<key>VariableValue</key>
<string>about:blank</string>
</dict>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>safari_tmp</string>
<key>VariableConditionType</key>
<string>DoesNotContain</string>
<key>VariableValue</key>
<string>file://</string>
</dict>
</array>
<key>ConditionListMatch</key>
<string>All</string>
</dict>
<key>ElseActions</key>
<array/>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>IfThenElse</string>
<key>ThenActions</key>
<array>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteJavaScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>var tmp = null;
if(document.kmvar.safari == "") {
tmp = window.location.href;
} else {
tmp = window.location.href + ";" + document.kmvar.safari;
}
console.log(tmp);
tmp;</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>safari</string>
<key>WebBrowser</key>
<string>Safari</string>
</dict>
</array>
<key>TimeOutAbortsMacro</key>
<true/>
</dict>
<dict>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>KeyCode</key>
<integer>13</integer>
<key>MacroActionType</key>
<string>SimulateKeystroke</string>
<key>Modifiers</key>
<integer>256</integer>
<key>ReleaseAll</key>
<false/>
</dict>
</array>
<key>IsActive</key>
<true/>
<key>ModificationDate</key>
<real>418676461.776815</real>
<key>Name</key>
<string>Record closing tab</string>
<key>Triggers</key>
<array>
<dict>
<key>FireType</key>
<string>Pressed</string>
<key>KeyCode</key>
<integer>13</integer>
<key>MacroTriggerType</key>
<string>HotKey</string>
<key>Modifiers</key>
<integer>256</integer>
</dict>
</array>
<key>UID</key>
<string>85E209FB-B5D6-476E-8CD2-BC8671820078</string>
</dict>
</array>
<key>Name</key>
<string>Safari Tabs Fix</string>
<key>Targeting</key>
<dict>
<key>Targeting</key>
<string>Included</string>
<key>TargetingApps</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.Safari</string>
<key>Name</key>
<string>Safari</string>
<key>NewFile</key>
<string>/Applications/Safari.app</string>
</dict>
</array>
</dict>
<key>UID</key>
<string>02BEBF32-B1D8-4E41-8086-D2EE7ACB9EC4</string>
</dict>
</array>
</plist>
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
<dict>
<key>Activate</key>
<string>Normal</string>
<key>IsActive</key>
<true/>
<key>Macros</key>
<array>
<dict>
<key>Actions</key>
<array>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteJavaScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>console.log(document.kmvar.safari);
var parts = document.kmvar.safari.split(";");
var result = null;
if(parts.lenght == 0) {
result = undefined;
} else {
result = parts.shift();
}
result;</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>safari_tmp</string>
<key>WebBrowser</key>
<string>Safari</string>
</dict>
<dict>
<key>Conditions</key>
<dict>
<key>ConditionList</key>
<array>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>safari_tmp</string>
<key>VariableConditionType</key>
<string>Is</string>
<key>VariableValue</key>
<string>undefined</string>
</dict>
<dict>
<key>ConditionType</key>
<string>Variable</string>
<key>Variable</key>
<string>safari_tmp</string>
<key>VariableConditionType</key>
<string>IsEmpty</string>
<key>VariableValue</key>
<string>value</string>
</dict>
</array>
<key>ConditionListMatch</key>
<string>None</string>
</dict>
<key>ElseActions</key>
<array/>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>IfThenElse</string>
<key>ThenActions</key>
<array>
<dict>
<key>Argument</key>
<string>%Variable%safari_tmp%</string>
<key>Command</key>
<string>NewTab</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>SafariControl</string>
<key>WebBrowser</key>
<string>Safari</string>
</dict>
</array>
<key>TimeOutAbortsMacro</key>
<true/>
</dict>
<dict>
<key>DisplayKind</key>
<string>Variable</string>
<key>IsActive</key>
<true/>
<key>IsDisclosed</key>
<true/>
<key>MacroActionType</key>
<string>ExecuteJavaScript</string>
<key>Path</key>
<string></string>
<key>Text</key>
<string>console.log(document.kmvar.safari);
var parts = document.kmvar.safari.split(";");
parts.shift();
var rest = parts.join(";");
rest;</string>
<key>TimeOutAbortsMacro</key>
<true/>
<key>TrimResults</key>
<true/>
<key>TrimResultsNew</key>
<true/>
<key>UseText</key>
<true/>
<key>Variable</key>
<string>safari</string>
<key>WebBrowser</key>
<string>Safari</string>
</dict>
</array>
<key>IsActive</key>
<true/>
<key>ModificationDate</key>
<real>418676104.31371999</real>
<key>Name</key>
<string>Restore Tab</string>
<key>Triggers</key>
<array>
<dict>
<key>FireType</key>
<string>Pressed</string>
<key>KeyCode</key>
<integer>17</integer>
<key>MacroTriggerType</key>
<string>HotKey</string>
<key>Modifiers</key>
<integer>768</integer>
</dict>
</array>
<key>UID</key>
<string>06EA07CA-0436-4E62-B003-A5E8A4B6960A</string>
</dict>
</array>
<key>Name</key>
<string>Safari Tabs Fix</string>
<key>Targeting</key>
<dict>
<key>Targeting</key>
<string>Included</string>
<key>TargetingApps</key>
<array>
<dict>
<key>BundleIdentifier</key>
<string>com.apple.Safari</string>
<key>Name</key>
<string>Safari</string>
<key>NewFile</key>
<string>/Applications/Safari.app</string>
</dict>
</array>
</dict>
<key>UID</key>
<string>02BEBF32-B1D8-4E41-8086-D2EE7ACB9EC4</string>
</dict>
</array>
</plist>
@wrtsprt

This comment has been minimized.

Copy link
Owner Author

commented Apr 9, 2014

  • closed tabs / windows are only registered if you're using the ⌘+W shortcut
  • history of close tabs is lost, url present at the time of closing will be restored
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.