Applescript - Firefox

Status
Not open for further replies.
Joined
May 4, 2009
Messages
5
Reaction score
0
Points
1
Hello,

Can anybody tell me how to use applescript to put the current URL of firefox into a variable (something like set a to URL, but that doesn't seem to work)

Basically, what I wanted to try, was making a program that would track how long I'd spent on each site I'd visit, but if I applescript doesn't know what URL I am on it doesn't know when to start and stop tracking the time.

So could anybody help me ?

-Floris

Edit: I just figured I can get the name of the front window, which is allmost just as good, best would be getting the url though.
 
OP
F
Joined
May 4, 2009
Messages
5
Reaction score
0
Points
1
Okay, I still need to find out how to extract the Url, I figured some other things out myself.

Some other thing I was puzzling with was replacing words in a text, but I figured out what Iwas doing wrong.
The whole thing I did wrongly was using the TELL command. Kind of confusing how you need to tell some things to the document, while some things need to be told to the text of the document.
 
OP
F
Joined
May 4, 2009
Messages
5
Reaction score
0
Points
1
Okay so basically this forum is really crappy or am I mistaken?
 

cwa107


Retired Staff
Joined
Dec 20, 2006
Messages
27,042
Reaction score
812
Points
113
Location
Lake Mary, Florida
Your Mac's Specs
14" MacBook Pro M1 Pro, 16GB RAM, 1TB SSD
Okay so basically this forum is really crappy or am I mistaken?

Patience. You need a very specific answer on Applescript, which not everyone is an expert with. Give it time.
 
OP
F
Joined
May 4, 2009
Messages
5
Reaction score
0
Points
1
Nah, the point is all the spam :p

Only the Url is still needed. Some intense googling helped me with alot of things. I think there should be some better Applescript tutorials though, most of them I tried went way too slow. If you mastered BASIC, you still need to learn some essential thing about applescript, which I figured out by googling and lots of trial and error....

And there are looooaaaads of people asking questions on the internet, getting answers which to me where really vague, while later on I found ways to do it all way more easy...
 

dtravis7


Retired Staff
Joined
Jan 4, 2005
Messages
30,133
Reaction score
703
Points
113
Location
Modesto, Ca.
Your Mac's Specs
MacMini M-1 MacOS Monterey, iMac 2010 27"Quad I7 , MBPLate2011, iPad Pro10.5", iPhoneSE
What Spam would that be? No spam lasts more than a few minutes here.
 
OP
F
Joined
May 4, 2009
Messages
5
Reaction score
0
Points
1
Yeah thats right maybe I am judging to fast, sorry. Anyways, I'll just post the thing I made in case anybody cares, it took me hours googling and stuff to figure all the things out needed to make this, I still don't know how to get an url but I like my program so far (altough I don't think I will ever use it, but it's cool that it works nontheless).
set b to 1
set a to 0
tell application "TextEdit"
activate
end tell
tell application "Firefox"
set c to name of front window
set c to (every word of c) as string
set d to c
end tell
repeat while b = 1
delay 1
set a to a + 1
tell application "Firefox"
set yu to name of the front window
if yu is not "" then
set d to (every word of yu) as string
end if
end tell
if c is not d then
tell application "TextEdit"
if the text of the front document contains c then
tell the text of the front document
set ui to the first paragraph where it contains c
delete (the first paragraph where it contains c)
set a to (a + (word 2 of ui as integer))
end tell
end if
set h to the text of the front document
set the text of the front document to h & c & " " & a & "
"
set a to 0
end tell
end if
tell application "Firefox"
set yu to name of the front window
if yu is not "" then
set c to (every word of yu) as string
end if
end tell
end repeat
 
Status
Not open for further replies.

Shop Amazon


Shop for your Apple, Mac, iPhone and other computer products on Amazon.
We are a participant in the Amazon Services LLC Associates Program, an affiliate program designed to provide a means for us to earn fees by linking to Amazon and affiliated sites.
Top