function redirectForTwitchAuthToken(action) {
		// If the action is "random"
		if (action === "random") {
			localStorage.setItem("rjp-afterAuthAction", "random"); // Set afterAuthAction to "random"
		}
		// Else if it is stream
		else if (action === "stream") {
			localStorage.setItem("rjp-afterAuthAction", streamURL); // Set afterAuthAction to the current stream URL
		} // Otherwise ignore action value

		// Remove event listener for when the page is reloaded in order to stop the confirmUnload dialog
		window.removeEventListener("beforeunload", confirmUnload);

		// Send the user to get an auth token
		document.location.href = `https://id.twitch.tv/oauth2/authorize?client_id=${twitchClientID}&redirect_uri=${window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" ? "http://localhost:5500/" : window.location.origin + window.location.pathname}&response_type=token`;
	}
// Accepts an action string to perform when it receives a response from Twitch
Accepts an action string to perform when it receives a response from Twitch
Accepts an action string to perform when it receives a response from Twitch
function redirectForTwitchAuthToken(action) {
		if (action === "random") {
			localStorage.setItem("rjp-afterAuthAction", "random"); 
		}
		else if (action === "stream") {
			localStorage.setItem("rjp-afterAuthAction", streamURL); 
		} 
		window.removeEventListener("beforeunload", confirmUnload);
		document.location.href = `https://id.twitch.tv/oauth2/authorize?client_id=${twitchClientID}&redirect_uri=${window.location.hostname === "localhost" || window.location.hostname === "127.0.0.1" ? "http://localhost:5500/" : window.location.origin + window.location.pathname}&response_type=token`;
	}
function redirectForTwitchAuthToken ( action ) { if ( action === "random" ) { localStorage . setItem ( "rjp-afterAuthAction" , "random" ) ; } else if ( action === "stream" ) { localStorage . setItem ( "rjp-afterAuthAction" , streamURL ) ; } window . removeEventListener ( "beforeunload" , confirmUnload ) ; document . location . href = ` ${ twitchClientID } ${ window . location . hostname === "localhost" || window . location . hostname === "127.0.0.1" ? "http://localhost:5500/" : window . location . origin + window . location . pathname } ` ; }
Accepts an action string to perform when it receives a response from Twitch
Accepts an action string to perform when it receives a response from Twitch
// If the action is "random" // Set afterAuthAction to "random" // Else if it is stream // Set afterAuthAction to the current stream URL // Otherwise ignore action value // Remove event listener for when the page is reloaded in order to stop the confirmUnload dialog // Send the user to get an auth token