Preloading the Chrome bookmarks bar with Office 365 links and favicons

There are two kinds of Chrome MDM settings: hard and soft ones. Or user-unmodifiable and user-modifiable, if you like. Hard settings can be set using a configuration profile, using the Chromium policy list as a reference. Soft settings are often set using a list of master preferences.

The latter isn’t very well documented, and if you look at some of the files Chrome writes to, you can find a whole bunch of undocumented settings, some of whom can be modified with noticeable results, and some that cannot. Have a look at the file ~/Library/Application Support/Google/Chrome/Default/Preferences in your favorite editor or run defaults read com.google.Chrome in Terminal.

The most common and obvious use for a master preference list, however, is preloading Chrome bookmarks. Let’s just cut to the chase. This script will preload bookmarks for the main Office 365 online apps on the bookmarks bar, with favicons, and disable a few potential annoyances. It should be run before the user’s first run of Chrome:

#!/bin/bash
# Output Chrome Bookmarks to /Library/Google/bookmarks.html
if [ ! -d "/Library/Google" ]
then
mkdir "/Library/Google"
fi
(
sudo cat <<'EOD'
<!DOCTYPE NETSCAPE-Bookmark-file-1>
<!-- This is an automatically generated file.
It will be read and overwritten.
DO NOT EDIT! -->
<META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=UTF-8">
<TITLE>Bookmarks</TITLE>
<H1>Bookmarks</H1>
<DL><p>
<DT><H3 ADD_DATE="1544871663" LAST_MODIFIED="1559916538" PERSONAL_TOOLBAR_FOLDER="true">Bookmarks Bar</H3>
<DL><p>
<DT><A HREF="https://www.office.com/launch/word&quot; ADD_DATE="1544871663" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABcUlEQVQ4jZ2Tuy+DURiHn/P5WpdFwiiKqATtl1QNTRdMwmigQSwS4pLwT9j8AZKGDgahgsUgYjQ1JneJWwexuMRtaeW8Bp8G/VTTJ+ck5wy/c5735D0Km3BvvPTV9dSsNa0i2hKtLQRLRFcgcLo+qXBA+ftj6yixELwiGkQQe36uNQgYpvk7m0LJnImix+nk3xytjP7Yp9+1OzA4P27kE3bCZRoA7iyvv/BFoo42BoBhKA6WhgE4XB6hM1RHY20lx6tjP0Jf8zsmgNYCQFmJC4CQv4pid1FeBpkSthPXtLVUs3dyS1NtJS9vKWYWdh1DWQYAp9cPdIXr2UkkGer20VBTwU7iMn+Ds+Q9U31BFjf3Ob95pCPoYXp2K3+D46u7T5PkPUcXd7S3eEi/638NlH8gJmCPHJ14sjaRdbsvEqXgRvqi4APs8lImwgYKC/DmCnx/A5sUSuYyXzTcGy99cj1bSktARAdEi4WIJaLLc33nD/9DsQsnDbsgAAAAAElFTkSuQmCC">Word</A>
<DT><A HREF="https://www.office.com/launch/powerpoint&quot; ADD_DATE="1544871663" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABrElEQVQ4jZ2Tv09TURTHP/e+h1LaWsKCIQQXAkh4TSOMEgwLAdJNJhyMm6saTUz8D4zGiZWVBePEr7AhIQwwtA3yiJSBmLiQQGlf09p7HGyfvvaFNH6Xm/s993zvOd97j6KO3YX+SOwyNgpmHDGOoBxEHIEeREhtf1eEwM7OjqyCcSgwKNqACIICCTveCpWdGxaEemJ9FZAmTlu6OddDyZLd3j3gbLiBvamUI7l08rkv2/v0BWNrx4ytuzgbLgNvP6Lsjr8JXgnjlTh99YTymYu+1QkQ0U2q/Pj0juuDHbofzdM9nfZj3xYnEVOjmNnn/P0bnw+0INUqF2sreHmX2IOH3O67FyjbisZbWmlxxk70kJiaA6CcP/b5WrFAZmaI7Ox9asVCeAVWNM7Iyh4A1wc7XH7d8mNKW6A1d5+9xIrGwwWMVyL/ehFTqeLl3fpb/sHol0OUtgLGtnpgangnuX/zfOTSycC+4cV//4MGfBN/Ln/g6PFEu3rIrypApe0KMjNDzVRFKZZsRH0G4wCDNwkkN09Cp9Endxf6I3euuhwjpBSSMkJjnBM3jfNvrDmsKUw7RnQAAAAASUVORK5CYII=">PowerPoint</A>
<DT><A HREF="https://www.office.com/launch/excel&quot; ADD_DATE="1544871663" ICON="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAABAAAAAQCAYAAAAf8/9hAAABqUlEQVQ4jY2TsUscQRSHv929PbVRkuAR5BRdDgmRiYJGEbRUsmclIoRUJqlMZwwXS/+BS8AEvMJGEAQLxebA07MwFlZaGAIicgaSiCRE1E69fRa6i+vtnf5gmDcD85tv3rynca3oyGBFmX781IFWR0RpIkocUQgPEeHnl1WNAGnWmD0vIgqRGALiCMjVuIoBETTTuH32DGEyBPQHOd9WLpnxrc/zF+HGRHxYv89hgIbRXm9uGO3FNEIAYc/gZbvN3LskphGi3Cwj83GK1NvxAoJcMuOj8Qx+HR3SVt+E/aybgec9WNW1fE5PFyVwFXKD9d1Nvv/e5VVnH48rH7G4lWXnIBdIcFO+HHzNztJhKWoeRJhYmimZgwICV3nHQdd0wobp27+TwNB1EvYb0ttrHJ7843186F4EnsFAaw9WdZRUdo7pb4u8UF001z0JJAj8hVikjvnNFX782WN2I83f0/986Ht9J4Fmjdki4pZv8VLen8j6nnSev6AxET8rSGIx3bz1Wl4vLAAKiJUy2P+0HNyNbhAdGawwzRNFXlpEaBHHUYgohKpS7XwJg0q9cUxsKk4AAAAASUVORK5CYII=">Excel</A>
</DL><p>
</DL><p>
EOD
) > "/Library/Google/bookmarks.html"
# Output Chrome Master Preferences to /Library/Google/Google Chrome Master Preferences
(
sudo cat <<'EOD'
{
"homepage": "https://www.google.com&quot;,
"homepage_is_newtabpage": true,
"browser": {
"show_home_button": false,
"check_default_browser": false,
"has_seen_welcome_page": true
},
"bookmark_bar": {
"show_apps_shortcut": false,
"show_on_all_tabs": true
},
"distribution": {
"import_bookmarks": false,
"import_bookmarks_from_file": "/Library/Google/bookmarks.html",
"suppress_first_run_bubble": true,
"show_welcome_page": false,
"skip_first_run_ui": true,
"import_history": false,
"import_home_page": false,
"import_search_engine": false,
"importautofillformdata": false,
"suppress_first_run_default_browser_prompt": true,
"require_eula": false
},
"sync_promo": {
"show_on_first_run_allowed": false,
"user_skipped": true
},
"first_run_tabs": [
"https://www.google.com/&quot;
]
}
EOD
) > "/Library/Google/Google Chrome Master Preferences"

To modify bookmarks, bookmark the pages you need in Chrome, open the Bookmark Manager and export them. Copy and paste as needed from the resulting html file. The base64 encoded strings are favicons. You can juggle them around, using a favicon not really being used on a particular bookmark for a different one. Chrome will replace the favicon with the one supplied by the page upon loading the page for the first time; use the favicon currently being used by the site in question if that isn’t what you want.

If the settings are not properly formatted, they won’t work. Use a service like jsonlint.com to clean up the part of the file containing settings if you make modifications and they aren’t working.

Check out my postinstall script for Firefox ESR, that does something similar. Since Firefox ESR 60.4, Firefox also supports macOS plists and configuration profiles. I recommend using ProfileCreator if you will be using a profile.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s