text
stringlengths
0
15.7k
source
stringlengths
6
112
on waitToBeVisible(selectors)
safari-javascript.applescript
script VisibilityWaiter
safari-javascript.applescript
.offsetParent !== null", {nextSelector, nextSelector}}
safari-javascript.applescript
exec of retry on VisibilityWaiter for findRunMax by findRetrySleep
safari-javascript.applescript
end waitToBeVisible
safari-javascript.applescript
on waitToBeInvisible(selector as text)
safari-javascript.applescript
set scriptText to format {"document.querySelector('{}') == null ||
safari-javascript.applescript
.offsetParent == null", {selector, selector}}
safari-javascript.applescript
if _runScript(scriptText) is true then return true
safari-javascript.applescript
(exec of retry on VisibilityWaiter for findRunMax by findRetrySleep) is equal to true
safari-javascript.applescript
end waitToBeInvisible
safari-javascript.applescript
on _runScript(scriptText)
safari-javascript.applescript
set montereyFix to "var jsresult = (" & scriptText & ");if (typeof(jsresult) === 'boolean') { jsresult ? 'true' : 'false'} else jsresult;"
safari-javascript.applescript
set runScriptResult to runScriptPlain(montereyFix)
safari-javascript.applescript
runScriptResult
safari-javascript.applescript
end _runScript
safari-javascript.applescript
on runScriptPlain(scriptText)
safari-javascript.applescript
tell application "Safari" to do JavaScript scriptText in _tab of safariTab
safari-javascript.applescript
end runScriptPlain
safari-javascript.applescript
set findRunMax of SafariJavaScriptInstance to configSystem's getValue("FIND_RETRY_MAX")
safari-javascript.applescript
set findRetrySleep of SafariJavaScriptInstance to configSystem's getValue("FIND_RETRY_SLEEP")
safari-javascript.applescript
SafariJavaScriptInstance
safari-javascript.applescript
set logger to std's import("logger")'s new("safari-javascript")
safari-javascript.applescript
set p to "/path/to/file.txt"
gistfile1-2 copy 2.applescript
open file (POSIX file p)
gistfile1-2 copy 2.applescript
open file (POSIX file "/path/to/file.txt")
gistfile1-2 copy 2.applescript
open file (p as POSIX file)
gistfile1-2 copy 2.applescript
set q to POSIX file p
gistfile1-2 copy 2.applescript
open file q
gistfile1-2 copy 2.applescript
set theURL to URL of current tab
Duplicate-Tab.applescript
set current tab to make new tab with properties {URL:theURL}
Duplicate-Tab.applescript
tell the last phrase
Spell Last Spoken Phrase.applescript
set readme to the content
Spell Last Spoken Phrase.applescript
set r to «class ktxt» of ((readme as text) as record)
Spell Last Spoken Phrase.applescript
set exp to {}
Spell Last Spoken Phrase.applescript
repeat with x in the characters of r
Spell Last Spoken Phrase.applescript
if contents of x = " " then
Spell Last Spoken Phrase.applescript
set the end of exp to " space "
Spell Last Spoken Phrase.applescript
else if contents of x = "\"" then
Spell Last Spoken Phrase.applescript
set the end of exp to " double quote "
Spell Last Spoken Phrase.applescript
else if contents of x = "\\" then
Spell Last Spoken Phrase.applescript
set the end of exp to " back slash "
Spell Last Spoken Phrase.applescript
set the end of exp to x as text
Spell Last Spoken Phrase.applescript
set the end of exp to ", " as text
Spell Last Spoken Phrase.applescript
set exp to exp as text
Spell Last Spoken Phrase.applescript
set exp to "empty"
Spell Last Spoken Phrase.applescript
output (exp as text)
Spell Last Spoken Phrase.applescript
set the_selection to (selection of front window as string)
selection-to-r.applescript
if (the_selection) is "" then
selection-to-r.applescript
set the_selection to line (get startLine of selection) of front window as string
selection-to-r.applescript
tell application "R"
selection-to-r.applescript
cmd the_selection
selection-to-r.applescript
tell application "TextWrangler" to activate
selection-to-r.applescript
keystroke (ASCII character 31) --move cursor down one line
selection-to-r.applescript
on open_directory_new_window(dir)
OpeniTerm.applescript
set p to (dir as text)
OpeniTerm.applescript
tell newWindow to set mySession to current session
OpeniTerm.applescript
tell mySession to write text "cd " & quoted form of p
OpeniTerm.applescript
end open_directory_new_window
OpeniTerm.applescript
set w to the front window
new_tab_current_directory_and_settings.scpt
set origName to name
new_tab_current_directory_and_settings.scpt
set title displays device name to not title displays device name
new_tab_current_directory_and_settings.scpt
set newName to name
new_tab_current_directory_and_settings.scpt
set tty to extractTTY(origName, newName)
new_tab_current_directory_and_settings.scpt
if tty is "" then
new_tab_current_directory_and_settings.scpt
display dialog "Could not find the tty for of the current Terminal window." buttons "Cancel" cancel button "Cancel" default button "Cancel"
new_tab_current_directory_and_settings.scpt
set pids to paragraphs of (do shell script "
new_tab_current_directory_and_settings.scpt
ps -o pid,tty,tpgid,pgid,state,command |
new_tab_current_directory_and_settings.scpt
awk '
new_tab_current_directory_and_settings.scpt
BEGIN {t=ARGV[1];ARGC=1}
new_tab_current_directory_and_settings.scpt
$2==t && $3==$4 {print $1}
new_tab_current_directory_and_settings.scpt
' " & quoted form of tty)
new_tab_current_directory_and_settings.scpt
if pids is {} or pids is {""} then
new_tab_current_directory_and_settings.scpt
display dialog "Could not find the processes for " & tty & "." buttons "Cancel" cancel button "Cancel" default button "Cancel"
new_tab_current_directory_and_settings.scpt
set lsof to do shell script "lsof -F 0n -a -d cwd -p " & quoted form of (pids as Unicode text) without altering line endings
new_tab_current_directory_and_settings.scpt
set text item delimiters to {(ASCII character 0) & (ASCII character 10)}
new_tab_current_directory_and_settings.scpt
set cwds to {}
new_tab_current_directory_and_settings.scpt
repeat with lsofItem in text items of lsof
new_tab_current_directory_and_settings.scpt
if lsofItem starts with "n" then
new_tab_current_directory_and_settings.scpt
set cwd to text 2 through end of lsofItem
new_tab_current_directory_and_settings.scpt
if cwds does not contain cwd then ¬
new_tab_current_directory_and_settings.scpt
set end of cwds to cwd
new_tab_current_directory_and_settings.scpt
if cwds is {} then
new_tab_current_directory_and_settings.scpt
display dialog "No cwds found!?" buttons "Cancel" cancel button "Cancel" default button "Cancel"
new_tab_current_directory_and_settings.scpt
if length of cwds is greater than 1 then
new_tab_current_directory_and_settings.scpt
set cwds to choose from list cwds with title "Multiple Distinct CWDs" with prompt "Choose the directory to use:" without multiple selections allowed and empty selection allowed
new_tab_current_directory_and_settings.scpt
if cwds is false then error number -128 -- cancel
new_tab_current_directory_and_settings.scpt
set settings to name of current settings in selected tab
new_tab_current_directory_and_settings.scpt
menu_click({"Terminal", "Shell", "New Tab", settings})
new_tab_current_directory_and_settings.scpt
tell application "Terminal" to do script "cd " & quoted form of item 1 of cwds in selected tab of window 1
new_tab_current_directory_and_settings.scpt
to extractTTY(a, b)
new_tab_current_directory_and_settings.scpt
set str to textLeftAfterRemovingMatchingHeadAndTail(a, b)
new_tab_current_directory_and_settings.scpt
set offs to offset of "tty" in str
new_tab_current_directory_and_settings.scpt
if offs > 0 then
new_tab_current_directory_and_settings.scpt
return text offs through (offs + 6) of str
new_tab_current_directory_and_settings.scpt
end extractTTY
new_tab_current_directory_and_settings.scpt
to textLeftAfterRemovingMatchingHeadAndTail(big, little)
new_tab_current_directory_and_settings.scpt
if class of big is not list then set big to text items of big
new_tab_current_directory_and_settings.scpt
if class of little is not list then set little to text items of little
new_tab_current_directory_and_settings.scpt
set {maxLen, minLen} to {length of big, length of little}
new_tab_current_directory_and_settings.scpt