Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: lib/elemHideFF.js

Issue 29356078: Issue 524 - Stop using @-moz-document (Closed) Base URL: https://hg.adblockplus.org/adblockplus
Patch Set: Improved comment Created Oct. 6, 2016, 12:24 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
« lib/contentPolicy.js ('K') | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: lib/elemHideFF.js
===================================================================
--- a/lib/elemHideFF.js
+++ b/lib/elemHideFF.js
@@ -36,37 +36,29 @@ FilterNotifier.on("elemhideupdate", () =
isDirty = true;
Utils.runAsync(() => {
isDirty = false;
port.emit("elemhideupdate")
});
}
});
-let translateMap = map => map;
-if (Services.vc.compare(Utils.platformVersion, "40.0") <= 0)
+port.on("getUnconditionalSelectors", () =>
{
- translateMap = map =>
- {
- // We cannot send Map objects with Gecko 40 and below, "translate" them
- // into nested arrays. This isn't very efficient but that should be ok as
- // long as only outdated Firefox versions are affected.
- let translated = [];
- for (let [key, value] of map)
- {
- if (value instanceof Map)
- translated.push([key, translateMap(value)]);
- else
- translated.push([key, value]);
- }
- return translated;
- };
-}
+ return [
+ ElemHide.getUnconditionalSelectors(),
+ ElemHide.getUnconditionalFilterKeys()
+ ];
+});
-port.on("getSelectors", () => translateMap(ElemHide.getSelectors()));
+port.on("getSelectorsForDomain", domain =>
+{
+ return ElemHide.getSelectorsForDomain(domain, ElemHide.NO_UNCONDITIONAL,
+ true);
+});
port.on("elemhideEnabled", ({frames, isPrivate}) =>
{
if (!Prefs.enabled)
return {enabled: false};
let hit = Policy.isFrameWhitelisted(frames, true);
if (hit)
@@ -81,8 +73,37 @@ port.on("elemhideEnabled", ({frames, isP
contentType, docDomain, thirdParty, location,
filter: filter.text, filterType: filter.type
};
}
}
return {enabled: true};
});
+
+port.on("registerElemHideHit", ({key, frames, isPrivate}) =>
+{
+ let filter = ElemHide.getFilterByKey(key);
+ if (!filter)
+ return null;
+
+ if (!isPrivate)
+ FilterStorage.increaseHitCount(filter);
+
+ let docDomain;
+ try
+ {
+ docDomain = Utils.unwrapURL(frames[0].location).host;
+ }
+ catch(e)
+ {
+ docDomain = null;
+ }
+
+ return {
+ contentType: "ELEMHIDE",
+ docDomain,
+ thirdParty: false,
+ location: filter.text.replace(/^.*?#/, '#'),
+ filter: filter.text,
+ filterType: filter.type
+ };
+});
« lib/contentPolicy.js ('K') | « lib/contentPolicy.js ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld