Tracking protection refactor to use new builtin base

This commit is contained in:
Jiiks 2018-08-25 16:58:27 +03:00
parent aa0882c449
commit 937ab55456
1 changed files with 15 additions and 15 deletions

View File

@ -14,23 +14,23 @@ import { Patcher, MonkeyPatch, Reflection } from 'modules';
export default new class E2EE extends BuiltinModule {
get settingPath() {
return ['security', 'default', 'tracking-protection'];
/* Getters */
get moduleName() { return 'TrackingProtection' }
get settingPath() { return ['security', 'default', 'tracking-protection'] }
/* Patches */
applyPatches() {
if (this.patches.length) return;
const TrackingModule = Reflection.module.byProps('track');
if (!TrackingModule) {
this.warn('Tracking module not found!');
return;
}
this.patch(TrackingModule, 'track', this.track, 'instead');
}
track(e) {
// console.log('Blocked Tracking');
this.debug('Tracking blocked');
}
enabled(e) {
if (Patcher.getPatchesByCaller('BD:TrackingProtection').length) return;
const trackingModule = Reflection.module.byProps('track');
if (!trackingModule) return; // TODO Log it
MonkeyPatch('BD:TrackingProtection', trackingModule).instead('track', this.track);
}
disabled(e) {
for (const patch of Patcher.getPatchesByCaller('BD:TrackingProtection')) patch.unpatch();
}
}