Get a certain link depending on the current URL

Hey Guys im new here, iv been making a add-on for chrome/firefox and at the moment im just testing it and playing around with a few things, At the moment iv just taken the easy way out and duplicated all my code and just change the getJson URL in each of them.

I need to break it all down into one, but to do that i need to have some sort of “if this URL is true then load this JSON” , im not good at explaining things but yeah,

Or is there a way to get a name of a “channel” from the source (" view-source:https://www.twitch.tv/forthevoyeur ") ?

Im all new with javascript and like i said im just playing around for the time being.

Everything is written in JavaScript

You want to get the channel name from a Twitch.tv URL? That’s just the stuff after the / in most cases (you might want to filter settings and subscriptions and all that).

Since the twitch API goes by twitch login, the thing in the URL is actually exactly what you want.