1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-11-23 02:42:41 +01:00
This commit is contained in:
gorhill 2017-08-17 08:25:02 -04:00
parent d1c752da29
commit fdcc9515dc
No known key found for this signature in database
GPG Key ID: 25E1490B761470C2
3 changed files with 10 additions and 140 deletions

View File

@ -72,70 +72,6 @@ if ( vAPI.sessionId ) {
/******************************************************************************/ /******************************************************************************/
var referenceCounter = 0;
vAPI.lock = function() {
referenceCounter += 1;
};
vAPI.unlock = function() {
referenceCounter -= 1;
if ( referenceCounter === 0 ) {
// Eventually there will be code here to flush the javascript code
// from this file out of memory when it ends up unused.
}
};
/******************************************************************************/
vAPI.executionCost = {
start: function(){},
stop: function(){}
};
/*
vAPI.executionCost = {
tcost: 0,
tstart: 0,
nstart: 0,
level: 1,
start: function() {
if ( this.nstart === 0 ) {
this.tstart = window.performance.now();
}
this.nstart += 1;
},
stop: function(mark) {
this.nstart -= 1;
if ( this.nstart !== 0 ) {
return;
}
var tcost = window.performance.now() - this.tstart;
this.tcost += tcost;
if ( mark === undefined ) {
return;
}
var top = window === window.top;
if ( !top && this.level < 2 ) {
return;
}
var context = window === window.top ? ' top' : 'frame';
var percent = this.tcost / window.performance.now() * 100;
console.log(
'uBO cost (%s): %sms/%s%% (%s: %sms)',
context,
this.tcost.toFixed(1),
percent.toFixed(1),
mark,
tcost.toFixed(2)
);
}
};
*/
vAPI.executionCost.start();
/******************************************************************************/
vAPI.randomToken = function() { vAPI.randomToken = function() {
return String.fromCharCode(Date.now() % 26 + 97) + return String.fromCharCode(Date.now() % 26 + 97) +
Math.floor(Math.random() * 982451653 + 982451653).toString(36); Math.floor(Math.random() * 982451653 + 982451653).toString(36);
@ -412,8 +348,6 @@ vAPI.shutdown.add(function() {
// https://www.youtube.com/watch?v=rT5zCHn0tsg // https://www.youtube.com/watch?v=rT5zCHn0tsg
// https://www.youtube.com/watch?v=E-jS4e3zacI // https://www.youtube.com/watch?v=E-jS4e3zacI
vAPI.executionCost.stop('vapi-client.js');
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/

View File

@ -54,63 +54,6 @@ var vAPI = self.vAPI;
/******************************************************************************/ /******************************************************************************/
var referenceCounter = 0;
vAPI.lock = function() {
referenceCounter += 1;
};
vAPI.unlock = function() {
referenceCounter -= 1;
};
/******************************************************************************/
vAPI.executionCost = {
start: function(){},
stop: function(){}
};
/*
vAPI.executionCost = vAPI.executionCost || {
tcost: 0,
tstart: 0,
nstart: 0,
level: 1,
start: function() {
if ( this.nstart === 0 ) {
this.tstart = window.performance.now();
}
this.nstart += 1;
},
stop: function(mark) {
this.nstart -= 1;
if ( this.nstart !== 0 ) {
return;
}
var tcost = window.performance.now() - this.tstart;
this.tcost += tcost;
if ( mark === undefined ) {
return;
}
var top = window === window.top;
if ( !top && this.level < 2 ) {
return;
}
var context = window === window.top ? ' top' : 'frame';
var percent = this.tcost / window.performance.now() * 100;
console.log(
'uBO cost (' + context + '): ' +
this.tcost.toFixed(1) + 'ms/' +
percent.toFixed(1) + '% (' +
mark + ': ' + tcost.toFixed(2) + 'ms)'
);
}
};
*/
vAPI.executionCost.start();
/******************************************************************************/
vAPI.firefox = true; vAPI.firefox = true;
vAPI.randomToken = function() { vAPI.randomToken = function() {
@ -498,10 +441,6 @@ if ( window !== window.top ) {
/******************************************************************************/ /******************************************************************************/
vAPI.executionCost.stop('vapi-client.js');
/******************************************************************************/
})(this); })(this);
/******************************************************************************/ /******************************************************************************/

View File

@ -77,17 +77,15 @@
*/ */
/******************************************************************************/ // Abort execution if our global vAPI object does not exist.
/******************************************************************************/ // https://github.com/chrisaljoudi/uBlock/issues/456
/******************************************************************************/ // https://github.com/gorhill/uBlock/issues/2029
// Abort execution by throwing if an unexpected condition arise. if ( self.vAPI !== undefined ) { // >>>>>>>> start of HUGE-IF-BLOCK
// - https://github.com/chrisaljoudi/uBlock/issues/456
if ( typeof vAPI !== 'object' ) { /******************************************************************************/
throw new Error('uBlock Origin: aborting content scripts for ' + window.location); /******************************************************************************/
} /******************************************************************************/
vAPI.lock();
vAPI.matchesProp = (function() { vAPI.matchesProp = (function() {
var docElem = document.documentElement; var docElem = document.documentElement;
@ -805,7 +803,6 @@ return domFilterer;
if ( !cfeDetails || !cfeDetails.ready ) { if ( !cfeDetails || !cfeDetails.ready ) {
vAPI.domWatcher = vAPI.domCollapser = vAPI.domFilterer = vAPI.domWatcher = vAPI.domCollapser = vAPI.domFilterer =
vAPI.domSurveyor = vAPI.domIsLoaded = null; vAPI.domSurveyor = vAPI.domIsLoaded = null;
vAPI.unlock();
return; return;
} }
@ -1611,9 +1608,7 @@ vAPI.domSurveyor = (function() {
vAPI.domIsLoaded = function(ev) { vAPI.domIsLoaded = function(ev) {
// This can happen on Firefox. For instance: // This can happen on Firefox. For instance:
// https://github.com/gorhill/uBlock/issues/1893 // https://github.com/gorhill/uBlock/issues/1893
if ( window.location === null ) { if ( window.location === null ) { return; }
return;
}
var slowLoad = ev instanceof Event; var slowLoad = ev instanceof Event;
if ( slowLoad ) { if ( slowLoad ) {
@ -1678,3 +1673,5 @@ vAPI.domIsLoaded = function(ev) {
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
/******************************************************************************/ /******************************************************************************/
} // <<<<<<<< end of HUGE-IF-BLOCK