1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2025-02-23 15:17:49 +01:00

Only formatting

This commit is contained in:
nobody 2020-08-13 08:07:04 +02:00
parent 3591496f9a
commit ed66f98580
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
6 changed files with 231 additions and 235 deletions

View File

@ -29,7 +29,6 @@ var helpers = {};
*/
helpers.insertI18nContentIntoDocument = function (document) {
let scriptDirection, i18nElements, translationComplete;
translationComplete = true;
@ -37,11 +36,10 @@ helpers.insertI18nContentIntoDocument = function (document) {
i18nElements = document.querySelectorAll('[data-i18n-content]');
i18nElements.forEach(function (i18nElement) {
let i18nMessageName = i18nElement.getAttribute('data-i18n-content');
if (chrome.i18n.getMessage(i18nMessageName) !== '') {
if (i18nElement.type === "button") {
if (i18nElement.type === 'button') {
i18nElement.value = chrome.i18n.getMessage(i18nMessageName);
} else {
i18nElement.innerText = chrome.i18n.getMessage(i18nMessageName);
@ -53,18 +51,15 @@ helpers.insertI18nContentIntoDocument = function (document) {
});
return translationComplete;
};
helpers.insertI18nTitlesIntoDocument = function (document) {
let scriptDirection, i18nElements;
scriptDirection = helpers.determineScriptDirection(navigator.language);
i18nElements = document.querySelectorAll('[data-i18n-title]');
i18nElements.forEach(function (i18nElement) {
let i18nMessageName = i18nElement.getAttribute('data-i18n-title');
i18nElement.setAttribute('title', chrome.i18n.getMessage(i18nMessageName));
@ -73,19 +68,42 @@ helpers.insertI18nTitlesIntoDocument = function (document) {
};
helpers.languageIsFullySupported = function (language) {
let languageSupported, supportedLanguages;
languageSupported = false;
supportedLanguages = [
'ar', 'bg', 'zh', 'cs', 'da', 'nl', 'en', 'eo', 'et', 'fi',
'fr', 'de', 'el', 'he', 'hu', 'is', 'id', 'it', 'ja', 'ko',
'nb', 'pl', 'pt', 'ro', 'ru', 'es', 'sv', 'tr'
'ar',
'bg',
'zh',
'cs',
'da',
'nl',
'en',
'eo',
'et',
'fi',
'fr',
'de',
'el',
'he',
'hu',
'is',
'id',
'it',
'ja',
'ko',
'nb',
'pl',
'pt',
'ro',
'ru',
'es',
'sv',
'tr',
];
for (let supportedLanguage of supportedLanguages) {
if (language.search(supportedLanguage) !== -1) {
languageSupported = true;
}
@ -95,7 +113,6 @@ helpers.languageIsFullySupported = function (language) {
};
helpers.normalizeDomain = function (domain) {
domain = domain.toLowerCase().trim();
if (domain.startsWith(Address.WWW_PREFIX)) {
@ -106,7 +123,6 @@ helpers.normalizeDomain = function (domain) {
};
helpers.extractDomainFromUrl = function (url, normalize) {
if (/^(?!(http[s]?|file):\/\/).*/.test(url)) {
return null;
}
@ -135,7 +151,6 @@ helpers.extractDomainFromUrl = function (url, normalize) {
};
helpers.extractFilenameFromPath = function (path) {
let pathSegments, filename;
pathSegments = path.split('/');
@ -145,16 +160,14 @@ helpers.extractFilenameFromPath = function (path) {
};
helpers.generateRandomHexString = function (length) {
let randomValues, randomHexString;
randomValues = crypto.getRandomValues(new Uint8Array(length));
randomHexString = '';
for (let value of randomValues) {
// eslint-disable-next-line no-bitwise
let hexValue = (0 ^ value & 15 >> 0 / 4).toString(16);
let hexValue = (0 ^ (value & (15 >> (0 / 4)))).toString(16);
randomHexString += hexValue;
}
@ -162,9 +175,7 @@ helpers.generateRandomHexString = function (length) {
};
helpers.determineCdnName = function (domainName) {
switch (domainName) {
case 'ajax.googleapis.com':
return 'Google Hosted Libraries';
case 'ajax.aspnetcdn.com':
@ -219,12 +230,10 @@ helpers.determineCdnName = function (domainName) {
};
helpers.determineResourceName = function (filename) {
if (filename in ListOfFiles) {
return ListOfFiles[filename];
}
return 'Unknown';
};
helpers.determineBundle = function (path = '') {
@ -238,7 +247,6 @@ helpers.determineBundle = function (path = '') {
};
helpers.determineScriptDirection = function (language) {
let rightToLeftLanguages, scriptDirection;
rightToLeftLanguages = ['ar', 'he'];
@ -253,14 +261,12 @@ helpers.determineScriptDirection = function (language) {
};
helpers.formatNumber = function (number) {
if (typeof number === 'number') {
return number.toLocaleString();
}
};
helpers.formatVersion = function (version) {
if (version.indexOf('beta') === -1) {
return version;
} else {
@ -534,7 +540,6 @@ helpers.setLastVersion = function (type, version) {
}
};
helpers.compareVersion = function (v1, v2) {
/**
* compareVersion( '1.5.7' , '1.5.8' ) is TRUE
@ -550,7 +555,7 @@ helpers.compareVersion = function (v1, v2) {
if (v1[i] > v2[i]) return true;
if (v1[i] < v2[i]) return false;
}
return v1.length == v2.length ? true: (v1.length < v2.length ? false : true);
return v1.length == v2.length ? true : v1.length < v2.length ? false : true;
};
const ListOfFiles = {

View File

@ -13,7 +13,7 @@
* You can obtain one at http://mozilla.org/MPL/2.0/.
*/
"use strict";
'use strict';
/**
* Stats
@ -29,17 +29,15 @@ stats.setStats = function (injection) {
framework = injection.path;
if (today in data) {
if (cdn in data[today]["cdns"]) {
data[today]["cdns"][cdn] = ++data[today]["cdns"][cdn];
if (cdn in data[today]['cdns']) {
data[today]['cdns'][cdn] = ++data[today]['cdns'][cdn];
} else {
Object.assign(data[today]["cdns"], { [cdn]: 1 });
Object.assign(data[today]['cdns'], { [cdn]: 1 });
}
if (framework in data[today]["frameworks"]) {
data[today]["frameworks"][framework] = ++data[today]["frameworks"][
framework
];
if (framework in data[today]['frameworks']) {
data[today]['frameworks'][framework] = ++data[today]['frameworks'][framework];
} else {
Object.assign(data[today]["frameworks"], { [framework]: 1 });
Object.assign(data[today]['frameworks'], { [framework]: 1 });
}
} else {
newEntry = { frameworks: { [framework]: 1 }, cdns: { [cdn]: 1 } };

View File

@ -24,28 +24,24 @@ var wrappers = {};
*/
wrappers.setBadgeBackgroundColor = function (details) {
if (chrome.browserAction.setBadgeBackgroundColor !== undefined) {
chrome.browserAction.setBadgeBackgroundColor(details);
}
};
wrappers.setBadgeText = function (details) {
if (chrome.browserAction.setBadgeText !== undefined) {
chrome.browserAction.setBadgeText(details);
}
};
wrappers.setBadgeTextColor = function (details) {
if (chrome.browserAction.setBadgeTextColor !== undefined) {
chrome.browserAction.setBadgeTextColor(details);
}
};
wrappers.setIcon = function (details, type) {
if (chrome.browserAction.setIcon) {
details.path = IconType[details.path][type];
} else {

View File

@ -21,7 +21,6 @@
var help = {};
help._onDocumentLoaded = function () {
let language = navigator.language;
help._languageSupported = helpers.languageIsFullySupported(language);

View File

@ -218,7 +218,7 @@ statistics._deleteStatistic = function () {
let text = chrome.i18n.getMessage('dialogConfirmDeleteStatistics');
if (confirm(text)) {
chrome.storage.local.set({
[Setting.INTERNAL_STATISTICS_DATA]: {},
[Setting.INTERNAL_STATISTICS_DATA]: {}
});
}
};

View File

@ -25,41 +25,41 @@ var updates = {};
* Private Methods
*/
updates._openRuleSet = function ({ target }) {
let urls = mappings;
let updateKey = target.getAttribute('data-option');
let textArea = document.getElementById("generated-rules");
let btnCopy = document.getElementById("button-copy-rule-set");
let textArea = document.getElementById('generated-rules');
let btnCopy = document.getElementById('button-copy-rule-set');
let content = "";
let content = '';
textArea.style.display = "block";
btnCopy.style.display = "block";
textArea.style.display = 'block';
btnCopy.style.display = 'block';
for (var domain in urls) {
if (updateKey === "uMatrix") {
content += "* " + domain + " script allow" + '\n';
content += "* " + domain + " css allow" + '\n';
} else if (updateKey === "uBlock") {
content += "* " + domain + " * noop" + '\n';
if (updateKey === 'uMatrix') {
content += '* ' + domain + ' script allow' + '\n';
content += '* ' + domain + ' css allow' + '\n';
} else if (updateKey === 'uBlock') {
content += '* ' + domain + ' * noop' + '\n';
}
}
textArea.value = content.replace(/\n+$/, "");
textArea.value = content.replace(/\n+$/, '');
};
updates._copyRuleSet = function () {
let textArea = document.getElementById("generated-rules");
navigator.clipboard.writeText(textArea.value).then(function() {
let textArea = document.getElementById('generated-rules');
navigator.clipboard.writeText(textArea.value).then(
function () {
textArea.select();
}, function() {
alert("Rule set cannot be copied!");
});
},
function () {
alert('Rule set cannot be copied!');
}
);
};
updates._openHistoryReleaseNotes = function () {
let container = document.getElementById('history-release-notes');
let toggle = document.getElementById('history-indicator');
@ -73,13 +73,12 @@ updates._openHistoryReleaseNotes = function() {
};
updates._onDocumentLoaded = function () {
document.getElementById('generate-ublock-rules').checked = false;
document.getElementById('generate-umatrix-rules').checked = false;
let updateElements = {
['ruleSets']: document.getElementsByName("rule-sets"),
['copyRuleSet']: document.getElementById("button-copy-rule-set")
['ruleSets']: document.getElementsByName('rule-sets'),
['copyRuleSet']: document.getElementById('button-copy-rule-set'),
};
for (let i = 0; i < updateElements.ruleSets.length; i++) {
@ -97,5 +96,4 @@ updates._onDocumentLoaded = function () {
}
};
document.addEventListener('DOMContentLoaded', updates._onDocumentLoaded);