-2

I'm new to Javascript.

I think it's a Javascript function. To elaborate, is there a way to make a bookmark with a function to add something behind the ".com"?

For example the function will be in the bookmarks and when I click it, it will add what I typed in it like if I'm on tumbr. The function will have "add '/archive' after '.com' function" and it will instantly add it.

Before: www.thisisjustanexample.tumblr.com After: www.thisisjustanexample.tumblr.com/archive

Can someone direct me to what this function is called? And if you know how to type the code if it's a simple one.

dda
  • 6,030
  • 2
  • 25
  • 34
raskyl
  • 1

1 Answers1

0

You can create a bookmark with this kind of url: javascript:window.location = window.location + "/archive" (tested, it works :))

Nico
  • 255
  • 2
  • 12
  • okay! but what if there were some things after the ".com" would there be a way to specifically putting the code right after .com? – raskyl Jan 31 '17 at 09:14
  • Maybe using a replace and a regexp. (.replace(/(https?:\/\/(.+)\.com)(\??.*)/, "$1/archive$2") – Nico Jan 31 '17 at 13:14