Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var twitch = window.Twitch.ext;
- var authorizationComplete = false;
- twitch.onAuthorized(function(credentials) {
- console.log("Auth complete");
- authorizationComplete = true;
- document.getElementById("config-form").addEventListener("submit", handleFormSubmission);
- document.getElementById("submit-button").removeAttribute("disabled");
- //getConfiguration();
- });
- twitch.configuration.onChanged(()=>{
- let config = twitch.configuration.broadcaster ? this.twitch.configuration.broadcaster.content : [];
- try {
- config = JSON.parse(config);
- } catch (e) {
- config = [];
- console.log(e.message);
- }
- console.log(config);
- })
- function handleFormSubmission() {
- console.log("Handling form submission");
- console.log("Starting with: " + twitch.configuration.broadcaster.content + " at " + twitch.configuration.broadcaster.version);
- if (!authorizationComplete) {
- console.log("Call before auth");
- return;
- }
- var usernameElement = document.getElementById("username-box");
- twitch.configuration.set("broadcaster", "2", JSON.stringify({
- "username": usernameElement.value,
- }));
- console.log("Done");
- console.log(JSON.stringify({
- "username": usernameElement.value
- }));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement