OraMatt: YABAOracle

Yet Another Blog About Oracle

Disable Facebook access

There should be a warning on while you log onto to Facebook saying that the next 2 hours you will accomplish nothing…

Until they implement that feature I hacked this up in AppleScript




-- Don't do Facebook during the workday...
-- Yeah…it's gotten that bad...

tell application "System Events" to set fp to first process whose frontmost is true

try
	display dialog "Disable Facebook access?" buttons {"Yes", "No", "Cancel"} with icon caution default button 1
	
	
	set userChoice to button returned of result
	
	if userChoice = "Yes" then
		-- make a backup and map facebook to loopback
		do shell script "cp /etc/hosts /tmp/hosts_`date +%m%d%y%H%M`"
		do shell script "echo '127.0.0.1 	www.facebook.com	facebook.com' >>/etc/hosts"
		
	else if userChoice = "No" then
		-- make a backup and change the facebook entry to fakebook
		do shell script "cp /etc/hosts /tmp/hosts_`date +%m%d%y%H%M`"
		do shell script "cp /etc/hosts /tmp/hosts.facebook"
		do shell script "cat /tmp/hosts.facebook | sed 's/facebook/fakebook/g' > /etc/hosts"
		
	else if userChoice = "Cancel" then
		-- Exit1
	end if
	
end try

Leave a comment

Navigation

About

I’m Matt and I do Oracle things.