Code Exchange Complete List Generator

This little (well maybe not little) script uses your Safari browser to get a list of every script written so and puts it in a TextEdit window for easy browsing and yes I tried doing it using the curl shell command, but it didn’t work. Let me warn you though. Once in a great while it has Safari open pages that don’t exist. If it does that then just press the stop button in the Script Editor window and start over again.

global TIDs
global the_doc
set TIDs to AppleScript's text item delimiters
set the_end to false
set program_list to {}
my safariOpen()
tell application "Safari"
	set n to 1
	repeat
		set program_list to program_list & ("Page " & n)
		set the_URL to "http://bbs.applescript.net/viewforum.php?id=11&p=" & n
		set URL of the_doc to the_URL
		my isDifferent()
		set i to 1
		try
			set the_text to text of the_doc
			set the_text to paragraphs of the_text
		on error
			set the_doc to document 1 of window 1
			delay 1
			set the_text to text of the_doc
			set the_text to paragraphs of the_text
		end try
		set t to 1
		set p to 1
		set z to 1
		if n = 1 then
			repeat 2 times
				set first_item to item 46 of the_text
			end repeat
		end if
		repeat
			if item t of the_text does not contain "by" then
				set t to t + 1
			else
				exit repeat
			end if
		end repeat
		repeat count of the_text times
			if p = t then
				if item p of the_text contains "by" then
					if first_item is not (item 46 of the_text) or (n is 1) then
						set program_list to program_list & item p of the_text
					else if (n is not 1) then
						set the_end to true
						exit repeat
					end if
				end if
				set t to t + 5
			end if
			set p to p + 1
		end repeat
		set n to n + 1
		if the_end is true then exit repeat
		set program_list to program_list & return
	end repeat
	set AppleScript's text item delimiters to return
	set program_list to program_list as string
	set AppleScript's text item delimiters to " "
	set program_list to text items 1 through -1 of program_list
	set AppleScript's text item delimiters to " "
	set program_list to program_list as string
	tell application "TextEdit" to activate
	tell application "System Events" to keystroke program_list
	set AppleScript's text item delimiters to TIDs
	return program_list
end tell

on safariOpen()
	tell application "System Events"
		if name of every process contains "Safari" then
			tell application "Safari"
				open location "http://bbs.applescript.net/"
				delay 0.5
				set the_doc to document 1 of window 1
			end tell
		else
			tell application "Safari"
				activate
				set URL of document 1 of window 1 to "http://bbs.applescript.net/"
				set the_doc to document 1 of window 1
			end tell
		end if
	end tell
	delay 1
	my isDifferent()
end safariOpen

on isDifferent()
	set first_text to "Wrong text"
	set first_source to "Wrong source"
	tell application "Safari"
		delay 1
		repeat until name of window 1 does not contain "Loading \""
		end repeat
		set the_doc to document 1 of window 1
		delay 1
	end tell
end isDifferent