Checking Preferences

How to check multiple prefs arent changed, every x minutes or daily?

Accept cookies=always
Default Web Browser=Safari

Hi cirno,

this script reads the preferences you described
and writes the result into a file “Browser.log” in the temporary items folder of current user.
Save the script as stay open application.
Change “days” in the line “return days” to the value you want when the script should rerun


on idle
	set temp to ((path to temporary items) as string) & "Browser.log"
	set cookie to do shell script "defaults read com.apple.WebFoundation NSHTTPAcceptCookies"
	
	set pFile to ((path to preferences folder) as string) & "com.apple.LaunchServices.plist"
	tell application "System Events"
		set v to value of property list items of property list item "LSHandlers" of property list file pFile
	end tell
	set flag to false
	repeat with i in v
		try
			if |LSHandlerURLScheme| of i is "http" then
				set StandardBrowser to |LSHandlerRoleAll| of i
				set flag to true
				exit repeat
			end if
		end try
	end repeat
	if flag is false then set StandardBrowser to "missing value"
	
	set currdate to short date string of (current date) & " " & time string of (current date)
	set logdata to currdate & tab & "cookie: " & cookie & tab & "Browser: " & StandardBrowser & return
	write_to_file(logdata, temp, true)
	return days -- daily or e.g. return 10 * minutes for every ten minutes
end idle

on write_to_file(|data|, target, append)
	try
		set open_target_file to ¬
			open for access file target with write permission
		if append is false then ¬
			set eof of open_target_file to 0
		write |data| to open_target_file starting at eof
		close access open_target_file
		return true
	on error
		try
			close access file target
		end try
		return false
	end try
end write_to_file

Neat, Stefan - very neat. :wink: