Commit db92a46f authored by grtgarrett's avatar grtgarrett
Browse files

Adding ability to see which previous sites you have been protected against.

parent 54dee8ce
......@@ -57,7 +57,8 @@ const Setting = {
'SHOW_RELEASE_NOTES': 'showReleaseNotes',
'STRIP_METADATA': 'stripMetadata',
'WHITELISTED_DOMAINS': 'whitelistedDomains',
'XHR_TEST_DOMAIN': 'xhrTestDomain'
'XHR_TEST_DOMAIN': 'xhrTestDomain',
'STATS_ENABLED': 'statsEnabled'
};
const WebRequest = {
......
......@@ -33,8 +33,14 @@ stateManager.registerInjection = function (tabIdentifier, injection) {
registeredTab.injections[injectionIdentifier] = injection;
injectionCount = Object.keys(registeredTab.injections).length || 0;
stateManager.pastTenSites().then(function (value) {
console.log(value);
});
if (injectionCount > 0) {
chrome.browserAction.setTitle({
'tabId': tabIdentifier,
'title': `Decentraleyes (${injectionCount})`
......@@ -90,6 +96,29 @@ stateManager.removeDomainFromWhitelist = function (domain) {
});
};
stateManager.pastTenSites = async function () {
var pastTen = [];
pastTen.push(JSON.parse(localStorage.getItem('session')));
console.log(pastTen);
const [tab] = await browser.tabs.query({currentWindow: true, active:true});
if(pastTen.includes(tab.url)) {
return;
}
else {
pastTen.push(tab.url);
localStorage.setItem('session', JSON.stringify(pastTen));
}
console.log('here');
return pastTen.toString();
};
/**
* Private Methods
*/
......
/**
* State Manager
* Belongs to Decentraleyes.
*
* @author Garrett Tucker
* @since 2018-07-10
* @license MPL 2.0
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this file,
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
'use strict';
/**
* Statistics
*/
var statistics = {};
/**
* Public Methods
*/
statistics.pastTenSites = async function () {
var pastTen = [];
pastTen.push(JSON.parse(localStorage.getItem('session')));
console.log(pastTen);
const [tab] = await browser.tabs.query({currentWindow: true, active:true});
if(pastTen.includes(tab.url)) {
return;
}
else {
pastTen.push(tab.url);
localStorage.setItem('session', JSON.stringify(pastTen));
}
console.log('here');
return pastTen.toString();
};
\ No newline at end of file
......@@ -14,6 +14,7 @@
<script src="../../modules/internal/wrappers.js"></script>
<script src="../../modules/internal/helpers.js"></script>
<script src="../../core/statistics.js"></script>
<script src="../../core/constants.js"></script>
<script src="../../core/files.js"></script>
<script src="../../core/resources.js"></script>
......
......@@ -124,7 +124,8 @@ options._getOptionElements = function () {
[Setting.BLOCK_MISSING]: options._getOptionElement(Setting.BLOCK_MISSING),
[Setting.DISABLE_PREFETCH]: options._getOptionElement(Setting.DISABLE_PREFETCH),
[Setting.STRIP_METADATA]: options._getOptionElement(Setting.STRIP_METADATA),
[Setting.WHITELISTED_DOMAINS]: options._getOptionElement(Setting.WHITELISTED_DOMAINS)
[Setting.WHITELISTED_DOMAINS]: options._getOptionElement(Setting.WHITELISTED_DOMAINS),
[Setting.STATS_ENABLED]: options._getOptionElement(Setting.STATS_ENABLED)
};
return optionElements;
......
......@@ -57,7 +57,7 @@
<div class="description" data-i18n-content="amountInjectedDescription"></div>
<div class="subheading" data-i18n-content="pastSites"></div>
<div id="sites-counter" class="sublist">www.google.com</div>
<div id="sites" class="sublist">www.google.com</div>
</div>
......
......@@ -23,21 +23,6 @@ var popup = {};
* Private Methods
*/
popup._lastSites = async function () {
var pastTen = [];
pastTen.push(JSON.parse(localStorage.getItem('session')));
const [tab] = await browser.tabs.query({currentWindow: true, active:true});
if(pastTen.length < 10 && !pastTen[0].includes(tab.url)) {
pastTen.push(tab.url);
localStorage.setItem('session', JSON.stringify(pastTen));
}
console.log(pastTen);
return pastTen.toString();
};
popup._renderContents = function () {
......@@ -56,16 +41,15 @@ popup._renderNonContextualContents = function () {
let versionLabelElement, counterElement, testingUtilityLinkElement, optionsButtonElement, lastSitesElement;
lastSitesElement = document.getElementById('sites');
lastSitesElement.innerText = (JSON.parse(localStorage.getItem('session'))).toString();
versionLabelElement = document.getElementById('version-label');
counterElement = document.getElementById('injection-counter');
testingUtilityLinkElement = document.getElementById('testing-utility-link');
optionsButtonElement = document.getElementById('options-button');
lastSitesElement = document.getElementById('sites-counter');
popup._lastSites().then(function(value) {
lastSitesElement.innerText = value;
});
versionLabelElement.innerText = popup._version;
counterElement.innerText = helpers.formatNumber(popup._amountInjected);
......
Supports Markdown
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