Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function() {
- const monkeyPatch = () => {
- const origOpen = window.XMLHttpRequest.prototype.open;
- window.XMLHttpRequest.prototype.open = function(method, url) {
- const requestObj = {
- xhrId: __ATOMRIGS_INPAGE_REQUEST_COUNTER__++,
- url,
- method
- };
- this.__atomrigs_xhr__ = requestObj;
- window.postMessage({
- protocol: "pga.inpage-request",
- data: requestObj
- });
- this.addEventListener("load", function() {
- if (this.responseType === "blob")
- return;
- try {
- const res = JSON.parse(this.responseText);
- const isLogin = url === "https://pixels-server.pixels.xyz/v1/auth/complete_onetime_authentication" || url === "https://pixels-server.pixels.xyz/v1/auth/complete_crypto_authentication";
- if (url === "https://pixels-server.pixels.xyz/v1/auth/initialize" || isLogin) {
- window.postMessage({
- protocol: "pga.inpage-to-app",
- func: "emit",
- data: {
- ...this.__atomrigs_xhr__,
- func: "initialize-api-response",
- payload: {
- user: {
- id: res.player._id,
- name: res.player.username
- },
- isLogin
- }
- }
- });
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement