Skip to content

Instantly share code, notes, and snippets.

@gargoyle
Last active August 29, 2015 14:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gargoyle/65c05eedf97de68da8cb to your computer and use it in GitHub Desktop.
Save gargoyle/65c05eedf97de68da8cb to your computer and use it in GitHub Desktop.
/Users/paul/Applications/Test.app/Contents/MacOS/My Chrome
#!/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