use AppleScript version "2.4" -- Yosemite (10.10) or later use scripting additions on searchReplaceText(SearchText, replaceText, theText) set theText to theText as text set oldTID to AppleScript's text item delimiters repeat with i from 1 to count SearchText set AppleScript's text item delimiters to SearchText's item i set theText to theText's text items set AppleScript's text item delimiters to replaceText's item i set theText to theText as text end repeat set AppleScript's text item delimiters to oldTID return theText end searchReplaceText on idxOfWidgetInParentByName(parentobj, childclass, childname) tell application "System Events" set idx to 1 set children to UI elements of parentobj repeat count of children times set child to item idx of children set achildclass to class of child set achildname to name of child if achildclass is equal to childclass and achildname is equal to childname then return idx end if set idx to idx + 1 end repeat end tell return -1 end idxOfWidgetInParentByName on generateScript(websitedata) set website to item 1 of websitedata set websiteurl to item 2 of websitedata set browser to item 3 of websitedata set scriptText to "" if browser is equal to "safari" then set pathToScript to (path to home folder as string) & "code:applescripts:openwebsiteinsafari.txt.applescript" as alias set scriptText to read file pathToScript end if if browser is equal to "chrome" then set pathToScript to (path to home folder as string) & "code:applescripts:openwebsitechrome.txt.applescript" as alias set scriptText to load script file pathToScript end if set SearchText to {"__websitename__", "__websiteurl__"} set replaceText to {website, websiteurl} set changedScriptText to my searchReplaceText(SearchText, replaceText, scriptText) return changedScriptText end generateScript on saveScriptAsAppletScriptEditor(website, scriptText) tell application "Script Editor" activate set appletName to "switchto_" & website & ".app" set appletPath to (path to home folder as string) & "devtools:buttonpanelapps:" try if exists file appletPath then delete file appletPath end if end try set appletLocation to appletPath as alias make new document at front set text of document 1 to scriptText try compile document 1 save document 1 as "application" end try my guiSave(appletPath, appletName) end tell end saveScriptAsAppletScriptEditor on saveScriptAsAppletScriptDebugger(website, scriptText) tell application "Script Debugger" activate set appletName to "switchto_" & website & ".app" set appletPath to (path to home folder as string) & "devtools:buttonpanelapps:" try if exists file appletPath then delete file appletPath end if end try set appletLocation to appletPath as alias make new document at front set script of document 1 to scriptText try compile document 1 save document 1 in file (appletPath & appletName) as "script application" end try end tell end saveScriptAsAppletScriptDebugger on guiSave(appletPath, appletName) tell application "System Events" set asheet to last item of UI elements of window 1 of application process "Script Editor" set fileNameField to text field named "Save As:" of splitter group 1 of sheet 1 of window "Untitled" of application process "Script Editor" set value of fileNameField to appletName -- set pathField to pop up button named "Where:" of splitter group 1 of asheet -- set expandChooserIdx to my idxOfWidgetInParentByName(splitter group 1 of asheet, class of pathField, "Where:") -- set expandPathChooser to item (expandChooserIdx + 1) of UI elements of splitter group 1 of asheet -- click expandPathChooser keystroke "G" using {command down, shift down} tell application process "Script Editor" to activate set pathTextField to item 3 of UI elements of item 2 of UI elements of asheet set value of pathTextField to "/Users/dlsa/Documents" --set clickable to item 3 of UI elements of table 1 of item 4 of UI elements of item 2 of UI elements of asheet --click clickable set clickable to click item 3 of UI elements of item 2 of UI elements of asheet delay 1 keystroke " " set a to 1 -- close window 1 of application "Script Editor" end tell end guiSave set softwaredevwebsites to {} set socialwebsites to {} set pornwebsites to {} set end of softwaredevwebsites to {"aws", "https://eu-north-1.signin.aws.amazon.com", "safari"} set end of softwaredevwebsites to {"name.com", "https://name.com", "safari"} set end of softwaredevwebsites to {"github", "https://github.com", "safari"} set end of softwaredevwebsites to {"savannah", "https://savannah.gnu.org", "safari"} set end of softwaredevwebsites to {"limited devices", "http://fisga.tretanet.net:8080", "safari"} set end of softwaredevwebsites to {"shampoos", "https://fisga.tretanet.net/shampoos/", "safari"} set end of socialwebsites to {"facebook", "https://facebook.com", "safari"} set end of socialwebsites to {"fanvue", "https://fanvue.com", "safari"} set end of socialwebsites to {"instagram", "https://instagram.com", "safari"} set end of socialwebsites to {"linkme", "https://link.me/dlsa", "chrome"} set end of socialwebsites to {"onlyfans", "https://onlyfans.com", "safari"} set softwaredevwebsitesidx to {1} set socialwebsitesidx to {} set pornwebsitesidx to {} set websitegroups to {{softwaredevwebsites, softwaredevwebsitesidx}, {socialwebsites, socialwebsitesidx}, {pornwebsites, pornwebsitesidx}} repeat with awebsitelist in websitegroups set awebsiteidxlist to item 2 of awebsitelist repeat with aidx in awebsiteidxlist set awebsite to item aidx of item 1 of awebsitelist set ascript to my generateScript(awebsite) my saveScriptAsAppletScriptEditor(item 1 of awebsite, ascript) end repeat end repeat