Remove previous Safari overhead; cleanup workarounds from rest of code

This commit is contained in:
Chris 2015-02-10 14:24:04 -07:00
parent 029a673a58
commit a17882a8cc
6 changed files with 19 additions and 46 deletions

View File

@ -150,12 +150,6 @@ vAPI.messaging = {
/******************************************************************************/ /******************************************************************************/
vAPI.canExecuteContentScript = function() {
return true;
};
/******************************************************************************/
})(); })();
/******************************************************************************/ /******************************************************************************/

View File

@ -166,12 +166,6 @@ window.addEventListener('pageshow', vAPI.messaging.toggleListener, true);
/******************************************************************************/ /******************************************************************************/
vAPI.canExecuteContentScript = function() {
return true;
};
/******************************************************************************/
})(this); })(this);
/******************************************************************************/ /******************************************************************************/

View File

@ -32,7 +32,6 @@
var vAPI = self.vAPI = self.vAPI || {}; var vAPI = self.vAPI = self.vAPI || {};
vAPI.safari = true; vAPI.safari = true;
var noopFunc = function(){};
/******************************************************************************/ /******************************************************************************/
@ -349,12 +348,10 @@
if(details.file) { if(details.file) {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.overrideMimeType('application/x-javascript;charset=utf-8'); xhr.open('GET', details.file, true);
xhr.open('GET', details.file, false); xhr.addEventListener("readystatechange", function() {
xhr.send(); if(this.readyState === 4) {
details.code = xhr.responseText; details.code = xhr.responseText;
}
tab.page.dispatchMessage('broadcast', { tab.page.dispatchMessage('broadcast', {
channelName: 'vAPI', channelName: 'vAPI',
msg: { msg: {
@ -362,10 +359,13 @@
details: details details: details
} }
}); });
if(typeof callback === 'function') { if(typeof callback === 'function') {
setTimeout(callback, 13); setTimeout(callback, 13);
} }
}
});
xhr.send();
}
}; };
/******************************************************************************/ /******************************************************************************/
@ -488,7 +488,7 @@
vAPI.messaging = { vAPI.messaging = {
listeners: {}, listeners: {},
defaultHandler: null, defaultHandler: null,
NOOPFUNC: noopFunc, NOOPFUNC: function() {},
UNHANDLED: 'vAPI.messaging.notHandled' UNHANDLED: 'vAPI.messaging.notHandled'
}; };

View File

@ -146,10 +146,6 @@
} }
}; };
vAPI.canExecuteContentScript = function() {
return (/^https?:/.test(location.protocol) && typeof safari === "object");
};
// The following code should run only in content pages // The following code should run only in content pages
if(location.protocol === "safari-extension:" || typeof safari !== "object") { if(location.protocol === "safari-extension:" || typeof safari !== "object") {
return; return;

View File

@ -42,11 +42,6 @@ if ( !vAPI ) {
return; return;
} }
if ( vAPI.canExecuteContentScript() !== true ) {
//console.debug('contentscript-end.js > can\'t execute');
return;
}
// https://github.com/gorhill/uBlock/issues/587 // https://github.com/gorhill/uBlock/issues/587
// Pointless to execute without the start script having done its job. // Pointless to execute without the start script having done its job.
if ( !vAPI.contentscriptStartInjected ) { if ( !vAPI.contentscriptStartInjected ) {

View File

@ -46,12 +46,6 @@ if ( !vAPI ) {
return; return;
} }
// Because Safari
if ( vAPI.canExecuteContentScript() !== true ) {
//console.debug('contentscript-start.js > can\'t execute');
return;
}
// https://github.com/gorhill/uBlock/issues/456 // https://github.com/gorhill/uBlock/issues/456
// Already injected? // Already injected?
if ( vAPI.contentscriptStartInjected ) { if ( vAPI.contentscriptStartInjected ) {