Here's another the way I do it stories, and, keep in mind I'm on Linux.

I have a Facebok account that is basically blank. In fact, when I look at my page my reaction is "what is all that stuff?" as it's nothing I put there. Every day I get multiple e-mail notifications that are filtered to trash. To prevent traffic to Facebook.com my /etc/hosts file contains:
0.0.0.0 facebook.com
0.0.0.0 www.facebook.com
0.0.0.0 m.facebook.com
They give me the desired "Unable to connect".

However, sometimes I go want to make the connection, so I have a script to toggle the lines commented or uncommented. The script is sudoed, since editing /etc/hosts is an admistrator task. I use a launcher in a self-created category on my applications menu. It could be done using a desktop, or, panel launcher. It could also be run by cron job (as the sudo user) for timed control. And, it wouldn't be hard to do other sites the same way.

Here's the script, .desktop file, and, sudo file. Names and locations are just the way I do it.

Script file name: /usr/local/bin/t-fb

#!/bin/bash
# http://stackoverflow.com/questions/229551/string-contains-in-bash

fb1=$(cat /etc/hosts | grep " facebook.com")
# fb2=$(cat /etc/hosts | grep www.facebook.com)

if [[ $fb1 == *"#"* ]] ;then
 sed -i -e 's/# 0.0.0.0 facebook/0.0.0.0 facebook/g' /etc/hosts
 sed -i -e 's/# 0.0.0.0 www.facebook/0.0.0.0 www.facebook/g' /etc/hosts
 sed -i -e 's/# 0.0.0.0 m.facebook/0.0.0.0 m.facebook/g' /etc/hosts  
 echo "facebook is uncommented"
else 
 sed -i -e 's/0.0.0.0 facebook/# 0.0.0.0 facebook/g' /etc/hosts
 sed -i -e 's/0.0.0.0 www.facebook/# 0.0.0.0 www.facebook/g' /etc/hosts
 sed -i -e 's/0.0.0.0 m.facebook/# 0.0.0.0 m.facebook/g' /etc/hosts
 echo "facebook is commented"
fi

Launcher file name: ~/.local/share/applications/t-fb.desktop

Desktop Entry]
Categories=T-scripts
Comment[en_US]=Toggle Facebook
Comment=Toggle Facebook
Encoding=UTF-8
Exec=xfce4-terminal -e "sudo /usr/local/bin/t-fb"
GenericName[en_US]=
GenericName=
Icon=/usr/share/icons/terminals_section.png
MimeType=
Name=Facebook Toggle
Path=
StartupNotify=true
Terminal=false
TerminalOptions=
Type=Application
X-DBUS-ServiceName=
X-DBUS-StartupType=
X-Desktop-File-Install-Version=0.11
X-KDE-SubstituteUID=false
X-KDE-Username=

Sudo file name: /etc/sudoers.d/fb

User_Alias FBERS=sparerep
Cmnd_Alias FB=/usr/local/bin/t-fb
FBERS ALL=NOPASSWD: FB

Here's a screenshot of my normal use.

Toggle Facebook