Skip to content

Instantly share code, notes, and snippets.

@tegomass
tegomass / cancelAJAX.js
Last active April 20, 2018 13:44 — forked from Integralist/cancelAJAX.js
Cancel all jQuery AJAX requests currently running
let xhrQueue = [];
$(document).ajaxSend(function(event,jqxhr,settings){
xhrQueue.push(jqxhr);
});
$(document).ajaxComplete(function(event,jqxhr,settings){
let i;
if((i=$.inArray(jqxhr,xhrQueue)) > -1){
xhrQueue.splice(i,1);
}
});
@tegomass
tegomass / waitForKeyElementsSingle.js
Created March 5, 2021 12:53 — forked from BrockA/waitForKeyElements.js
A utility function, for Greasemonkey scripts, that detects and handles AJAXed content.
/*--- waitForKeyElements(): A utility function, for Greasemonkey scripts,
that detects and handles AJAXed content.
Usage example:
waitForKeyElements (
"div.comments"
, commentCallbackFunction
);