How to create .webloc files without mousing in big sur?
How to create .webloc files without mousing in big sur? Dragging url from safari to desktop
doesn't work.
MacBook Pro 13″, macOS 11.1
How to create .webloc files without mousing in big sur? Dragging url from safari to desktop
doesn't work.
MacBook Pro 13″, macOS 11.1
this won't solve the dragging problem, however if you want to create a website desktop alias...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>https://PUT-URL-HERE</string>
</dict>
</plist>
this won't solve the dragging problem, however if you want to create a website desktop alias...
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>URL</key>
<string>https://PUT-URL-HERE</string>
</dict>
</plist>
Dragging the actual URL string and not the favicon from the Safari 14.0.2 address panel does create a .webloc for me on Big Sur 11.1.
If you want to programmatically generate a .webloc using the name and URL of the current default browser's page, the following will write a .webloc on the Desktop. Currently, it only supports Safari and Firefox.
-- webloc.applscript
-- Given a default browser (currently Safari and Firefox supported) generate a .webloc of bearing the title of the
-- current site, and its URL to the Desktop.
-- Tested: AppleScript, Safari 14.0.2, Firefox 85 on Big Sur 11.1
-- VikingOSX, 2021-01-04, Apple Support Communities, No warranties of any kind.
use framework "Foundation"
use framework "AppKit"
use scripting additions
property NSMutableDictionary : a reference to current application's NSMutableDictionary
property NSURL : a reference to current application's NSURL
property NSWorkspace : a reference to current application's NSWorkspace
property NSString : a reference to current application's NSString
property chromium_derivatives : {"Google Chrome", "Chromium", "Opera", "Vivaldi", "Brave Browser", "Microsoft Edge"}
set browser_name to my default_browser()
if browser_name is missing value then return
if browser_name contains "Safari" then
tell application "Safari"
activate
tell front document
set webloc_name to its name
set webloc_URL to its URL
end tell
end tell
else if browser_name contains "Firefox" then
# until Mozilla provides AppleScript properties
tell application "Firefox"
activate
set webloc_name to name of front window
tell application "System Events"
keystroke "l" using {command down}
keystroke "c" using {command down}
key code 36
end tell
end tell
tell application "Finder" to set webloc_URL to (the clipboard)
else if chromium_derivatives contains browser_name then
display alert "Chromium-based browser: " & browser_name & " unsupported at this time." giving up after 10
return
else
display alert "Unsupported browser : " & my browser_namer as text & " is unsupported at this time." giving up after 10
end if
set status to my gen_webloc("~/Desktop", webloc_URL, webloc_name)
if not status then display alert "webloc not written to Desktop"
return
on gen_webloc(awhere, aurl, aname)
# generate a .webloc with default browser's front windows URL and tab name for filename
set fixed_name to (NSString's stringWithString:aname)'s mutableCopy()
# just say no to long-winded white space names
# fixed_name's stringByReplacingOccurrencesOfString:" " withString:"_"
fixed_name's stringByReplacingOccurrencesOfString:"." withString:" "
fixed_name's appendString:".webloc"
set webloc to ((NSString's stringWithString:awhere)'s stringByAppendingPathComponent:fixed_name)'s stringByStandardizingPath()
# next two lines build .webloc plist skeleton with URL key
set dict to NSMutableDictionary's dictionaryWithCapacity:1
dict's setObject:aurl forKey:"URL"
set wstatus to dict's writeToFile:webloc atomically:0
return wstatus as boolean
end gen_webloc
on default_browser()
# return default browser name that would open this URL
set URL_Apple to NSURL's URLWithString:"https://www.apple.com"
set browser_name to ((NSWorkspace's sharedWorkspace)'s URLForApplicationToOpenURL:URL_Apple)'s lastPathComponent()
return (browser_name's stringByDeletingPathExtension()) as text
end default_browser
Although the following code works as written for Google Chrome, it fails when one uses a variable for the browser name instead of an explicitly quoted reference to Google Chrome. Got tired of dealing with it.
use scripting additions
tell application "Google Chrome"
activate
set webloc_name to title of active tab of front window
set webloc_URL to URL of active tab of front window
end tell
return
What happens when you drag the url to the Desktop?
I seem to be able to do it.
How to create .webloc files without mousing in big sur?