mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-06-05 21:49:31 +02:00
Just code style (JS)
This commit is contained in:
@@ -14,12 +14,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Help
|
||||
*/
|
||||
|
||||
var help = {};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
|
||||
help._onDocumentLoaded = function () {
|
||||
let language = navigator.language;
|
||||
|
||||
@@ -29,4 +35,9 @@ help._onDocumentLoaded = function () {
|
||||
helpers.insertI18nContentIntoDocument(document);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
*/
|
||||
|
||||
document.addEventListener('DOMContentLoaded', help._onDocumentLoaded);
|
||||
|
||||
@@ -18,12 +18,14 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Options
|
||||
*/
|
||||
|
||||
var options = {};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
@@ -55,9 +57,10 @@ options._renderContents = function () {
|
||||
};
|
||||
|
||||
options._renderOptionsPanel = function () {
|
||||
let allowlistedDomains, domainAllowlist, elements, htmlFilterDomains, domainHtmlFilter, googleFontsDomains, domainAllowedGoogleFonts, url, bgColor, txtColor;
|
||||
let allowlistedDomains, domainAllowlist, elements, htmlFilterDomains, domainHtmlFilter,
|
||||
googleFontsDomains, domainAllowedGoogleFonts, url, bgColor, txtColor;
|
||||
|
||||
Object.assign(options._optionValues, { [Setting.INTERNAL_STATISTICS]: options._internalStatistics });
|
||||
Object.assign(options._optionValues, {[Setting.INTERNAL_STATISTICS]: options._internalStatistics});
|
||||
|
||||
allowlistedDomains = options._optionValues.allowlistedDomains;
|
||||
domainAllowlist = options._serializeAllowlistedDomains(allowlistedDomains);
|
||||
@@ -69,9 +72,9 @@ options._renderOptionsPanel = function () {
|
||||
domainAllowedGoogleFonts = options._serializeAllowlistedDomains(googleFontsDomains);
|
||||
|
||||
elements = options._optionElements;
|
||||
Object.assign(elements, { [Setting.INTERNAL_STATISTICS]: document.getElementById('checkbox-internal-statistics') });
|
||||
Object.assign(elements, {[Setting.INTERNAL_STATISTICS]: document.getElementById('checkbox-internal-statistics')});
|
||||
|
||||
Object.assign(elements, { [Setting.SELECTED_ICON]: document.getElementsByName('selected-icon') });
|
||||
Object.assign(elements, {[Setting.SELECTED_ICON]: document.getElementsByName('selected-icon')});
|
||||
|
||||
elements.showIconBadge.checked = options._optionValues.showIconBadge;
|
||||
elements.blockMissing.checked = options._optionValues.blockMissing;
|
||||
@@ -111,14 +114,16 @@ options._renderOptionsPanel = function () {
|
||||
}
|
||||
|
||||
if (options._platformSupportIcons) {
|
||||
if (options._optionValues.selectedIcon === 'Default') {
|
||||
let selectedIcon = options._optionValues.selectedIcon;
|
||||
|
||||
if (selectedIcon === 'Default') {
|
||||
document.getElementById('icon-default').checked = true;
|
||||
} else if (options._optionValues.selectedIcon === 'Grey') {
|
||||
} else if (selectedIcon === 'Grey') {
|
||||
document.getElementById('icon-grey').checked = true;
|
||||
} else if (options._optionValues.selectedIcon === 'Light') {
|
||||
} else if (selectedIcon === 'Light') {
|
||||
document.getElementById('icon-light').checked = true;
|
||||
}
|
||||
url = chrome.runtime.getURL('icons/action/' + options._optionValues.selectedIcon.toLowerCase() + '/icon38-default.png');
|
||||
url = chrome.runtime.getURL(`icons/action/${selectedIcon.toLowerCase()}/icon38-default.png`);
|
||||
document.getElementById('icon-badge-preview').src = url;
|
||||
|
||||
bgColor = options._optionValues.badgeColor || '#4A826C';
|
||||
@@ -133,15 +138,31 @@ options._renderOptionsPanel = function () {
|
||||
document.getElementById('badged-text-color').value = txtColor;
|
||||
}
|
||||
|
||||
document.getElementById('last-mapping-update').textContent += ' ' + mappings.lastMappingUpdate;
|
||||
document.getElementById('negate-html-filter-list-warning').addEventListener('click', function () { options._onLinkClick(Links.CODEBERG_HTML_FILTER); });
|
||||
document.getElementById('link-welcome-page').addEventListener('click', function () { options._onLinkClick(Links.WELCOME); });
|
||||
document.getElementById('link-changelog').addEventListener('click', function () { options._onLinkClick(Links.CHANGELOG); });
|
||||
document.getElementById('link-donate').addEventListener('click', function () { options._onLinkClick(Links.DONATE); });
|
||||
document.getElementById('link-faq').addEventListener('click', function () { options._onLinkClick(Links.FAQ);});
|
||||
document.getElementById('ruleset-help').addEventListener('click', function () { options._onLinkClick(Links.CODEBERG_RULESET); });
|
||||
document.getElementById('sync-help').addEventListener('click', function () { options._onLinkClick(Links.FAQ + '#sync'); });
|
||||
document.getElementById('link-statistic').addEventListener('click', function () { options._onLinkClick(Links.STATISTICS); });
|
||||
document.getElementById('last-mapping-update').textContent += ` ${mappings.lastMappingUpdate}`;
|
||||
document.getElementById('negate-html-filter-list-warning').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.CODEBERG_HTML_FILTER);
|
||||
});
|
||||
document.getElementById('link-welcome-page').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.WELCOME);
|
||||
});
|
||||
document.getElementById('link-changelog').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.CHANGELOG);
|
||||
});
|
||||
document.getElementById('link-donate').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.DONATE);
|
||||
});
|
||||
document.getElementById('link-faq').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.FAQ);
|
||||
});
|
||||
document.getElementById('ruleset-help').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.CODEBERG_RULESET);
|
||||
});
|
||||
document.getElementById('sync-help').addEventListener('click', function () {
|
||||
options._onLinkClick(`${Links.FAQ}#sync`);
|
||||
});
|
||||
document.getElementById('link-statistic').addEventListener('click', function () {
|
||||
options._onLinkClick(Links.STATISTICS);
|
||||
});
|
||||
|
||||
document.getElementById('btn-general-tab').addEventListener('click', options._changeTab);
|
||||
document.getElementById('btn-advanced-tab').addEventListener('click', options._changeTab);
|
||||
@@ -265,13 +286,15 @@ options._configureLinkPrefetching = function (value) {
|
||||
chrome.privacy.network.networkPredictionEnabled.clear({});
|
||||
} else {
|
||||
chrome.privacy.network.networkPredictionEnabled.set({
|
||||
value: false,
|
||||
'value': false,
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
options._serializeAllowlistedDomains = function (allowlistedDomains) {
|
||||
if (allowlistedDomains === undefined) return '';
|
||||
if (allowlistedDomains === undefined) {
|
||||
return '';
|
||||
}
|
||||
|
||||
let domainAllowlist, allowlistedDomainKeys;
|
||||
|
||||
@@ -334,7 +357,7 @@ options._renderInfoPanel = function () {
|
||||
btnFrameworks.value += Object.keys(options._listOfFrameworks).length - unsupportedFrameworks;
|
||||
};
|
||||
|
||||
options._btnCreateList = function ({ target }) {
|
||||
options._btnCreateList = function ({target}) {
|
||||
if (target.id === 'cdn') {
|
||||
document.getElementById('cdn').classList.add('btns-active');
|
||||
document.getElementById('framework').classList.remove('btns-active');
|
||||
@@ -361,53 +384,56 @@ options._createList = function (type) {
|
||||
|
||||
list.forEach((elem) => {
|
||||
if (!(BrowserType.CHROMIUM && (elem === 'fontawesome' || elem === 'google-material-design-icons'))) {
|
||||
textArea.value += elem + '\n';
|
||||
textArea.value += `${elem}\n`;
|
||||
}
|
||||
});
|
||||
};
|
||||
|
||||
options._colorPicker = function () {
|
||||
/* eslint-disable no-undef, no-invalid-this */
|
||||
const badgeBackgroundColor = new CP(document.getElementById('badged-background-color'));
|
||||
badgeBackgroundColor.on('change', function(r, g, b) {
|
||||
badgeBackgroundColor.on('change', function (r, g, b) {
|
||||
this.source.value = this.color(r, g, b);
|
||||
});
|
||||
badgeBackgroundColor.on('drag', function(r, g, b) {
|
||||
badgeBackgroundColor.on('drag', function (r, g, b) {
|
||||
options._backgroundColor = this.color(r, g, b);
|
||||
this.source.value = options._backgroundColor
|
||||
wrappers.setBadgeBackgroundColor({color: options._backgroundColor});
|
||||
this.source.value = options._backgroundColor;
|
||||
wrappers.setBadgeBackgroundColor({'color': options._backgroundColor});
|
||||
document.getElementById('counter-preview-badge').style.backgroundColor = options._backgroundColor;
|
||||
document.getElementById('pre-badged-background-color').style.backgroundColor = options._backgroundColor;
|
||||
});
|
||||
|
||||
const badgeTextColor = new CP(document.getElementById('badged-text-color'));
|
||||
badgeTextColor.on('change', function(r, g, b) {
|
||||
badgeTextColor.on('change', function (r, g, b) {
|
||||
this.source.value = this.color(r, g, b);
|
||||
});
|
||||
badgeTextColor.on('drag', function(r, g, b) {
|
||||
badgeTextColor.on('drag', function (r, g, b) {
|
||||
options._textColor = this.color(r, g, b);
|
||||
this.source.value = options._textColor
|
||||
wrappers.setBadgeTextColor({color: options._textColor});
|
||||
this.source.value = options._textColor;
|
||||
wrappers.setBadgeTextColor({'color': options._textColor});
|
||||
document.getElementById('counter-preview-badge').style.color = options._textColor;
|
||||
document.getElementById('pre-badged-text-color').style.backgroundColor = options._textColor;
|
||||
});
|
||||
/* eslint-enable no-undef, no-invalid-this */
|
||||
};
|
||||
|
||||
options._setDefaultColor = function ({ target }) {
|
||||
options._setDefaultColor = function ({target}) {
|
||||
if (target.id === 'restore-text-color') {
|
||||
options._textColor = '#FFFFFF';
|
||||
wrappers.setBadgeTextColor({color: options._textColor});
|
||||
wrappers.setBadgeTextColor({'color': options._textColor});
|
||||
document.getElementById('counter-preview-badge').style.color = options._textColor;
|
||||
document.getElementById('pre-badged-text-color').style.backgroundColor = options._textColor;
|
||||
document.getElementById('badged-text-color').value = options._textColor;
|
||||
} else if (target.id === 'restore-background-color') {
|
||||
options._backgroundColor = '#4A826C';
|
||||
wrappers.setBadgeBackgroundColor({color: options._backgroundColor});
|
||||
wrappers.setBadgeBackgroundColor({'color': options._backgroundColor});
|
||||
document.getElementById('counter-preview-badge').style.backgroundColor = options._backgroundColor;
|
||||
document.getElementById('pre-badged-background-color').style.backgroundColor = options._backgroundColor;
|
||||
document.getElementById('badged-background-color').value = options._backgroundColor;
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Event Handlers
|
||||
*/
|
||||
@@ -423,7 +449,7 @@ options._onDocumentLoaded = function () {
|
||||
options._renderContents();
|
||||
};
|
||||
|
||||
options._onOptionChanged = function ({ target }) {
|
||||
options._onOptionChanged = function ({target}) {
|
||||
let optionKey, optionType, optionValue;
|
||||
|
||||
optionKey = target.getAttribute('data-option');
|
||||
@@ -451,7 +477,10 @@ options._onOptionChanged = function ({ target }) {
|
||||
options._configureLinkPrefetching(optionValue);
|
||||
}
|
||||
|
||||
if (optionKey === Setting.ALLOWLISTED_DOMAINS || optionKey === Setting.DOMAINS_MANIPULATE_DOM || optionKey === Setting.ALLOWED_DOMAINS_GOOGLE_FONTS) {
|
||||
if (optionKey === Setting.ALLOWLISTED_DOMAINS ||
|
||||
optionKey === Setting.DOMAINS_MANIPULATE_DOM ||
|
||||
optionKey === Setting.ALLOWED_DOMAINS_GOOGLE_FONTS) {
|
||||
|
||||
optionValue = options._parseDomainAllowlist(optionValue);
|
||||
}
|
||||
|
||||
@@ -474,8 +503,8 @@ options._onOptionChanged = function ({ target }) {
|
||||
}
|
||||
|
||||
if (optionKey === Setting.SELECTED_ICON) {
|
||||
wrappers.setIcon({ path: optionValue }, 'Enabled');
|
||||
let url = chrome.runtime.getURL('icons/action/' + optionValue.toLowerCase() + '/icon38-default.png');
|
||||
wrappers.setIcon({'path': optionValue}, 'Enabled');
|
||||
let url = chrome.runtime.getURL(`icons/action/${optionValue.toLowerCase()}/icon38-default.png`);
|
||||
document.getElementById('icon-badge-preview').src = url;
|
||||
}
|
||||
storageManager.type.set({
|
||||
@@ -483,7 +512,7 @@ options._onOptionChanged = function ({ target }) {
|
||||
});
|
||||
};
|
||||
|
||||
options._onStorageOptionChanged = function ({ target }) {
|
||||
options._onStorageOptionChanged = function ({target}) {
|
||||
chrome.storage.local.set({
|
||||
[Setting.STORAGE_TYPE]: target.value,
|
||||
});
|
||||
@@ -496,12 +525,12 @@ options._onStorageOptionChanged = function ({ target }) {
|
||||
|
||||
options._onLinkClick = function (url) {
|
||||
chrome.tabs.create({
|
||||
url: url,
|
||||
active: true
|
||||
'url': url,
|
||||
'active': true
|
||||
});
|
||||
};
|
||||
|
||||
options._changeTab = function ({ target }) {
|
||||
options._changeTab = function ({target}) {
|
||||
let tabContent, tabButton, optionKey;
|
||||
|
||||
optionKey = target.getAttribute('data-option');
|
||||
@@ -519,17 +548,17 @@ options._changeTab = function ({ target }) {
|
||||
}
|
||||
};
|
||||
|
||||
options._onChangedHexColor = function ({ target }) {
|
||||
options._onChangedHexColor = function ({target}) {
|
||||
if (/#([a-f0-9]{3}){1,2}\b/i.test(target.value)) {
|
||||
target.classList.remove('color-error');
|
||||
if (target.id === 'badged-text-color') {
|
||||
options._textColor = target.value;
|
||||
wrappers.setBadgeTextColor({color: options._textColor});
|
||||
wrappers.setBadgeTextColor({'color': options._textColor});
|
||||
document.getElementById('counter-preview-badge').style.color = options._textColor;
|
||||
document.getElementById('pre-badged-text-color').style.backgroundColor = options._textColor;
|
||||
} else {
|
||||
options._backgroundColor = target.value;
|
||||
wrappers.setBadgeBackgroundColor({color: options._backgroundColor});
|
||||
wrappers.setBadgeBackgroundColor({'color': options._backgroundColor});
|
||||
document.getElementById('counter-preview-badge').style.backgroundColor = options._backgroundColor;
|
||||
document.getElementById('pre-badged-background-color').style.backgroundColor = options._backgroundColor;
|
||||
}
|
||||
@@ -556,6 +585,7 @@ options._updatesDomainLists = function (changes) {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
*/
|
||||
|
||||
@@ -18,14 +18,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Popup
|
||||
*/
|
||||
|
||||
var popup = {};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
|
||||
popup._renderContents = function () {
|
||||
helpers.insertI18nContentIntoDocument(document);
|
||||
helpers.insertI18nTitlesIntoDocument(document);
|
||||
@@ -49,7 +53,8 @@ popup._renderContents = function () {
|
||||
};
|
||||
|
||||
popup._renderNonContextualContents = function () {
|
||||
let versionLabelElement, nameLabelElement, counterElement, testingUtilityLinkElement, optionsButtonElement, donationButtonElement, infoButtonLabel;
|
||||
let versionLabelElement, nameLabelElement, counterElement, testingUtilityLinkElement,
|
||||
optionsButtonElement, donationButtonElement, infoButtonLabel;
|
||||
|
||||
versionLabelElement = document.getElementById('version-label');
|
||||
nameLabelElement = document.getElementById('name-label');
|
||||
@@ -86,7 +91,8 @@ popup._renderContextualContents = function () {
|
||||
};
|
||||
|
||||
popup._renderDomainAllowlistPanel = function () {
|
||||
let websiteContextElement, protectionToggleElement, domainIndicatorElement, manipulateDOMToggleElement, manipulateDOMToggleStyle;
|
||||
let websiteContextElement, protectionToggleElement, domainIndicatorElement,
|
||||
manipulateDOMToggleElement, manipulateDOMToggleStyle;
|
||||
|
||||
websiteContextElement = document.getElementById('website-context');
|
||||
protectionToggleElement = document.getElementById('protection-toggle-switch');
|
||||
@@ -139,8 +145,8 @@ popup._renderInjectionPanel = function (groupedInjections) {
|
||||
|
||||
popup._enableProtection = function () {
|
||||
let message = {
|
||||
topic: 'allowlist:remove-domain',
|
||||
value: popup._domain,
|
||||
'topic': 'allowlist:remove-domain',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function () {
|
||||
@@ -150,8 +156,8 @@ popup._enableProtection = function () {
|
||||
|
||||
popup._disableProtection = function () {
|
||||
let message = {
|
||||
topic: 'allowlist:add-domain',
|
||||
value: popup._domain,
|
||||
'topic': 'allowlist:add-domain',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function () {
|
||||
@@ -161,8 +167,8 @@ popup._disableProtection = function () {
|
||||
|
||||
popup._enableManipulateDOM = function () {
|
||||
let message = {
|
||||
topic: 'manipulateDOM:add-domain',
|
||||
value: popup._domain,
|
||||
'topic': 'manipulateDOM:add-domain',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function () {
|
||||
@@ -172,8 +178,8 @@ popup._enableManipulateDOM = function () {
|
||||
|
||||
popup._disableManipulateDOM = function () {
|
||||
let message = {
|
||||
topic: 'manipulateDOM:remove-domain',
|
||||
value: popup._domain,
|
||||
'topic': 'manipulateDOM:remove-domain',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function () {
|
||||
@@ -184,8 +190,8 @@ popup._disableManipulateDOM = function () {
|
||||
popup._determineDomainAllowlistStatus = function () {
|
||||
return new Promise((resolve) => {
|
||||
let message = {
|
||||
topic: 'domain:fetch-is-allowlisted',
|
||||
value: popup._domain,
|
||||
'topic': 'domain:fetch-is-allowlisted',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
if (popup._domain === null) {
|
||||
@@ -202,8 +208,8 @@ popup._determineDomainAllowlistStatus = function () {
|
||||
popup._determineStatusManipulateDOM = function () {
|
||||
return new Promise((resolve) => {
|
||||
let message = {
|
||||
topic: 'domain:fetch-is-manipulateDOM',
|
||||
value: popup._domain,
|
||||
'topic': 'domain:fetch-is-manipulateDOM',
|
||||
'value': popup._domain,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function (response) {
|
||||
@@ -216,8 +222,8 @@ popup._determineStatusManipulateDOM = function () {
|
||||
popup._determineResourceInjections = function () {
|
||||
return new Promise((resolve) => {
|
||||
let message = {
|
||||
topic: 'tab:fetch-injections',
|
||||
value: popup._targetTab.id,
|
||||
'topic': 'tab:fetch-injections',
|
||||
'value': popup._targetTab.id,
|
||||
};
|
||||
|
||||
chrome.runtime.sendMessage(message, function (response) {
|
||||
@@ -231,7 +237,7 @@ popup._determineResourceInjections = function () {
|
||||
|
||||
popup._determineTargetTab = function () {
|
||||
return new Promise((resolve) => {
|
||||
chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
|
||||
chrome.tabs.query({'active': true, 'currentWindow': true}, function (tabs) {
|
||||
popup._targetTab = tabs[0];
|
||||
popup._domain = helpers.extractDomainFromUrl(tabs[0].url, true);
|
||||
|
||||
@@ -271,7 +277,7 @@ popup._groupResourceInjections = function (injections) {
|
||||
let groupedInjections = {};
|
||||
|
||||
for (let index in injections) {
|
||||
let { source } = injections[index];
|
||||
let {source} = injections[index];
|
||||
|
||||
groupedInjections[source] = groupedInjections[source] || [];
|
||||
groupedInjections[source].push(injections[index]);
|
||||
@@ -320,14 +326,14 @@ popup._createInjectionGroupHeaderElement = function (source, cdn) {
|
||||
};
|
||||
|
||||
popup._createInjectionGroupElement = function (source, cdn) {
|
||||
let injectionGroupElement;
|
||||
let injectionGroupElement, bundle, filtered;
|
||||
|
||||
// Filter duplicates
|
||||
let bundle = [];
|
||||
bundle = [];
|
||||
for (let injection of cdn) {
|
||||
bundle.push(injection);
|
||||
}
|
||||
let filtered = popup._filterDuplicates(bundle, 'bundle');
|
||||
filtered = popup._filterDuplicates(bundle, 'bundle');
|
||||
|
||||
injectionGroupElement = document.createElement('ul');
|
||||
injectionGroupElement.setAttribute('class', 'sublist');
|
||||
@@ -352,7 +358,7 @@ popup._createInjectionElement = function (injection) {
|
||||
if (injection.bundle === '') {
|
||||
name = targets.determineResourceName(filename);
|
||||
} else {
|
||||
name = injection.bundle + ' (Bundle)';
|
||||
name = `${injection.bundle} (Bundle)`;
|
||||
}
|
||||
|
||||
nameTextNode = document.createTextNode(`- ${name}`);
|
||||
@@ -393,7 +399,9 @@ popup._filterDuplicates = function (array, key) {
|
||||
*/
|
||||
let filtered = array
|
||||
.map((e) => e[key])
|
||||
.map((value, index, newArray) => (value != '' ? newArray.indexOf(value) === index && index : index))
|
||||
.map(function (value, index, newArray) {
|
||||
return value !== '' ? newArray.indexOf(value) === index && index : index;
|
||||
})
|
||||
.filter((e) => array[e])
|
||||
.map((e) => array[e]);
|
||||
|
||||
@@ -414,10 +422,10 @@ popup._renderLocaleNotice = function () {
|
||||
};
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Event Handlers
|
||||
*/
|
||||
|
||||
popup._onDocumentLoaded = function () {
|
||||
let manifest, language;
|
||||
|
||||
@@ -436,8 +444,8 @@ popup._onDocumentLoaded = function () {
|
||||
popup._onTestingUtilityLinkClicked = function (event) {
|
||||
if (event.button === 0 || event.button === 1) {
|
||||
chrome.tabs.create({
|
||||
url: Links.LOCALCDN_TEST_WEBSITE + popup._targetTab.url,
|
||||
active: event.button === 0,
|
||||
'url': Links.LOCALCDN_TEST_WEBSITE + popup._targetTab.url,
|
||||
'active': event.button === 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -454,8 +462,8 @@ popup._onOptionsButtonClicked = function () {
|
||||
popup._onDonationButtonClicked = function () {
|
||||
if (event.button === 0 || event.button === 1) {
|
||||
chrome.tabs.create({
|
||||
url: Links.DONATE,
|
||||
active: event.button === 0,
|
||||
'url': Links.DONATE,
|
||||
'active': event.button === 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -467,7 +475,7 @@ popup._onDonationButtonClicked = function () {
|
||||
popup._onToggled = function () {
|
||||
let bypassCache = typeof browser === 'undefined';
|
||||
|
||||
chrome.tabs.reload(popup._targetTab.id, { bypassCache });
|
||||
chrome.tabs.reload(popup._targetTab.id, {bypassCache});
|
||||
setTimeout(function () {
|
||||
popup._close();
|
||||
}, 200);
|
||||
@@ -488,8 +496,8 @@ popup._close = function () {
|
||||
popup._onInfoButtonClicked = function () {
|
||||
if (event.button === 0 || event.button === 1) {
|
||||
chrome.tabs.create({
|
||||
url: Links.FAQ_HTML_FILTER,
|
||||
active: event.button === 0,
|
||||
'url': Links.FAQ_HTML_FILTER,
|
||||
'active': event.button === 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -501,8 +509,8 @@ popup._onInfoButtonClicked = function () {
|
||||
popup._onIncompleteTranslation = function () {
|
||||
if (event.button === 0 || event.button === 1) {
|
||||
chrome.tabs.create({
|
||||
url: Links.Weblate,
|
||||
active: event.button === 0,
|
||||
'url': Links.Weblate,
|
||||
'active': event.button === 0,
|
||||
});
|
||||
}
|
||||
|
||||
@@ -514,8 +522,8 @@ popup._onIncompleteTranslation = function () {
|
||||
popup._onStatisticsButtonClicked = function () {
|
||||
if (event.button === 0 || event.button === 1) {
|
||||
chrome.tabs.create({
|
||||
url: Links.STATISTICS,
|
||||
active: event.button === 0,
|
||||
'url': Links.STATISTICS,
|
||||
'active': event.button === 0,
|
||||
});
|
||||
}
|
||||
if (event.button === 0) {
|
||||
@@ -523,9 +531,11 @@ popup._onStatisticsButtonClicked = function () {
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
*/
|
||||
|
||||
popup.negateHtmlFilterList = false;
|
||||
popup._statisticsStatus = false;
|
||||
|
||||
|
||||
@@ -14,14 +14,18 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Statistic
|
||||
*/
|
||||
|
||||
var statistics = {};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
|
||||
statistics._onDocumentLoaded = function () {
|
||||
helpers.insertI18nContentIntoDocument(document);
|
||||
helpers.insertI18nTitlesIntoDocument(document);
|
||||
@@ -63,7 +67,7 @@ statistics._generateTable = function (data, type) {
|
||||
valueColumn.appendChild(document.createTextNode(value[1]));
|
||||
row.appendChild(valueColumn);
|
||||
|
||||
document.getElementById('tbody-' + type).appendChild(row);
|
||||
document.getElementById(`tbody-${type}`).appendChild(row);
|
||||
}
|
||||
};
|
||||
|
||||
@@ -92,7 +96,7 @@ statistics._mergeObjects = function (obj, arr) {
|
||||
let bundle = targets.determineBundle(key);
|
||||
if (bundle !== '') {
|
||||
bundle = key.split('/');
|
||||
key = bundle[0] + '/' + bundle[1] + '/' + bundle[2] + '/';
|
||||
key = `${bundle[0]}/${bundle[1]}/${bundle[2]}/`;
|
||||
}
|
||||
// If CDN/Framework exists, add it, otherwise create new one
|
||||
if (arr[key]) {
|
||||
@@ -125,9 +129,11 @@ statistics._setDateRange = function () {
|
||||
|
||||
if (days > 1) {
|
||||
for (let i = 0; i < days; i++) {
|
||||
let diff, day;
|
||||
|
||||
// NOTE: setDate/getDate is buggy over day/month/year boundaries
|
||||
let diff = 24 * 3600000 * i;
|
||||
let day = from.setTime(today.getTime() - diff);
|
||||
diff = 24 * 3600000 * i;
|
||||
day = from.setTime(today.getTime() - diff);
|
||||
statistics._dateRange.push(new Date(day).toISOString().slice(0, 10));
|
||||
}
|
||||
}
|
||||
@@ -194,12 +200,12 @@ statistics._displayNameOfFramework = function (str, type) {
|
||||
if (filename === 'Unknown') {
|
||||
filename = targets.determineBundle(str);
|
||||
if (filename === '' && str.startsWith('resources/font-awesome/')) {
|
||||
filename = 'Font Awesome (Fonts)'
|
||||
filename = 'Font Awesome (Fonts)';
|
||||
}
|
||||
}
|
||||
version = str.match(Resource.VERSION_EXPRESSION);
|
||||
if (version !== null && version.length > 0) {
|
||||
version = version[0] === 'latest' ? version[0] : 'v' + version[0];
|
||||
version = version[0] === 'latest' ? version[0] : `v${version[0]}`;
|
||||
} else {
|
||||
version = '';
|
||||
}
|
||||
@@ -215,7 +221,7 @@ statistics._displayNameOfFramework = function (str, type) {
|
||||
return document.createTextNode(str);
|
||||
};
|
||||
|
||||
statistics._handlerDateRange = function ({ target }) {
|
||||
statistics._handlerDateRange = function ({target}) {
|
||||
let type = target.value;
|
||||
if (type === 'day' || type === 'week' || type === 'month' || type === 'year') {
|
||||
statistics._dateUnit = type;
|
||||
@@ -231,20 +237,22 @@ statistics._deleteStatistic = function () {
|
||||
chrome.storage.local.set({
|
||||
[Setting.INTERNAL_STATISTICS_DATA]: {}
|
||||
});
|
||||
chrome.runtime.sendMessage({ topic: 'deleteStatistic' });
|
||||
chrome.runtime.sendMessage({'topic': 'deleteStatistic'});
|
||||
}
|
||||
};
|
||||
|
||||
statistics._registerListener = function () {
|
||||
document.getElementById('date-range').addEventListener('change', statistics._handlerDateRange);
|
||||
document.getElementById('btn-delete').addEventListener('click', function () {
|
||||
statistics._handlerDateRange({ target: { value: 'delete' } });
|
||||
statistics._handlerDateRange({'target': {'value': 'delete'}});
|
||||
});
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Initializations
|
||||
*/
|
||||
|
||||
statistics._data = {};
|
||||
statistics._dataSortedCDNs = {};
|
||||
statistics._dataSortedFrameworks = {};
|
||||
|
||||
@@ -15,19 +15,23 @@
|
||||
|
||||
'use strict';
|
||||
|
||||
|
||||
/**
|
||||
* Updates
|
||||
*/
|
||||
|
||||
var updates = {};
|
||||
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
|
||||
updates._openHistoryReleaseNotes = function () {
|
||||
let container = document.getElementById('history-release-notes');
|
||||
let toggle = document.getElementById('history-indicator');
|
||||
let container, toggle;
|
||||
|
||||
container = document.getElementById('history-release-notes');
|
||||
toggle = document.getElementById('history-indicator');
|
||||
|
||||
if (container.style.display === 'none') {
|
||||
container.style.display = 'block';
|
||||
@@ -39,11 +43,13 @@ updates._openHistoryReleaseNotes = function () {
|
||||
};
|
||||
|
||||
updates._onDocumentLoaded = function () {
|
||||
let updateElements, urlParams;
|
||||
|
||||
document.getElementById('generate-ublock-rules').checked = false;
|
||||
document.getElementById('generate-umatrix-rules').checked = false;
|
||||
document.getElementById('generate-adguard-rules').checked = false;
|
||||
|
||||
let updateElements = {
|
||||
updateElements = {
|
||||
['ruleSets']: document.getElementsByName('rule-sets'),
|
||||
['copyRuleSet']: document.getElementById('button-copy-rule-set'),
|
||||
};
|
||||
@@ -57,7 +63,7 @@ updates._onDocumentLoaded = function () {
|
||||
document.getElementById('history').addEventListener('click', updates._openHistoryReleaseNotes);
|
||||
|
||||
// GET parameter to display the rule set generator
|
||||
let urlParams = new URLSearchParams(window.location.search);
|
||||
urlParams = new URLSearchParams(window.location.search);
|
||||
if (urlParams.get('mappingupdate') === 'true') {
|
||||
document.getElementById('generator-section').style.display = 'block';
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user