Web Dev Notes

Blog about web development by Robert Dawson

Bookmarklet to switch subdomains

If you ever find yourself needing to switch subdomains, such as from beta.mysite.com to www.mysite.com, here is a bookmarklet to make life easier. Because dragging my mouse to the address bar, selecting the entire subdomain, and then tediously typing in a new one is so exhausting!

With this handy bookmarklet, all you have to do is click it and type in the subdomain you want. It's not telepathy, but it's tolerable. To make this bookmarklet, make a new bookmark on any given page and then replace the URL with the following code.

javascript:var env=prompt("Subdomain?","e.g., www");if(env!="e.g., www"){window.location=window.location.href.replace(/http:\/\/(.+?)\.(.+?)\.(.+)/g, "http://"+env+".$2.$3");};

Automator script to copy all open URLs in Safari to clipboard


You need to send someone (or do anything with) a list of URLs you have open (in Safari or Chrome on Mac).


Use this Automator workflow script:

on run {input, parameters}
	set _urls to {}
	tell application "Safari"
		repeat with _tab in tabs of window 1
			set end of _urls to URL of _tab
		end repeat
	end tell
	set {_tid, AppleScript's text item delimiters} to {AppleScript's text item delimiters, return}
	set the clipboard to _urls as string
	set AppleScript's text item delimiters to _tid
	return input
end run

Then, just paste wherever you like!