-
-
Save jkmartindale/c2a2cb83e6a2e889c7e3aa7b37b5fedc to your computer and use it in GitHub Desktop.
/* 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]; | |
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": extensionID, | |
"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://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track", { | |
method: 'GET', | |
headers: { | |
'x-extension-jwt': authToken, | |
'x-extension-channel': channelId | |
} | |
}) | |
.then(response => response.json()) | |
.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); | |
}) | |
.finally(() => { | |
setTimeout(handlePolling, pollDuration); | |
}); | |
}; | |
handlePolling() |
Twitch quests seem to be working again without help so I'm not going to send requests through my server by default. If you get 404 errors with this fix, try replacing line 39 with:
fetch("https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track", {
Is there any way that you can provide a code to those of us who haven't granted the extension permission?
Because even though the code works, it only works if you've granted permission to the extension beforehand - something which I screwed up when removing its permission a few minutes ago in the hopes that I could probably make it work again by removing and granting it permission again afterwards. I'm a bit stuck here.
So basically is there a possibility for a code that grants the extension its permission through the console?
I think it might be possible but it's a whole lot harder, and I'm in the middle of a cross-country move right now so I haven't been able to take a better look at it yet. The whole authorization flow is owned by Twitch and I don't know how their authentication works.
Fair enough. It was worth a try. I mean it IS my own fault for disabling its permission in the hopes that I can grant it back and maybe make the extension work again.
Anyway, thank you very much for the quick reply, AND for the magic code, of course.
Keep up the good work and have a good one!
Is there any way that you can provide a code to those of us who haven't granted the extension permission?
Had an idea come to me while I was cooking and it ended up being simpler than I thought. Try it out now.
Holy shit, dude! You're a genius!
Not only did the new code grant permission to the extension on its own, but it also helped me get my daily Twitch ARP with no issues.
Thank you SO MUCH!
Thanks for this code!
Is there a way to not have a reference to your domain, but instead a static string? https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track
Is there a way to not have a reference to your domain, but instead a static string?
https://alienware.jkmartindale.dev/?url=https://www.alienwarearena.com/twitch/extensions/track
You can just replace it with https://www.alienwarearena.com/twitch/extensions/track
. This will also make it functionally identical to the existing widget that comes with the Twitch panel.
Thanks!
So all I have to do is go to https://www.twitch.tv/directory, be logged in and execute the code?
So all I have to do is go to https://www.twitch.tv/directory, be logged in and execute the code?
What exactly are you trying to accomplish with this script?
This is a replacement for the Twitch ARP earning widget. It will not work on the Twitch directory page, just like how the Twitch ARP widget wouldn't work there because there's no stream. You need to be watching a streamer eligible for Twitch ARP earnings and you need make sure the existing Twitch ARP widget is loaded first before pasting the code into the console.
I know people superstitiously swear by this script but as far as I'm aware, it's not going to provide any benefit anymore. The only benefit it has provided in the past year or so is the CORS proxy, which fixes an occasional issue with how AWA servers handle a browser security check and also gives you a new IP address in case you need to tell the Fastly CDN between you and AWA to update your Twitch earnings cap.
Since you previously mentioned you want to remove the proxy, I'm pretty sure whatever it is you're trying to do won't happen with this script. Happy to know if I'm wrong.
Ah, sorry for misunderstanding then! My use case would have been to trigger the Twitch ARP earnings without having to have a twitch stream loaded, saving system resources. And I was under the (incorrect) assumption that your script would help with that. I didn't realize the purpose of the script was to fix some issue.
My use case would have been to trigger the Twitch ARP earnings without having to have a twitch stream loaded, saving system resources.
If it helps, you can pause the stream and the regular widget will keep pinging AWA every minute and earn you ARP
so we can just pause the stream and keep it in a hidden tab, and it'll still count? i often have trouble with keeping my ARP twitch count going
so we can just pause the stream and keep it in a hidden tab, and it'll still count? i often have trouble with keeping my ARP twitch count going
The way the AWA widget is designed and intended to work, yes. All you should need to do is get the stream running, and scroll down to load the panel if the streamer is still using the old widget that isn't the overlay. As soon as the widget is loaded, it runs in a loop every minute to ping AWA to tell them who you're watching and get you some ARP.
However, different browsers on different devices and with different settings treat inactive tabs differently. Some of them slow down the timer, some of them may sleep an inactive tab after a period of time. I've personally never had issues leaving the stream on and then playing a game or something, but I have a decent bit of RAM and afaik disabled suspending inactive tabs in Chrome.
There's been people reporting slow ARP earnings. Some of them are people who never got the memo that only Hive streamers give 0.4 ARP/min and the rest 0.2 ARP/min, but some of them seem to be people legitimately encountering a slowdown. I've never really noticed because I let the stream go for however long and then I come back a couple hours later and it's done. So no clue what else is or is not happening.
today i literally got 0 ARP in firefox..
Uncaught ReferenceError: APOLLO_CLIENT is not defined
debugger eval code:4
debugger eval code:4:19
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.sprig.com/sdk/1/environments/zIy65lh0OA/config. (Reason: CORS request did not succeed). Status code: (null).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.sprig.com/sdk/1/environments/zIy65lh0OA/config. (Reason: CORS request did not succeed). Status code: (null).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.sprig.com/sdk/1/environments/zIy65lh0OA/config. (Reason: CORS request did not succeed). Status code: (null).
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.sprig.com/sdk/1/environments/zIy65lh0OA/config. (Reason: CORS request did not succeed). Status code: (null).
UserLeap - Disabled: failed to fetch configuration vendor.sprig-controller.min.js-bcc43c50eaa7ca69183b.js:1:27259
UserLeap - Disabled: failed to fetch configuration vendor.sprig-controller.min.js-bcc43c50eaa7ca69183b.js:1:27259
Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.sprig.com/sdk/1/errors. (Reason: CORS request did not succeed). Status code: (null).
UserLeap - Disabled: failed to fetch configuration vendor.sprig-controller.min.js-bcc43c50eaa7ca69183b.js:1:27259
[Sprig] (ERR-444) Failed to report error to API TypeError: NetworkError when attempting to fetch resource. vendor.sprig-controller.min.js-bcc43c50eaa7ca69183b.js:1:171948
21:11:40 - [VideoTransformer] WebGPU unavailable player-core-variant-b-abb06cd8c786cc1a0940.js:1:31732
Amazon IVS Player SDK 1.38.0-rc.2 amazon-ivs-wasmworker.min-4ca0f140b1a435d8fec3.js:1:49847
MediaCapabilities found
Array [ {…}, {…} ]
amazon-ivs-wasmworker.min-4ca0f140b1a435d8fec3.js:1:105572
InstallTrigger is deprecated and will be removed in the future. nat.min.js:6901:35
WEBGL_debug_renderer_info is deprecated in Firefox and will be removed. Please use RENDERER. nat.min.js:7447:21
Use of the orientation sensor is deprecated. nat.min.js:3415:19
Moving to buffered region 0.005666 0 player-core-variant-b-abb06cd8c786cc1a0940.js:1:61952
Uncaught ReferenceError: APOLLO_CLIENT is not defined
Looks like Twitch just changed something that broke how API queries are handled. Honestly surprised that code worked as long as it did because it was a bit of a hack. I'm AFK on international travel for a bit but I'll take a look eventually. I'm honestly surprised people still feel a need to use this.
Can you send a screenshot of the AWA panel? Just curious what it's saying that is making you try this ancient script.
Uncaught ReferenceError: APOLLO_CLIENT is not defined
at :4:19
i cant see success message and i cannot take ARP anymore.
Original code from Alienware's Twitch widget (to compare against): https://ehc5ey5g9hoehi8ys54lr6eknomqgr.ext-twitch.tv/ehc5ey5g9hoehi8ys54lr6eknomqgr/1.0.0/361e558ed213dda8e3ed6a8e8d761431/js/rewards-tracker.js
Source code for the server this script runs data through: https://github.com/jkmartindale/alienware-arena-fix