Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update m3u8-downloader.user.js #147

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

liudonghua123
Copy link

fix incorrect overwrite of XHR.open.

See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply.

If not pass all the arguments down to the original XHR.open, some ajax of jquery would be failed like async: false or authentication.

I found this bug due to the Biometric login of https://ids.ynu.edu.cn/ isn't always shown if enabled this content script.

After some debugging, I found it's an ajax call with async: false not working expected. The xhr.open is overwrited incorrect by this script. The third argument async is not passed.

See also the following snapshots.

image

image

realXHR.open = function (method, url) {
url.toString() && url.toString().indexOf('.m3u8') > 0 && checkM3u8Url(url.toString())
// if (url.toString() && url.toString().toLocaleLowerCase().indexOf('.mp4') > 0) {
// appendDom();
// document.getElementById('mp4-show').style.display = 'block'
// mp4Objs.push({
// url,
// fileName: url.slice(url.lastIndexOf('/') + 1).split('?')[0],
// });
// }
originOpen.call(realXHR, method, url)
}

fix incorrect overwrite of XHR.open.

See also https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply.

If not pass all the arguments down to the original XHR.open, some ajax of jquery would be failed like `async: false` or authentication.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant