Skip to content

Instantly share code, notes, and snippets.

@AndyShade
Forked from jkmartindale/awa-twitch.js
Created August 11, 2024 09:59
Show Gist options
  • Save AndyShade/c31d76a19f28f63e4895d53963f7da1a to your computer and use it in GitHub Desktop.
Save AndyShade/c31d76a19f28f63e4895d53963f7da1a to your computer and use it in GitHub Desktop.

Revisions

  1. @jkmartindale jkmartindale revised this gist Feb 15, 2024. No changes.
  2. @jkmartindale jkmartindale revised this gist Apr 6, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -1,4 +1,4 @@
    /* Twitch Quest Fixer v3 */
    /* Twitch Quest Fixer v3.1 */
    const extensionID = "ehc5ey5g9hoehi8ys54lr6eknomqgr";
    const channel = location.pathname.slice(1).toLowerCase();
    const channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY["channel({\"name\":\""+channel+"\"})"].__ref.split(":")[1];
    @@ -36,7 +36,7 @@ grantPermission = async () => {
    }

    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
    fetch("https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track", {
    method: 'GET',
    headers: {
    'x-extension-jwt': authToken,
  3. @jkmartindale jkmartindale revised this gist Mar 13, 2023. No changes.
  4. @jkmartindale jkmartindale revised this gist Mar 13, 2023. No changes.
  5. @jkmartindale jkmartindale revised this gist Mar 13, 2023. No changes.
  6. @jkmartindale jkmartindale revised this gist Mar 13, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -20,7 +20,7 @@ grantPermission = async () => {
    "operationName": "LinkUserMutation",
    "variables": {
    "channelID": channelId,
    "extensionID": "ehc5ey5g9hoehi8ys54lr6eknomqgr",
    "extensionID": extensionID,
    "token": authToken,
    "showUser": true
    },
  7. @jkmartindale jkmartindale revised this gist Mar 13, 2023. 1 changed file with 42 additions and 3 deletions.
    45 changes: 42 additions & 3 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,40 @@
    var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1];
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    /* Twitch Quest Fixer v3 */
    const extensionID = "ehc5ey5g9hoehi8ys54lr6eknomqgr";
    const channel = location.pathname.slice(1).toLowerCase();
    const channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY["channel({\"name\":\""+channel+"\"})"].__ref.split(":")[1];
    const pollDuration = 60000;
    let authToken = __APOLLO_CLIENT__.cache.data.data["Channel:" + channelId].selfInstalledExtensions.filter(x => x.helixToken.extensionID == extensionID)[0].token.jwt;

    grantPermission = async () => {
    console.log("Attempting to grant permission automatically...");
    const integrityResponse = await (await fetch("https://gql.twitch.tv/integrity", { method: "post", headers: commonOptions.headers })).json();
    const integrity = integrityResponse.token;
    const permissionResponse = await (await fetch("https://gql.twitch.tv/gql", {
    method: "post",
    headers: {
    ...commonOptions.headers, ...{
    "Client-Integrity": integrity
    }
    },
    body: JSON.stringify([{
    "operationName": "LinkUserMutation",
    "variables": {
    "channelID": channelId,
    "extensionID": "ehc5ey5g9hoehi8ys54lr6eknomqgr",
    "token": authToken,
    "showUser": true
    },
    "extensions": { "persistedQuery": { "version": 1, "sha256Hash": "b5dfec96759d42ac5a24f79beec27bcdf90e936e0fac4f727b7ab36dadb6a22a" } }
    }])
    })).json();
    console.log(permissionResponse);
    newAuthToken = permissionResponse[0].data.extensionLinkUser.token.jwt;
    if (newAuthToken) {
    authToken = newAuthToken;
    console.log("Looks like permission was successfully granted. You should see another message saying that you're earning ARP about 60 seconds from now.");
    };
    }

    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    @@ -10,8 +44,13 @@ handlePolling = () => {
    }
    })
    .then(response => response.json())
    .then(data => {
    .then(async data => {

    console.log(data);
    /* Attempt to authorize extension if not authorized */
    if (data.state === "grant_permission") {
    await grantPermission();
    };
    })
    .catch((err) => {
    console.log(err);
  8. @jkmartindale jkmartindale revised this gist Feb 25, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    const pollDuration = 60000;
    handlePolling = () => {
    fetch(`https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track`, {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    headers: {
    'x-extension-jwt': authToken,
  9. @jkmartindale jkmartindale revised this gist Feb 19, 2023. 1 changed file with 0 additions and 1 deletion.
    1 change: 0 additions & 1 deletion awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,6 @@ var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    const pollDuration = 60000;
    handlePolling = () => {
    /* Server source code: https://github.com/jkmartindale/alienware-arena-fix */
    fetch(`https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    headers: {
  10. @jkmartindale jkmartindale revised this gist Feb 19, 2023. 1 changed file with 1 addition and 0 deletions.
    1 change: 1 addition & 0 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -2,6 +2,7 @@ var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    const pollDuration = 60000;
    handlePolling = () => {
    /* Server source code: https://github.com/jkmartindale/alienware-arena-fix */
    fetch(`https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    headers: {
  11. @jkmartindale jkmartindale revised this gist Feb 19, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -2,7 +2,7 @@ var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    const pollDuration = 60000;
    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
    fetch(`https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    headers: {
    'x-extension-jwt': authToken,
  12. @jkmartindale jkmartindale revised this gist Feb 8, 2023. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -19,5 +19,5 @@ handlePolling = () => {
    .finally(() => {
    setTimeout(handlePolling, pollDuration);
    });
    }
    };
    handlePolling()
  13. @jkmartindale jkmartindale revised this gist Feb 8, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1]
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt
    var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1];
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt;
    const pollDuration = 60000;
    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
  14. @jkmartindale jkmartindale revised this gist Feb 8, 2023. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1]
    authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt
    var channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1]
    var authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt
    const pollDuration = 60000;
    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
  15. @jkmartindale jkmartindale created this gist Feb 8, 2023.
    23 changes: 23 additions & 0 deletions awa-twitch.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,23 @@
    channelId = __APOLLO_CLIENT__.cache.data.data.ROOT_QUERY[`channel({\"name\":\"${location.pathname.slice(1).toLowerCase()}\"})`].__ref.split(":")[1]
    authToken = __APOLLO_CLIENT__.cache.data.data[`Channel:${channelId}`].selfInstalledExtensions.filter(x=>x.helixToken.extensionID=="ehc5ey5g9hoehi8ys54lr6eknomqgr")[0].token.jwt
    const pollDuration = 60000;
    handlePolling = () => {
    fetch(`https://www.alienwarearena.com/twitch/extensions/track`, {
    method: 'GET',
    headers: {
    'x-extension-jwt': authToken,
    'x-extension-channel': channelId
    }
    })
    .then(response => response.json())
    .then(data => {
    console.log(data);
    })
    .catch((err) => {
    console.log(err);
    })
    .finally(() => {
    setTimeout(handlePolling, pollDuration);
    });
    }
    handlePolling()