text
stringlengths 0
15.7k
| source
stringlengths 6
112
|
---|---|
if theString contains "~" then set theString to my SearchandReplace(theString, "~", path to home folder as string)
|
Kevin's Library.applescript
|
if theString starts with "/Users" then set theString to "Macintosh HD" & theString
|
Kevin's Library.applescript
|
if theString contains "\\" then set theString to my SearchandReplace(theString, "\\", "")
|
Kevin's Library.applescript
|
if theString contains "\"" then set theString to my SearchandReplace(theString, "\"", "")
|
Kevin's Library.applescript
|
return my SearchandReplace(theString, "/", ":")
|
Kevin's Library.applescript
|
end encodePosixtoHFS
|
Kevin's Library.applescript
|
on encodeHFStoPosix(theString)
|
Kevin's Library.applescript
|
if theString contains "~/" then set theString to my SearchandReplace(theString, (path to home folder as string), "~/")
|
Kevin's Library.applescript
|
return my SearchandReplace(theString, ":", "/")
|
Kevin's Library.applescript
|
end encodeHFStoPosix
|
Kevin's Library.applescript
|
on escBshPth(theString)
|
Kevin's Library.applescript
|
set theString to SearchandReplace(theString, " ", "\\ ")
|
Kevin's Library.applescript
|
set theString to SearchandReplace(theString, ")", "\\) ")
|
Kevin's Library.applescript
|
set theString to SearchandReplace(theString, "(", "\\( ")
|
Kevin's Library.applescript
|
return theString
|
Kevin's Library.applescript
|
end escBshPth
|
Kevin's Library.applescript
|
on doJava:theAction onType:theType withIdentifier:theID withElementNum:num withSetValue:theValue inTab:thetab
|
Kevin's Library.applescript
|
if theType = "id" then
|
Kevin's Library.applescript
|
set getBy to "getElementById"
|
Kevin's Library.applescript
|
set theJavaEnd to ""
|
Kevin's Library.applescript
|
if theType = "class" then
|
Kevin's Library.applescript
|
set theType to "ClassName"
|
Kevin's Library.applescript
|
else if theType = "name" then
|
Kevin's Library.applescript
|
set theType to "Name"
|
Kevin's Library.applescript
|
else if theType = "tag" then
|
Kevin's Library.applescript
|
set theType to "TagName"
|
Kevin's Library.applescript
|
set getBy to "getElementsBy" & theType
|
Kevin's Library.applescript
|
set theJavaEnd to "[" & num & "]"
|
Kevin's Library.applescript
|
if theAction = "click" then
|
Kevin's Library.applescript
|
set theJavaEnd to theJavaEnd & ".click();"
|
Kevin's Library.applescript
|
else if theAction = "get" then
|
Kevin's Library.applescript
|
set theJavaEnd to theJavaEnd & ".innerHTML;"
|
Kevin's Library.applescript
|
else if theAction = "set" then
|
Kevin's Library.applescript
|
set theJavaEnd to theJavaEnd & ".value ='" & theValue & "';"
|
Kevin's Library.applescript
|
else if theAction = "submit" then
|
Kevin's Library.applescript
|
else if theAction = "force" then
|
Kevin's Library.applescript
|
set theJava to "document." & getBy & "('" & theID & "')" & theJavaEnd
|
Kevin's Library.applescript
|
if thetab is missing value then set thetab to front document
|
Kevin's Library.applescript
|
tell thetab
|
Kevin's Library.applescript
|
if theAction = "get" then
|
Kevin's Library.applescript
|
set input to do JavaScript theJava
|
Kevin's Library.applescript
|
return input
|
Kevin's Library.applescript
|
do JavaScript theJava
|
Kevin's Library.applescript
|
end doJava:onType:withIdentifier:withElementNum:withSetValue:inTab:
|
Kevin's Library.applescript
|
on waitForSafariToLoad(SearchText, thetab)
|
Kevin's Library.applescript
|
set tabText to ""
|
Kevin's Library.applescript
|
set failsafe to 0
|
Kevin's Library.applescript
|
tell front window
|
Kevin's Library.applescript
|
if thetab is missing value then set thetab to current tab
|
Kevin's Library.applescript
|
repeat until tabText contains SearchText
|
Kevin's Library.applescript
|
set tabText to text of thetab
|
Kevin's Library.applescript
|
set failsafe to failsafe + 1
|
Kevin's Library.applescript
|
if failsafe = 300 then
|
Kevin's Library.applescript
|
error "Script timed out, Safari didn't load" number -100
|
Kevin's Library.applescript
|
end waitForSafariToLoad
|
Kevin's Library.applescript
|
on checkForExistingTab(theURLs)
|
Kevin's Library.applescript
|
if class of theURLs is text then set theURLs to theURLs as list
|
Kevin's Library.applescript
|
set URLs to URL of every tab
|
Kevin's Library.applescript
|
set URLfound to false
|
Kevin's Library.applescript
|
repeat with q from 1 to count of theURLs
|
Kevin's Library.applescript
|
set theURL to item q of theURLs
|
Kevin's Library.applescript
|
if URLs contains theURL then
|
Kevin's Library.applescript
|
repeat with n from 1 to (count of URLs)
|
Kevin's Library.applescript
|
if item n of URLs is theURL then
|
Kevin's Library.applescript
|
set URLfound to true
|
Kevin's Library.applescript
|
set thetab to tab n
|
Kevin's Library.applescript
|
if URLfound then exit repeat
|
Kevin's Library.applescript
|
if URLfound is false then
|
Kevin's Library.applescript
|
set thetab to current tab
|
Kevin's Library.applescript
|
end checkForExistingTab
|
Kevin's Library.applescript
|
on list_position(this_item, this_list)
|
Kevin's Library.applescript
|
repeat with i from 1 to the count of this_list
|
Kevin's Library.applescript
|
if item i of this_list is this_item then return i
|
Kevin's Library.applescript
|
end list_position
|
Kevin's Library.applescript
|
on ls__countMatchesInList(this_list, this_item)
|
Kevin's Library.applescript
|
set the match_counter to 0
|
Kevin's Library.applescript
|
if item i of this_list contains this_item then ¬
|
Kevin's Library.applescript
|
set the match_counter to the match_counter + 1
|
Kevin's Library.applescript
|
return the match_counter
|
Kevin's Library.applescript
|
end ls__countMatchesInList
|
Kevin's Library.applescript
|
on ls__makeParasFromList(this_list)
|
Kevin's Library.applescript
|
set textList to ""
|
Kevin's Library.applescript
|
repeat with n from 1 to count of this_list
|
Kevin's Library.applescript
|
if textList = "" then
|
Kevin's Library.applescript
|
set textList to item n of this_list
|
Kevin's Library.applescript
|
set textList to textList & return & item n of this_list
|
Kevin's Library.applescript
|
return textList
|
Kevin's Library.applescript
|
end ls__makeParasFromList
|
Kevin's Library.applescript
|
on sortAList:theList
|
Kevin's Library.applescript
|
set theArray to current application's NSArray's arrayWithArray:theList
|
Kevin's Library.applescript
|
set theArray to theArray's sortedArrayUsingSelector:"localizedStandardCompare:"
|
Kevin's Library.applescript
|
return theArray as list
|
Kevin's Library.applescript
|
end sortAList:
|
Kevin's Library.applescript
|
on makeFileReference(theFile)
|
Kevin's Library.applescript
|
if class of theFile is string and character 1 of theFile is "/" then
|
Kevin's Library.applescript
|
set theFile to POSIX file theFile
|
Kevin's Library.applescript
|
else if class of theFile is string and character 1 of theFile is "~" then
|
Kevin's Library.applescript
|
set theFile to POSIX file ((POSIX path of (path to home folder)) & text 2 thru -1 of theFile)
|
Kevin's Library.applescript
|
else if class of theFile is string then
|
Kevin's Library.applescript
|
set theFile to alias theFile
|
Kevin's Library.applescript
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.