Last active
August 29, 2015 14:02
-
-
Save gargoyle/65c05eedf97de68da8cb to your computer and use it in GitHub Desktop.
/Users/paul/Applications/Test.app/Contents/MacOS/My Chrome
This file contains 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
#!/usr/bin/env php | |
<?php | |
// Read prefs file | |
$prefsRaw = file_get_contents('/Users/ ** USERNAME ** /Library/Application Support/Google/Chrome/Default/Preferences'); | |
$prefsJson = json_decode($prefsRaw); | |
// Rewrite (or create) "pinned_tabs" with fixed list of urls. | |
$myUrls = array( | |
'https://www.facebook.com/', | |
'https://www.twitter.com', | |
); | |
$objectUrls = array(); | |
foreach ($myUrls as $url) { | |
$object = new StdClass(); | |
$object->url = $url; | |
$objectUrls[] = $object; | |
} | |
// Save prefs | |
$prefsJson->pinned_tabs = $objectUrls; | |
$newPrefsRaw = json_encode($prefsJson, JSON_PRETTY_PRINT); | |
file_put_contents('/Users/ ** USERNAME ** /Library/Application Support/Google/Chrome/Default/Preferences', $newPrefsRaw); | |
// Launch Chrome | |
exec('/Applications/Google\ Chrome.app/Contents/MacOS/Google\ Chrome >/dev/null'); | |
exit; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment