mirror of
https://github.com/gorhill/uBlock.git
synced 2024-11-23 02:42:41 +01:00
fix #2029
This commit is contained in:
parent
d1c752da29
commit
fdcc9515dc
@ -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() {
|
||||
return String.fromCharCode(Date.now() % 26 + 97) +
|
||||
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=E-jS4e3zacI
|
||||
|
||||
vAPI.executionCost.stop('vapi-client.js');
|
||||
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
|
@ -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.randomToken = function() {
|
||||
@ -498,10 +441,6 @@ if ( window !== window.top ) {
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.executionCost.stop('vapi-client.js');
|
||||
|
||||
/******************************************************************************/
|
||||
|
||||
})(this);
|
||||
|
||||
/******************************************************************************/
|
||||
|
@ -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.
|
||||
// - https://github.com/chrisaljoudi/uBlock/issues/456
|
||||
if ( self.vAPI !== undefined ) { // >>>>>>>> start of HUGE-IF-BLOCK
|
||||
|
||||
if ( typeof vAPI !== 'object' ) {
|
||||
throw new Error('uBlock Origin: aborting content scripts for ' + window.location);
|
||||
}
|
||||
vAPI.lock();
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
vAPI.matchesProp = (function() {
|
||||
var docElem = document.documentElement;
|
||||
@ -805,7 +803,6 @@ return domFilterer;
|
||||
if ( !cfeDetails || !cfeDetails.ready ) {
|
||||
vAPI.domWatcher = vAPI.domCollapser = vAPI.domFilterer =
|
||||
vAPI.domSurveyor = vAPI.domIsLoaded = null;
|
||||
vAPI.unlock();
|
||||
return;
|
||||
}
|
||||
|
||||
@ -1611,9 +1608,7 @@ vAPI.domSurveyor = (function() {
|
||||
vAPI.domIsLoaded = function(ev) {
|
||||
// This can happen on Firefox. For instance:
|
||||
// https://github.com/gorhill/uBlock/issues/1893
|
||||
if ( window.location === null ) {
|
||||
return;
|
||||
}
|
||||
if ( window.location === null ) { return; }
|
||||
|
||||
var slowLoad = ev instanceof Event;
|
||||
if ( slowLoad ) {
|
||||
@ -1678,3 +1673,5 @@ vAPI.domIsLoaded = function(ev) {
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
/******************************************************************************/
|
||||
|
||||
} // <<<<<<<< end of HUGE-IF-BLOCK
|
||||
|
Loading…
Reference in New Issue
Block a user