Skip to content

Instantly share code, notes, and snippets.

@Tithen-Firion
Last active September 1, 2021 19:01
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Tithen-Firion/e58d22e4b97cdfb90400c5b1ddbfc647 to your computer and use it in GitHub Desktop.
Save Tithen-Firion/e58d22e4b97cdfb90400c5b1ddbfc647 to your computer and use it in GitHub Desktop.
WeTV - hijack callback

With this code you can hijack the JSON data WeTV player loads - doesn't matter the encryption version. Change the hijackedCallback function to do whatever you want with the data and then you can create a bookmarklet with this tool. After running the bookmarklet it will hijack one request - initial video load or when you change the quality. Comment out line 10 if you want it to keep hijacking.


If you use this code in your project - let me know and credit me. ;)

let hijackedCallback = data => {
console.log(JSON.stringify(data));
console.log(data);
};
new MutationObserver((mutations, observer) => {
for(let mutation of mutations) {
for(let element of mutation.addedNodes) {
if(element.tagName === 'SCRIPT' && element.src.indexOf('/play.') > -1) {
observer.disconnect(); // you can comment that line out if you want to keep observing
let callbackName = (new URL(element.src)).searchParams.get('callback');
(name => {
let realCallback = window[name];
window[name] = data => {
realCallback(data);
hijackedCallback(data);
};
})(callbackName);
}
}
}
}).observe(document.head, {childList: true});
@Tithen-Firion
Copy link
Author

You run this code and then change the video quality. You can see that hijackedCallback simply logs the data to the browser console (F12 > Console). This is just an example, you can do whatever you want with that data.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment