* Chrome will inform you that this extension can "Read your browsing history". This is a result of two permissions that we require: "webNavigation" to intercept navigation requests and rewrite the URL, and "tabs" to open the existing extension options page (if already exists) instead of creating a new one when you click on the icon. I do not care about your browsing history.
* You can now remove part of a URL by leaving the replacement text blank.
* The test page warns you if your rewrite rule is going to remove the protocol (http://, https://) from URLs making them relative.
Based on "Host name rewriter" by Mattias Lundberg.
URL Rewriter edits certain URLs, whether typed in or linked, via a set of rules before navigating to the URL. A rule consists of a regular expression specified in capture groups, a capture group number to replace, and the replacement text for that group. When you click on a link or type a URL in the address bar, it is checked against each of the rules. If a matching rule is found, the text of the specified capturing group number is replaced with the specified text.
- Regex: ^(http[s]?\:\/\/.*\.)(toothboiler)(\..*\/watch\?v=.*)$
- Group number to replace: 2
- Replacement text: youtube
- If you click a link for "http://www.toothboiler.com/watch?v=abcdefg", it matches the regex rule and capture group 2 ("toothboiler") is replaced with "youtube" to result in "http://www.youtube.com/watch?v=abcdefg".