Skip to content

Instantly share code, notes, and snippets.

View tuktukvlad's full-sized avatar
👽
tothemoon

Vladislav K tuktukvlad

👽
tothemoon
View GitHub Profile
@tuktukvlad
tuktukvlad / ajaxListener.js
Created November 24, 2020 13:05 — forked from icodejs/ajaxListener.js
JS: Listen to ajax calls from Javascript
var open = window.XMLHttpRequest.prototype.open,
send = window.XMLHttpRequest.prototype.send,
onReadyStateChange;
function openReplacement(method, url, async, user, password) {
var syncMode = async !== false ? 'async' : 'sync';
console.warn(
'Preparing ' +
syncMode +
' HTTP request : ' +
// From https://github.com/MaxArt2501/base64-js/blob/master/base64.js
(function () {
if (window.atob) {
// Some browsers' implementation of atob doesn't support whitespaces
// in the encoded string (notably, IE). This wraps the native atob
// in a function that strips the whitespaces.
// The original function can be retrieved in atob.original
try {
window.atob(' ');
} catch (e) {