Microsoft has acquired GitHub. Decentraleyes has left GitHub. Welcome to its new home!

To participate, please register, or sign in with an existing GitLab.com, Bitbucket, or GitHub account.

Past contributions on GitHub? Be sure to reclaim your Comments, Issues, and Pull Requests.

Refactor existing codebase

parent ad08b042
......@@ -10,6 +10,7 @@
],
"globals": {
"Address": true,
"Environment": true,
"fileGuard": true,
"files": true,
"Header": true,
......
......@@ -32,6 +32,11 @@ const Address = {
'WWW_PREFIX': 'www.'
};
const Environment = {
'STABLE': 'stable',
'STAGING': 'staging'
};
const Header = {
'COOKIE': 'Cookie',
'ORIGIN': 'Origin',
......
......@@ -20,7 +20,7 @@
var files = {
// Files [Stable]
'stable': {
[Environment.STABLE]: {
// AngularJS
'resources/angularjs/1.0.1/angular.min.jsm': true,
......@@ -265,7 +265,7 @@ var files = {
},
// Files [Staging]
'staging': {
[Environment.STAGING]: {
// AngularJS
'resources/angularjs/1.5.8/angular.min.jsm': true,
......
......@@ -42,9 +42,9 @@ main._initializeSettings = function () {
}
if (items.blockMissing === true || items.enforceStaging === true) {
stateManager.updateEnvironment('staging');
stateManager.updateEnvironment(Environment.STAGING);
} else {
stateManager.updateEnvironment('stable');
stateManager.updateEnvironment(Environment.STABLE);
}
if (items.disablePrefetch !== false) {
......
......@@ -65,9 +65,9 @@ requestSanitizer._stripMetadata = function (requestDetails) {
* Initializations
*/
chrome.storage.local.get({[Setting.STRIP_METADATA]: true}, function (options) {
chrome.storage.local.get({[Setting.STRIP_METADATA]: true}, function (items) {
if (options === null || options.stripMetadata !== false) {
if (items === null || items.stripMetadata !== false) {
requestSanitizer.enable();
}
});
......@@ -70,12 +70,12 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
stateManager.setEnvironment = function (environment) {
if (environment === 'stable') {
if (environment === Environment.STABLE) {
// Strike a balance between coverage and website stability.
files.active = files.stable;
} else if (environment === 'staging') {
} else if (environment === Environment.STAGING) {
// Improve coverage at the expense of website stability.
files.active = Object.assign({}, files.stable, files.staging);
......@@ -86,24 +86,24 @@ stateManager.updateEnvironment = function (preferredEnvironment) {
return new Promise((resolve) => {
if (preferredEnvironment === 'stable') {
if (preferredEnvironment === Environment.STABLE) {
let requiredItems = [Setting.BLOCK_MISSING, Setting.ENFORCE_STAGING];
chrome.storage.local.get(requiredItems, function (items) {
if (items.blockMissing === true || items.enforceStaging === true) {
stateManager.setEnvironment('staging');
stateManager.setEnvironment(Environment.STAGING);
} else {
stateManager.setEnvironment('stable');
stateManager.setEnvironment(Environment.STABLE);
}
resolve();
});
} else if (preferredEnvironment === 'staging') {
} else if (preferredEnvironment === Environment.STAGING) {
stateManager.setEnvironment('staging');
stateManager.setEnvironment(Environment.STAGING);
resolve();
}
});
......@@ -205,18 +205,18 @@ stateManager._handleStorageChanged = function (changes) {
if (Setting.BLOCK_MISSING in changes) {
if (changes.blockMissing.newValue === true) {
stateManager.updateEnvironment('staging');
stateManager.updateEnvironment(Environment.STAGING);
} else {
stateManager.updateEnvironment('stable');
stateManager.updateEnvironment(Environment.STABLE);
}
}
if (Setting.ENFORCE_STAGING in changes) {
if (changes.enforceStaging.newValue === true) {
stateManager.updateEnvironment('staging');
stateManager.updateEnvironment(Environment.STAGING);
} else {
stateManager.updateEnvironment('stable');
stateManager.updateEnvironment(Environment.STABLE);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment