Last active
December 15, 2022 07:07
-
-
Save aldodelgado/7198aa47bc779b0ea2758b4b46d12a25 to your computer and use it in GitHub Desktop.
Object Builder for the birds
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
let admins = []; | |
let speakers = []; | |
let listeners = []; | |
(function(open) { | |
window.XMLHttpRequest.prototype.open = function() { | |
this.addEventListener("readystatechange", function() { | |
if (this.readyState == 4) { | |
if (this.responseURL.includes('AudioSpaceById')) { | |
let obj = JSON.parse(this.response); | |
obj.data.audioSpace.participants.admins.forEach(function (item, index) { | |
var admin_index = admins.findIndex(admin => admin.periscope_user_id == item.periscope_user_id); | |
admin_index === -1 ? admins.push(item) : console.log("object already exists") | |
}); | |
obj.data.audioSpace.participants.speakers.forEach(function (item, index) { | |
var speaker_index = speakers.findIndex(speaker => speaker.periscope_user_id == item.periscope_user_id); | |
speaker_index === -1 ? speakers.push(item) : console.log("object already exists") | |
}); | |
obj.data.audioSpace.participants.listeners.forEach(function (item, index) { | |
var listener_index = listeners.findIndex(listener => listener.periscope_user_id == item.periscope_user_id); | |
listener_index === -1 ? listeners.push(item) : console.log("object already exists") | |
}); | |
console.log(obj.data.audioSpace.participants); | |
} | |
} | |
}, false); | |
open.apply(this, arguments); | |
}; | |
})(window.XMLHttpRequest.prototype.open); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment