So a great guy helped me (Automator: Applescript - Open a specific Google Chrome profile and use extension). Now, I want to implement the next step into this.
I can now run a specific Chrome profile and use a specific extension function that basically opens a Chrome setup that I saved (various websites opening with specific dimensions on my monitors and with specific placements)
This is the script:
set chrome to "\"/Applications/Google Chrome.app/Contents/MacOS/Google Chrome\""
do shell script chrome & " --profile-directory=\"Profile 6\"" & " > /dev/null 2>&1 &"
tell application "Google Chrome" to activate
delay 0.25
tell application "System Events"
click ¬
pop up button "Multi Layout Manager" of ¬
toolbar 1 of group 1 of window 1 of ¬
application process "Chrome"
delay 0.25
repeat 3 times
key code 48 -- # tab key
delay 0.2
end repeat
key code 36 -- # enter key
end tell
What I want now, is for some of these websites to change their scrollbars so that I can see the part of the website that interests me in front of me.
I've found this script that works but only by itself.
set myURL to "https://weather.com/weather/hourbyhour/l/12345"
set scrollAmount to "16" --- % down the page
tell application "Google Chrome"
activate
tell front window to set curTab to make new tab at after (get active tab) with properties {URL:myURL}
tell curTab
repeat while (loading)
delay 1
end repeat
-- set the vertical scroll
execute javascript "h=document.documentElement.scrollHeight-
document.documentElement.clientHeight; window.scrollTo(0,h*" & scrollAmount & "/100)"
end tell
end tell
I tried, but my knowledge is limited and can't make the two of them work together.
On its simple form, I want the script to pick one of the sites that the first script opens and change its scrollbar.
Any help would be appreciated.
UPDATE
I managed to make it work using this script:
delay 3
tell application "Google Chrome" to tell active tab of window 1
execute javascript "window.scroll(0,270)"
end tell
The issue now is that it takes the active tab and applies the scroll function. I want it to find a different tab and apply it.
The tab is in a different window though.
Any way around it?