1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-10-06 09:37:12 +02:00
gorhill 2014-10-26 10:19:38 -04:00
parent 8fc0b4c00d
commit e594dfa8ab

View File

@ -226,11 +226,18 @@ var cachedAssetsManager = (function() {
/******************************************************************************/
var getTextFileFromURL = function(url, onLoad, onError) {
// https://github.com/gorhill/uMatrix/issues/15
var onResponseReceived = function() {
if ( typeof this.status === 'number' && this.status >= 200 && this.status < 300 ) {
return onLoad.call(this);
}
return onError.call(this);
};
// console.log('µBlock> getTextFileFromURL("%s"):', url);
var xhr = new XMLHttpRequest();
xhr.responseType = 'text';
xhr.timeout = 15000;
xhr.onload = onLoad;
xhr.onload = onResponseReceived;
xhr.onerror = onError;
xhr.ontimeout = onError;
xhr.open('get', url, true);