Last active
August 29, 2015 14:04
-
-
Save aliou/e803aedfae6d0b75e59a to your computer and use it in GitHub Desktop.
List open tabs on iCloud devices
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"dependencies": { | |
"underscore": "^1.6.0", | |
"plist": "^1.0.1", | |
"optimist": "^0.6.1", | |
"async": "^0.9.0" | |
} | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
_ = require 'underscore' | |
argv = require('optimist').argv | |
async = require 'async' | |
exec = require('child_process').exec | |
fs = require 'fs' | |
plist = require 'plist' | |
file = process.env.HOME + '/Library/SyncedPreferences/com.apple.Safari.plist' | |
data = plist.parse(fs.readFileSync(file, 'utf8')) | |
commands = [] | |
devices = _.toArray(data.values) | |
devices.forEach (device) -> | |
if device.value.Tabs? | |
if argv.open | |
device.value.Tabs.forEach (tab) -> | |
command = 'open -a "Google Chrome" "' + tab.URL + '"' | |
commands.push async.apply(exec, command) | |
async.parallel commands | |
else | |
console.log device.value.DeviceName | |
device.value.Tabs.forEach (tab) -> | |
console.log " " + tab.Title | |
console.log " " + '↦ ' + tab.URL + "\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment