Skip to content
Snippets Groups Projects

Compare revisions

Changes are shown as if the source revision was being merged into the target revision. Learn more about comparing revisions.

Source

Select target project
No results found

Target

Select target project
  • Synzvato/decentraleyes
  • gkrishnaks/decentraleyes
  • ExE-Boss/decentraleyes
  • whtsky/decentraleyes
  • grtgarrett/decentraleyes
  • An_dz/decentraleyes
  • Alaska/decentraleyes
  • finn/decentraleyes
  • klippy/decentraleyes
9 results
Show changes
Showing
with 239 additions and 307 deletions
/**
* State Manager
* Belongs to Decentraleyes.
*
* @author Thomas Rientjes
* @since 2017-03-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';
/**
* State Manager
*/
var stateManager = {};
/**
* Public Methods
*/
stateManager.registerInjection = function (tabIdentifier, injection) {
let injectionIdentifier, registeredTab, injectionCount;
injectionIdentifier = injection.source + injection.path + injection.version;
registeredTab = stateManager.tabs[tabIdentifier];
registeredTab.injections[injectionIdentifier] = injection;
injectionCount = Object.keys(registeredTab.injections).length || 0;
if (stateManager.showIconBadge === true) {
if (injectionCount > 0) {
chrome.browserAction.setBadgeText({
'tabId': tabIdentifier,
'text': injectionCount.toString()
});
} else {
chrome.browserAction.setBadgeText({
'tabId': tabIdentifier,
'text': ''
});
}
}
if (isNaN(interceptor.amountInjected)) {
chrome.storage.local.get(Setting.AMOUNT_INJECTED, function (items) {
interceptor.amountInjected = items.amountInjected;
chrome.storage.local.set({
'amountInjected': ++interceptor.amountInjected
});
});
} else {
chrome.storage.local.set({
'amountInjected': ++interceptor.amountInjected
});
}
};
stateManager.addDomainToWhitelist = function (domain) {
return new Promise((resolve) => {
let whitelistedDomains = requestAnalyzer.whitelistedDomains;
whitelistedDomains[domain] = true;
chrome.storage.local.set({whitelistedDomains}, resolve);
});
};
stateManager.deleteDomainFromWhitelist = function (domain) {
return new Promise((resolve) => {
let whitelistedDomains = requestAnalyzer.whitelistedDomains;
delete whitelistedDomains[domain];
chrome.storage.local.set({whitelistedDomains}, resolve);
});
};
/**
* Private Methods
*/
stateManager._createTab = function (tab) {
let tabIdentifier, requestFilters;
tabIdentifier = tab.id;
stateManager.tabs[tabIdentifier] = {
'injections': {}
};
requestFilters = {
'tabId': tabIdentifier,
'urls': stateManager.validHosts
};
chrome.webRequest.onBeforeRequest.addListener(function (requestDetails) {
return new Promise((resolve) => {
browser.tabs.get(tabIdentifier).then(function (tab) {
resolve(interceptor.handleRequest(requestDetails, tabIdentifier, tab));
});
});
}, requestFilters, [WebRequest.BLOCKING]);
};
stateManager._removeTab = function (tabIdentifier) {
delete stateManager.tabs[tabIdentifier];
};
stateManager._updateTab = function (details) {
let tabIdentifier, frameIdentifier;
tabIdentifier = details.tabId;
frameIdentifier = details.frameId;
if (tabIdentifier === -1 || frameIdentifier !== 0) {
return;
}
if (stateManager.showIconBadge === true) {
chrome.browserAction.setBadgeText({
'tabId': tabIdentifier,
'text': ''
});
}
if (stateManager.tabs[tabIdentifier]) {
stateManager.tabs[tabIdentifier].injections = {};
}
};
stateManager._stripMetadata = function (requestDetails) {
for (let i = 0; i < requestDetails.requestHeaders.length; ++i) {
if (requestDetails.requestHeaders[i].name === WebRequest.ORIGIN_HEADER) {
requestDetails.requestHeaders.splice(i--, 1);
} else if (requestDetails.requestHeaders[i].name === WebRequest.REFERER_HEADER) {
requestDetails.requestHeaders.splice(i--, 1);
}
}
return {
'requestHeaders': requestDetails.requestHeaders
};
};
stateManager._handleStorageChanged = function (changes) {
if ('showIconBadge' in changes) {
stateManager.showIconBadge = changes.showIconBadge.newValue;
if (changes.showIconBadge.newValue !== true) {
chrome.tabs.query({}, function (tabs) {
tabs.forEach(stateManager._removeIconBadgeFromTab);
});
}
}
if ('stripMetadata' in changes) {
let onBeforeSendHeaders;
onBeforeSendHeaders = chrome.webRequest.onBeforeSendHeaders;
onBeforeSendHeaders.removeListener(stateManager._stripMetadata, {
'urls': stateManager.validHosts
}, [WebRequest.BLOCKING, WebRequest.HEADERS]);
if (changes.stripMetadata.newValue !== false) {
onBeforeSendHeaders.addListener(stateManager._stripMetadata, {
'urls': stateManager.validHosts
}, [WebRequest.BLOCKING, WebRequest.HEADERS]);
}
}
};
stateManager._removeIconBadgeFromTab = function (tab) {
chrome.browserAction.setBadgeText({
'tabId': tab.id,
'text': ''
});
};
/**
* Initializations
*/
stateManager.requests = {};
stateManager.tabs = {};
stateManager.validHosts = [];
for (let mapping in mappings) {
let supportedHost = Address.ANY_PROTOCOL + mapping + Address.ANY_PATH;
stateManager.validHosts.push(supportedHost);
}
chrome.tabs.query({}, function (tabs) {
tabs.forEach(stateManager._createTab);
});
chrome.storage.local.get('showIconBadge', function (items) {
stateManager.showIconBadge = items.showIconBadge || true;
});
/**
* Event Handlers
*/
chrome.tabs.onCreated.addListener(stateManager._createTab);
chrome.tabs.onRemoved.addListener(stateManager._removeTab);
chrome.webNavigation.onCommitted.addListener(stateManager._updateTab, {
'url': [{'urlContains': ':'}]
});
chrome.webRequest.onErrorOccurred.addListener(function (requestDetails) {
if (stateManager.requests[requestDetails.requestId]) {
delete stateManager.requests[requestDetails.requestId];
}
}, {'urls': [Address.ANY]});
chrome.webRequest.onBeforeRedirect.addListener(function (requestDetails) {
let knownRequest = stateManager.requests[requestDetails.requestId];
if (knownRequest) {
stateManager.registerInjection(knownRequest.tabIdentifier, knownRequest.targetDetails);
delete stateManager.requests[requestDetails.requestId];
}
}, {'urls': [Address.ANY]});
chrome.storage.local.get({'stripMetadata': true}, function (options) {
if (options === null || options.stripMetadata !== false) {
chrome.webRequest.onBeforeSendHeaders.addListener(stateManager._stripMetadata, {
'urls': stateManager.validHosts
}, [WebRequest.BLOCKING, WebRequest.HEADERS]);
}
});
chrome.storage.onChanged.addListener(stateManager._handleStorageChanged);
"project_identifier": "decentraleyes"
"preserve_hierarchy": true
"files":
-
"source": "/_locales/en_US/messages.json"
"translation": "/_locales/%locale_with_underscore%/messages.json"
"languages_mapping":
"locale_with_underscore":
"ar": "ar"
"bg": "bg"
"da": "da"
"de": "de"
"el": "el"
"et": "et"
"eo": "eo"
"es-ES": "es"
"fi": "fi"
"fr": "fr"
"he": "he"
"hu": "hu"
"id": "id"
"is": "is"
"it": "it"
"ja": "ja"
"ko": "ko"
"nl": "nl"
"pl": "pl"
"ro": "ro"
"ru": "ru"
"sr": "sr"
"sv-SE": "sv"
"tr": "tr"
#
# API Configuration
#
"project_id" : "153483"
"base_url" : "https://api.crowdin.com"
#
# Directory Configuration
#
"preserve_hierarchy" : true
#
# File Configuration
#
files: [{
"source" : "/_locales/en_US/messages.json",
"translation" : "/_locales/%locale_with_underscore%/messages.json",
"export_only_approved" : true,
"languages_mapping" : {
"locale_with_underscore" : {
"ar" : "ar",
"bg" : "bg",
"bn" : "bn",
"ca" : "ca",
"cs" : "cs",
"da" : "da",
"de" : "de",
"el" : "el",
"eo" : "eo",
"es-ES" : "es",
"et" : "et",
"fi" : "fi",
"fr" : "fr",
"he" : "he",
"hr" : "hr",
"hu" : "hu",
"id" : "id",
"is" : "is",
"it" : "it",
"ja" : "ja",
"ko" : "ko",
"lb" : "lb",
"nb" : "nb",
"nl" : "nl",
"pa-IN" : "pa",
"pl" : "pl",
"ro" : "ro",
"ru" : "ru",
"si-LK" : "si",
"sq" : "sq",
"sr" : "sr",
"sv-SE" : "sv",
"tl" : "tl",
"tr" : "tr",
"uk" : "uk",
"vi" : "vi"
}
}
}]
import globals from 'globals';
import js from '@eslint/js';
import noUnsanitized from 'eslint-plugin-no-unsanitized';
export const baseConfiguration = {
'languageOptions': {
'ecmaVersion': 2023
},
'rules': {
'array-bracket-newline': 'error',
'array-bracket-spacing': 'error',
'arrow-parens': 'error',
'arrow-spacing': 'error',
'block-spacing': 'error',
'brace-style': 'error',
'camelcase': 'error',
'comma-dangle': ['error', 'never'],
'comma-spacing': 'error',
'comma-style': 'error',
'computed-property-spacing': 'error',
'consistent-this': 'error',
'curly': 'error',
'eol-last': 'error',
'eqeqeq': 'error',
'func-call-spacing': 'error',
'function-paren-newline': 'error',
'generator-star-spacing': 'error',
'indent': ['error', 4],
'key-spacing': 'error',
'keyword-spacing': 'error',
'linebreak-style': ['error', 'unix'],
'new-cap': 'error',
'new-parens': 'error',
'no-array-constructor': 'error',
'no-bitwise': 'error',
'no-confusing-arrow': 'error',
'no-continue': 'error',
'no-duplicate-imports': 'error',
'no-eval': 'error',
'no-extend-native': 'error',
'no-implicit-coercion': 'error',
'no-implied-eval': 'error',
'no-invalid-this': 'error',
'no-iterator': 'error',
'no-label-var': 'error',
'no-labels': 'error',
'no-lone-blocks': 'error',
'no-loop-func': 'error',
'no-multi-spaces': 'error',
'no-multi-str': 'error',
'no-multiple-empty-lines': [
'error', {
'max': 1,
'maxEOF': 1,
'maxBOF': 0
}
],
'max-len': [
'error', {
'code': 120
}
],
'no-negated-condition': 'error',
'no-new': 'error',
'no-new-func': 'error',
'no-new-object': 'error',
'no-new-wrappers': 'error',
'no-octal-escape': 'error',
'no-proto': 'error',
'no-return-assign': 'error',
'no-return-await': 'error',
'no-script-url': 'error',
'no-self-compare': 'error',
'no-sequences': 'error',
'no-shadow-restricted-names': 'error',
'no-tabs': 'error',
'no-ternary': 'error',
'no-throw-literal': 'error',
'no-trailing-spaces': 'error',
'no-undef-init': 'error',
'no-unmodified-loop-condition': 'error',
'no-unused-expressions': 'error',
'no-use-before-define': 'error',
'no-useless-call': 'error',
'no-useless-concat': 'error',
'no-useless-constructor': 'error',
'no-useless-rename': 'error',
'no-useless-return': 'error',
'no-void': 'error',
'no-warning-comments': 'warn',
'no-whitespace-before-property': 'error',
'no-with': 'error',
'object-curly-spacing': 'error',
'object-shorthand': ['error', 'consistent-as-needed'],
'operator-assignment': 'error',
'operator-linebreak': 'error',
'prefer-numeric-literals': 'error',
'prefer-promise-reject-errors': 'error',
'quote-props': 'error',
'prefer-rest-params': 'error',
'prefer-spread': 'error',
'prefer-template': 'error',
'quotes': ['error', 'single'],
'rest-spread-spacing': 'error',
'require-await': 'error',
'semi': 'error',
'semi-spacing': 'error',
'semi-style': 'error',
'space-before-blocks': 'error',
'space-before-function-paren': 'error',
'space-in-parens': 'error',
'space-infix-ops': 'error',
'space-unary-ops': [
2, {
'words': false,
'nonwords': false,
'overrides': {
'!': true
}
}
],
'spaced-comment': 'error',
'strict': ['error', 'global'],
'switch-colon-spacing': 'error',
'symbol-description': 'error',
'template-curly-spacing': 'error',
'template-tag-spacing': 'error',
'unicode-bom': 'error',
'vars-on-top': 'error',
'wrap-regex': 'error',
'yield-star-spacing': 'error',
'yoda': 'error'
}
};
export default [
js.configs.recommended,
baseConfiguration,
{
'ignores': [
'_locales',
'images',
'pages/shared/resources',
'resources'
]
},
{
'plugins': {
'no-unsanitized': noUnsanitized
},
'languageOptions': {
'globals': {
...globals.browser,
...globals.webextensions
}
},
'rules': {
'no-unsanitized/method': 'error',
'no-unsanitized/property': 'error'
}
}
];
File moved
images/icons/action/disabled/16.png

540 B

images/icons/action/disabled/18.png

596 B

images/icons/action/disabled/19.png

629 B

images/icons/action/disabled/32.png

1 KiB

images/icons/action/disabled/36.png

1.12 KiB

images/icons/action/disabled/38.png

1.16 KiB

images/icons/action/disabled/64.png

1.88 KiB

File moved
images/icons/extension/16.png

608 B