Skip to content

Instantly share code, notes, and snippets.

@kzar
Created September 22, 2017 09:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kzar/a724861d8dbff146b9590c777afea774 to your computer and use it in GitHub Desktop.
Save kzar/a724861d8dbff146b9590c777afea774 to your computer and use it in GitHub Desktop.
adblockplusui critical dependency webpack fix
diff --git a/messageResponder.js b/messageResponder.js
index 65e91ea..7ed00c7 100644
--- a/messageResponder.js
+++ b/messageResponder.js
@@ -21,8 +21,6 @@
(function(global)
{
- let ext = global.ext || require("ext_background");
-
const {port} = require("messaging");
const {Prefs} = require("prefs");
const {Utils} = require("utils");
@@ -42,22 +40,6 @@
SpecialSubscription
} = require("subscriptionClasses");
- // Some modules doesn't exist on Firefox. Moreover,
- // require() throws an exception on Firefox in that case.
- // However, try/catch causes the whole function to to be
- // deoptimized on V8. So we wrap it into another function.
- function tryRequire(module)
- {
- try
- {
- return require(module);
- }
- catch (e)
- {
- return null;
- }
- }
-
function convertObject(keys, obj)
{
let result = {};
@@ -159,7 +141,7 @@
{
if (message.what == "issues")
{
- let subscriptionInit = tryRequire("subscriptionInit");
+ let subscriptionInit = require("subscriptionInit");
let result = subscriptionInit ? subscriptionInit.reinitialized : false;
return {filterlistsReinitialized: result};
}
@@ -233,10 +215,11 @@
port.on("filters.get", (message, sender) =>
{
+ const {checkWhitelisted} = require("whitelisting");
+
if (message.what == "elemhideemulation")
{
let filters = [];
- const {checkWhitelisted} = require("whitelisting");
let isWhitelisted = checkWhitelisted(sender.page, sender.frame,
RegExpFilter.typeMap.DOCUMENT | RegExpFilter.typeMap.ELEMHIDE);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment