OLD | NEW |
(Empty) | |
| 1 let {FilterStorage} = require("filterStorage"); |
| 2 let {Subscription} = require("subscriptionClasses"); |
| 3 let {Filter} = require("filterClasses"); |
| 4 let {ElemHide} = require("elemHide"); |
| 5 let {defaultMatcher} = require("matcher"); |
| 6 let {CSSRules} = require("cssRules"); |
| 7 let {FilterNotifier} = require("filterNotifier"); |
| 8 let {Prefs} = require("prefs"); |
| 9 |
| 10 exports.prepareFilterComponents = function(keepListeners) |
| 11 { |
| 12 this._backup = { |
| 13 subscriptions: FilterStorage.subscriptions, |
| 14 storageKnown: FilterStorage.knownSubscriptions, |
| 15 subscriptionsKnown: Subscription.knownSubscriptions, |
| 16 filtersKnown: Filter.knownFilters, |
| 17 listeners: FilterNotifier._listeners, |
| 18 sourceFile: FilterStorage.sourceFile |
| 19 }; |
| 20 |
| 21 FilterStorage.subscriptions = []; |
| 22 FilterStorage.knownSubscriptions = Object.create(null); |
| 23 Subscription.knownSubscriptions = Object.create(null); |
| 24 Filter.knownFilters = Object.create(null); |
| 25 if (!keepListeners) |
| 26 FilterNotifier._listeners = {}; |
| 27 |
| 28 defaultMatcher.clear(); |
| 29 ElemHide.clear(); |
| 30 CSSRules.clear(); |
| 31 }; |
| 32 |
| 33 exports.restoreFilterComponents = function() |
| 34 { |
| 35 FilterStorage.subscriptions = this._backup.subscriptions; |
| 36 FilterStorage.knownSubscriptions = this._backup.storageKnown; |
| 37 Subscription.knownSubscriptions = this._backup.subscriptionsKnown; |
| 38 Filter.knownFilters = this._backup.filtersKnown; |
| 39 FilterNotifier._listeners = this._backup.listeners; |
| 40 Object.defineProperty(FilterStorage, "sourceFile", |
| 41 {value: this._backup.sourceFile, configurable: true}); |
| 42 |
| 43 FilterNotifier.triggerListeners("load"); |
| 44 }; |
| 45 |
| 46 exports.preparePrefs = function() |
| 47 { |
| 48 this._pbackup = Object.create(null); |
| 49 for (let pref in Prefs) |
| 50 { |
| 51 if (Prefs.__lookupSetter__(pref)) |
| 52 this._pbackup[pref] = Prefs[pref]; |
| 53 } |
| 54 Prefs.enabled = true; |
| 55 }; |
| 56 |
| 57 exports.restorePrefs = function() |
| 58 { |
| 59 for (let pref in this._pbackup) |
| 60 Prefs[pref] = this._pbackup[pref]; |
| 61 }; |
OLD | NEW |