Skip to main content
Commonmark migration
Source Link
added 1410 characters in body
Source Link
markhunte
  • 12.3k
  • 1
  • 34
  • 55

UPDATE Second idea.

To possibly satisfy any one who does not want to use the clipboard. And wants to stick to using a file (webloc)

This Applescript when saved as an Application and in the Dock.

Will when first run ask for a folder where the single webloc file is stored.

The folder should only ever have one file inside.

When run any time after it will open the file or any other file you place in the folder.

If it cannot find a file in the folder or the folder it's self when you run the app to open the url it will warn you and offer you the choice to reset the folder.

property theUrl : ""

on run
    
    if theUrl is not "" then
        try
            tell application "System Events" to set chosenFile to POSIX path of (file 1 of theUrl) whose visible is true
            
            do shell script "open " & quoted form of chosenFile & " -b org.mozilla.firefox"
        on error errm
            
            display dialog "ERROR : The URL Folder may be empty or not exist" with icon 0 buttons {"Reset Folder", "OK"} default button 1 giving up after 5
            copy the result as list to {button_pressed, text_returned}
            if button_pressed is "Reset Folder" then
                set theUrl to (choose folder)
            end if
        end try
    else
        
        set theUrl to (choose folder)
    end if
    
    
end run

UPDATE Second idea.

To possibly satisfy any one who does not want to use the clipboard. And wants to stick to using a file (webloc)

This Applescript when saved as an Application and in the Dock.

Will when first run ask for a folder where the single webloc file is stored.

The folder should only ever have one file inside.

When run any time after it will open the file or any other file you place in the folder.

If it cannot find a file in the folder or the folder it's self when you run the app to open the url it will warn you and offer you the choice to reset the folder.

property theUrl : ""

on run
    
    if theUrl is not "" then
        try
            tell application "System Events" to set chosenFile to POSIX path of (file 1 of theUrl) whose visible is true
            
            do shell script "open " & quoted form of chosenFile & " -b org.mozilla.firefox"
        on error errm
            
            display dialog "ERROR : The URL Folder may be empty or not exist" with icon 0 buttons {"Reset Folder", "OK"} default button 1 giving up after 5
            copy the result as list to {button_pressed, text_returned}
            if button_pressed is "Reset Folder" then
                set theUrl to (choose folder)
            end if
        end try
    else
        
        set theUrl to (choose folder)
    end if
    
    
end run
added 33 characters in body
Source Link
markhunte
  • 12.3k
  • 1
  • 34
  • 55
(* stored url *)
property theUrl : ""

on run
    
    (* check if the clipboard has an http url*)
    set fromClip to the clipboard as string
    
    if fromClip starts with "http:" or fromClip starts with "https:" then
        (* Theclipboard has an http url so this means we want to update the apps url to open in firefox *)
        
        (* Confirm this is what we want to do, and we can make adjustments to the url*)
        display dialog "Set new URL to " default answer fromClip buttons {"Cancel", "OK"} default button 1
        
        
        copy the result as list to {button_pressed, text_returned}
        if button_pressed is "OK" then
            (* Set the url to the stored property*)
            set theUrl to text_returned
            
            (* Clear the clipboard*)
            set the clipboard to ""
        end if
        
        
    else
        (* check if the clipboard DID NOT start with http url*)
        if theUrl is not "" then
            (* This means   we want to open the current url in firefox *)
            do shell script "open " & quoted form of theUrl & " -b org.mozilla.firefox"
        end if
        
    end if
    
    
end run
(* stored url *)
property theUrl : ""

on run
    
    (* check if the clipboard has an http url*)
    set fromClip to the clipboard as string
    
    if fromClip starts with "http:" then
        (* Theclipboard has an http url so this means we want to update the apps url to open in firefox *)
        
        (* Confirm this is what we want to do, and we can make adjustments to the url*)
        display dialog "Set new URL to " default answer fromClip buttons {"Cancel", "OK"} default button 1
        
        
        copy the result as list to {button_pressed, text_returned}
        if button_pressed is "OK" then
            (* Set the url to the stored property*)
            set theUrl to text_returned
            
            (* Clear the clipboard*)
            set the clipboard to ""
        end if
        
        
    else
        (* check if the clipboard DID NOT start with http url*)
        if theUrl is not "" then
            (* This means   we want to open the current url in firefox *)
            do shell script "open " & quoted form of theUrl & " -b org.mozilla.firefox"
        end if
        
    end if
    
    
end run
(* stored url *)
property theUrl : ""

on run
    
    (* check if the clipboard has an http url*)
    set fromClip to the clipboard as string
    
    if fromClip starts with "http:" or fromClip starts with "https:" then
        (* Theclipboard has an http url so this means we want to update the apps url to open in firefox *)
        
        (* Confirm this is what we want to do, and we can make adjustments to the url*)
        display dialog "Set new URL to " default answer fromClip buttons {"Cancel", "OK"} default button 1
        
        
        copy the result as list to {button_pressed, text_returned}
        if button_pressed is "OK" then
            (* Set the url to the stored property*)
            set theUrl to text_returned
            
            (* Clear the clipboard*)
            set the clipboard to ""
        end if
        
        
    else
        (* check if the clipboard DID NOT start with http url*)
        if theUrl is not "" then
            (* This means   we want to open the current url in firefox *)
            do shell script "open " & quoted form of theUrl & " -b org.mozilla.firefox"
        end if
        
    end if
    
    
end run
added 585 characters in body
Source Link
markhunte
  • 12.3k
  • 1
  • 34
  • 55
Loading
Source Link
markhunte
  • 12.3k
  • 1
  • 34
  • 55
Loading