Tracking protection refactor to use new builtin base
This commit is contained in:
parent
aa0882c449
commit
937ab55456
|
@ -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();
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue