| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-2016 Eyeo GmbH | 3 * Copyright (C) 2006-2016 Eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 23 matching lines...) Expand all Loading... |
| 34 if (!isDirty) | 34 if (!isDirty) |
| 35 { | 35 { |
| 36 isDirty = true; | 36 isDirty = true; |
| 37 Utils.runAsync(() => { | 37 Utils.runAsync(() => { |
| 38 isDirty = false; | 38 isDirty = false; |
| 39 port.emit("elemhideupdate") | 39 port.emit("elemhideupdate") |
| 40 }); | 40 }); |
| 41 } | 41 } |
| 42 }); | 42 }); |
| 43 | 43 |
| 44 let translateMap = map => map; | 44 port.on("getUnconditionalSelectors", () => |
| 45 if (Services.vc.compare(Utils.platformVersion, "40.0") <= 0) | |
| 46 { | 45 { |
| 47 translateMap = map => | 46 return [ |
| 48 { | 47 ElemHide.getUnconditionalSelectors(), |
| 49 // We cannot send Map objects with Gecko 40 and below, "translate" them | 48 ElemHide.getUnconditionalFilterKeys() |
| 50 // into nested arrays. This isn't very efficient but that should be ok as | 49 ]; |
| 51 // long as only outdated Firefox versions are affected. | 50 }); |
| 52 let translated = []; | |
| 53 for (let [key, value] of map) | |
| 54 { | |
| 55 if (value instanceof Map) | |
| 56 translated.push([key, translateMap(value)]); | |
| 57 else | |
| 58 translated.push([key, value]); | |
| 59 } | |
| 60 return translated; | |
| 61 }; | |
| 62 } | |
| 63 | 51 |
| 64 port.on("getSelectors", () => translateMap(ElemHide.getSelectors())); | 52 port.on("getSelectorsForDomain", domain => |
| 53 { |
| 54 return ElemHide.getSelectorsForDomain(domain, ElemHide.NO_UNCONDITIONAL, |
| 55 true); |
| 56 }); |
| 65 | 57 |
| 66 port.on("elemhideEnabled", ({frames, isPrivate}) => | 58 port.on("elemhideEnabled", ({frames, isPrivate}) => |
| 67 { | 59 { |
| 68 if (!Prefs.enabled) | 60 if (!Prefs.enabled) |
| 69 return {enabled: false}; | 61 return {enabled: false}; |
| 70 | 62 |
| 71 let hit = Policy.isFrameWhitelisted(frames, true); | 63 let hit = Policy.isFrameWhitelisted(frames, true); |
| 72 if (hit) | 64 if (hit) |
| 73 { | 65 { |
| 74 let [frameIndex, contentType, docDomain, thirdParty, location, filter] = hit
; | 66 let [frameIndex, contentType, docDomain, thirdParty, location, filter] = hit
; |
| 75 if (contentType != "GENERICHIDE") | 67 if (contentType != "GENERICHIDE") |
| 76 { | 68 { |
| 77 if (!isPrivate) | 69 if (!isPrivate) |
| 78 FilterStorage.increaseHitCount(filter); | 70 FilterStorage.increaseHitCount(filter); |
| 79 return { | 71 return { |
| 80 enabled: false, | 72 enabled: false, |
| 81 contentType, docDomain, thirdParty, location, | 73 contentType, docDomain, thirdParty, location, |
| 82 filter: filter.text, filterType: filter.type | 74 filter: filter.text, filterType: filter.type |
| 83 }; | 75 }; |
| 84 } | 76 } |
| 85 } | 77 } |
| 86 | 78 |
| 87 return {enabled: true}; | 79 return {enabled: true}; |
| 88 }); | 80 }); |
| 81 |
| 82 port.on("registerElemHideHit", ({key, frames, isPrivate}) => |
| 83 { |
| 84 let filter = ElemHide.getFilterByKey(key); |
| 85 if (!filter) |
| 86 return null; |
| 87 |
| 88 if (!isPrivate) |
| 89 FilterStorage.increaseHitCount(filter); |
| 90 |
| 91 let docDomain; |
| 92 try |
| 93 { |
| 94 docDomain = Utils.unwrapURL(frames[0].location).host; |
| 95 } |
| 96 catch(e) |
| 97 { |
| 98 docDomain = null; |
| 99 } |
| 100 |
| 101 return { |
| 102 contentType: "ELEMHIDE", |
| 103 docDomain, |
| 104 thirdParty: false, |
| 105 location: filter.text.replace(/^.*?#/, '#'), |
| 106 filter: filter.text, |
| 107 filterType: filter.type |
| 108 }; |
| 109 }); |
| OLD | NEW |