From bf99623a54fef739bd21777c1ac52da53a004c0b Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Sun, 29 Sep 2019 12:26:58 -0400 Subject: [PATCH] Add sanity checks In rare circumstances, it's possible the content script lose access to the background page, best to check against this to avoid spurious console errors. --- src/js/contentscript.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/js/contentscript.js b/src/js/contentscript.js index f0246bce9..f0510a9dc 100644 --- a/src/js/contentscript.js +++ b/src/js/contentscript.js @@ -148,6 +148,7 @@ vAPI.SafeAnimationFrame = function(callback) { vAPI.SafeAnimationFrame.prototype = { start: function(delay) { + if ( vAPI instanceof Object === false ) { return; } if ( delay === undefined ) { if ( this.fid === undefined ) { this.fid = requestAnimationFrame(( ) => { this.onRAF(); } ); @@ -1454,7 +1455,8 @@ vAPI.bootstrap = (function() { // to try bootstrapping again later. const bootstrapPhase1 = function(response) { - if ( response === null ) { return; } + if ( response instanceof Object === false ) { return; } + vAPI.bootstrap = undefined; // cosmetic filtering engine aka 'cfe'