Skip to content
Permalink
Browse files

fix #2029

  • Loading branch information...
gorhill committed Aug 17, 2017
1 parent d1c752d commit fdcc9515dc3c65ea6978d22468e0ba343b15c5b3
Showing with 9 additions and 139 deletions.
  1. +0 −66 platform/chromium/vapi-client.js
  2. +0 −61 platform/firefox/vapi-client.js
  3. +9 −12 src/js/contentscript.js
@@ -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,18 +77,16 @@
*/

// Abort execution if our global vAPI object does not exist.
// https://github.com/chrisaljoudi/uBlock/issues/456
// https://github.com/gorhill/uBlock/issues/2029

if ( self.vAPI !== undefined ) { // >>>>>>>> start of HUGE-IF-BLOCK

/******************************************************************************/
/******************************************************************************/
/******************************************************************************/

// Abort execution by throwing if an unexpected condition arise.
// - 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() {
var docElem = document.documentElement;
if ( typeof docElem.matches !== 'function' ) {
@@ -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

0 comments on commit fdcc951

Please sign in to comment.
You can’t perform that action at this time.