1
0
mirror of https://github.com/gorhill/uBlock.git synced 2024-09-15 07:22:28 +02:00

cleaning up old stuff

This commit is contained in:
gorhill 2015-04-10 02:17:12 -04:00
parent 35ac2cc1a8
commit 67417c5cec
6 changed files with 28 additions and 82 deletions

View File

@ -11,7 +11,6 @@
<script src="js/vapi-common.js"></script>
<script src="js/vapi-background.js"></script>
<script src="js/background.js"></script>
<script src="js/xal.js"></script>
<script src="js/async.js"></script>
<script src="js/utils.js"></script>
<script src="js/uritools.js"></script>

View File

@ -84,7 +84,7 @@ AsyncJobManager.prototype.restartTimer = function() {
// TODO: Maybe use chrome.alarms() API when the next job is at more than
// one minute in the future... From reading about it, chrome.alarms() is
// smarter in that it will fire the event only when the browser is not
// too busy. (through XAL to abstract API specificities)
// too busy.
if ( when < this.timerWhen ) {
clearTimeout(this.timerId);
this.timerWhen = when;

View File

@ -1113,7 +1113,7 @@ var backupUserData = function(callback) {
µb.restoreBackupSettings.lastBackupFile = filename;
µb.restoreBackupSettings.lastBackupTime = Date.now();
µb.XAL.keyvalSetMany(µb.restoreBackupSettings);
µb.keyvalSetMany(µb.restoreBackupSettings);
getLocalData(callback);
};
@ -1135,20 +1135,20 @@ var restoreUserData = function(request) {
var onAllRemoved = function() {
// Be sure to adjust `countdown` if adding/removing anything below
µb.XAL.keyvalSetOne('version', userData.version);
µb.keyvalSetOne('version', userData.version);
µBlock.saveLocalSettings(true);
µb.XAL.keyvalSetMany(userData.userSettings, onCountdown);
µb.XAL.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
µb.XAL.keyvalSetOne('netWhitelist', userData.netWhitelist || '', onCountdown);
µb.keyvalSetMany(userData.userSettings, onCountdown);
µb.keyvalSetOne('remoteBlacklists', userData.filterLists, onCountdown);
µb.keyvalSetOne('netWhitelist', userData.netWhitelist || '', onCountdown);
// With versions 0.9.2.4-, dynamic rules were saved within the
// `userSettings` object. No longer the case.
var s = userData.dynamicFilteringString || userData.userSettings.dynamicFilteringString || '';
µb.XAL.keyvalSetOne('dynamicFilteringString', s, onCountdown);
µb.keyvalSetOne('dynamicFilteringString', s, onCountdown);
µb.XAL.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown);
µb.keyvalSetOne('hostnameSwitchesString', userData.hostnameSwitchesString || '', onCountdown);
µb.assets.put('assets/user/filters.txt', userData.userFilters, onCountdown);
µb.XAL.keyvalSetMany({
µb.keyvalSetMany({
lastRestoreFile: request.file || '',
lastRestoreTime: Date.now(),
lastBackupFile: '',
@ -1162,13 +1162,13 @@ var restoreUserData = function(request) {
// If we are going to restore all, might as well wipe out clean local
// storage
µb.XAL.keyvalRemoveAll(onAllRemoved);
vAPI.storage.clear(onAllRemoved);
};
/******************************************************************************/
var resetUserData = function() {
µb.XAL.keyvalRemoveAll();
vAPI.storage.clear();
// Keep global counts, people can become quite attached to numbers
µb.saveLocalSettings(true);

View File

@ -141,7 +141,7 @@ var onUserSettingsReady = function(fetched) {
// Remove obsolete setting
delete userSettings.logRequests;
µb.XAL.keyvalRemoveOne('logRequests');
vAPI.storage.remove('logRequests');
};
/******************************************************************************/

View File

@ -38,6 +38,20 @@
/******************************************************************************/
µBlock.keyvalSetOne = function(key, val, callback) {
var bin = {};
bin[key] = val;
vAPI.storage.set(bin, callback || this.noopFunc);
};
/******************************************************************************/
µBlock.keyvalSetMany = function(dict, callback) {
vAPI.storage.set(dict, callback || this.noopFunc);
};
/******************************************************************************/
µBlock.saveLocalSettings = function(force) {
if ( force ) {
this.localSettingsModifyTime = Date.now();
@ -70,13 +84,13 @@
/******************************************************************************/
µBlock.savePermanentFirewallRules = function() {
this.XAL.keyvalSetOne('dynamicFilteringString', this.permanentFirewall.toString());
this.keyvalSetOne('dynamicFilteringString', this.permanentFirewall.toString());
};
/******************************************************************************/
µBlock.saveHostnameSwitches = function() {
this.XAL.keyvalSetOne('hostnameSwitchesString', this.hnSwitches.toString());
this.keyvalSetOne('hostnameSwitchesString', this.hnSwitches.toString());
};
/******************************************************************************/

View File

@ -1,67 +0,0 @@
/*******************************************************************************
µBlock - a browser extension to block requests.
Copyright (C) 2014 Raymond Hill
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see {http://www.gnu.org/licenses/}.
Home: https://github.com/gorhill/uBlock
*/
/* global µBlock */
'use strict';
/******************************************************************************/
µBlock.XAL = (function(){
/******************************************************************************/
var exports = {};
var noopFunc = function(){};
/******************************************************************************/
exports.keyvalSetOne = function(key, val, callback) {
var bin = {};
bin[key] = val;
vAPI.storage.set(bin, callback || noopFunc);
};
/******************************************************************************/
exports.keyvalSetMany = function(dict, callback) {
vAPI.storage.set(dict, callback || noopFunc);
};
/******************************************************************************/
exports.keyvalRemoveOne = function(key, callback) {
vAPI.storage.remove(key, callback || noopFunc);
};
/******************************************************************************/
exports.keyvalRemoveAll = function(callback) {
vAPI.storage.clear(callback || noopFunc);
};
/******************************************************************************/
return exports;
/******************************************************************************/
})();