From dc430f1eff851a1206c30bb6fb6af5938e9df029 Mon Sep 17 00:00:00 2001 From: Raymond Hill Date: Tue, 14 Aug 2018 14:32:56 -0400 Subject: [PATCH] fix https://github.com/uBlockOrigin/uBlock-issues/issues/167 --- platform/chromium/vapi-usercss.real.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/platform/chromium/vapi-usercss.real.js b/platform/chromium/vapi-usercss.real.js index 82142204c..3b7c987b6 100644 --- a/platform/chromium/vapi-usercss.real.js +++ b/platform/chromium/vapi-usercss.real.js @@ -66,8 +66,14 @@ vAPI.DOMFilterer = function() { this.excludedNodeSet = new WeakSet(); this.addedCSSRules = new Set(); + // https://github.com/uBlockOrigin/uBlock-issues/issues/167 + // By the time the DOMContentLoaded is fired, the content script might + // have been disconnected from the background page. Unclear why this + // would happen, so far seems to be a Chromium-specific behavior at + // launch time. if ( this.domIsReady !== true ) { - document.addEventListener('DOMContentLoaded', () => { + document.addEventListener('DOMContentLoaded', ( ) => { + if ( vAPI instanceof Object === false ) { return; } this.domIsReady = true; this.commit(); });