0

I'm wanting to make a bookmarklet that would change a webpage from

http://user.tumblr.com/post/123456789 to
http://user.tumblr.com/liked/by/user

with just a click. I'm usually alright at frankensteining code together, and I've been looking at the Tumblr manual reblog button that uses "window.location" along with Bookmarklet to edit current URL and Replace end characters of current URL with bookmarklet

I can't see anything useable that would extract a subdomain into a variable and then place it in a new URL. I did stumble across this code:

^http://([^.]+)\.domain\.com

But I have no idea what that means or how to use it.

Community
  • 1
  • 1

1 Answers1

0

Not sure if this is what your looking for, but I use as I have multiple instances of my site and what bookmarks to keep me in the same instance regardless of port or protocol.

New Tab

javascript:(function(){window.open(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})();

Current Tab

javascript:(function(){window.location.assign(location.protocol+'//'+location.hostname+':'+location.port+'/liked/by/user')})();

EDIT: Forgot to put code blocks

eweb
  • 27
  • 7
  • That works well, is there any way to detect the subdomain (location.subdomain doesn't work) and replace 'user' with it? – user1102021 Dec 17 '11 at 23:04