Fixed bug in lastMappingUpdate and added hideReleaseNotes in settings
This commit is contained in:
parent
27eb0d8c17
commit
e9057f7918
|
@ -70,5 +70,21 @@
|
||||||
"generateRuleSetTitle": {
|
"generateRuleSetTitle": {
|
||||||
"message": "Generiere Regelsätze für uBlock oder uMatrix",
|
"message": "Generiere Regelsätze für uBlock oder uMatrix",
|
||||||
"description": "Generate rule set title."
|
"description": "Generate rule set title."
|
||||||
|
},
|
||||||
|
"loggingTitle": {
|
||||||
|
"message": "Aktiviere das loggen in die Browser-Konsole",
|
||||||
|
"description": "Aktiviere das loggen in die Browser-Konsole."
|
||||||
|
},
|
||||||
|
"loggingDescription": {
|
||||||
|
"message": "Öffne die \"Browser-Konsole\" ( STRG + UMSCHALT + J ) um fehlende Resourcen anzuzeigen.",
|
||||||
|
"description": "Öffne die \"Browser-Konsole\" ( STRG + UMSCHALT + J ) um fehlende Resourcen anzuzeigen."
|
||||||
|
},
|
||||||
|
"hideReleaseNotesTitle": {
|
||||||
|
"message": "Versionshinweise deaktivieren",
|
||||||
|
"description": "Versionshinweise deaktivieren"
|
||||||
|
},
|
||||||
|
"hideReleaseNotesDescription": {
|
||||||
|
"message": "Falls aktivert, erhälst du keine Hinweise über Neuerungen in LocalCDN. Dazu gehören auch Informationen über neue uBlock/uMatrix-Regeln.",
|
||||||
|
"description": "Falls aktivert, erhälst du keine Hinweise über Neuerungen in LocalCDN. Dazu gehören auch Informationen über neue uBlock/uMatrix-Regeln."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,14 @@
|
||||||
},
|
},
|
||||||
"loggingDescription": {
|
"loggingDescription": {
|
||||||
"message": "Open \"Browser Console\" ( CTRL + SHIFT + J ) to show missing resources",
|
"message": "Open \"Browser Console\" ( CTRL + SHIFT + J ) to show missing resources",
|
||||||
"description": "Generate rule set title."
|
"description": "Open \"Browser Console\" ( CTRL + SHIFT + J ) to show missing resources."
|
||||||
|
},
|
||||||
|
"hideReleaseNotesTitle": {
|
||||||
|
"message": "Disable release notes",
|
||||||
|
"description": "Disable release notes"
|
||||||
|
},
|
||||||
|
"hideReleaseNotesDescription": {
|
||||||
|
"message": "If enabled, you wont receive any information about new features in LocalCDN. This includes information about new uBlock/uMatrix rules.",
|
||||||
|
"description": "If enabled, you wont receive any information about new features in LocalCDN. This includes information about new uBlock/uMatrix rules."
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -60,7 +60,7 @@ const Setting = {
|
||||||
'DISABLE_PREFETCH': 'disablePrefetch',
|
'DISABLE_PREFETCH': 'disablePrefetch',
|
||||||
'ENFORCE_STAGING': 'enforceStaging',
|
'ENFORCE_STAGING': 'enforceStaging',
|
||||||
'SHOW_ICON_BADGE': 'showIconBadge',
|
'SHOW_ICON_BADGE': 'showIconBadge',
|
||||||
'SHOW_RELEASE_NOTES': 'showReleaseNotes',
|
'HIDE_RELEASE_NOTES': 'hideReleaseNotes',
|
||||||
'STRIP_METADATA': 'stripMetadata',
|
'STRIP_METADATA': 'stripMetadata',
|
||||||
'LAST_MAPPING_UPDATE': 'lastMappingUpdate',
|
'LAST_MAPPING_UPDATE': 'lastMappingUpdate',
|
||||||
'WHITELISTED_DOMAINS': 'whitelistedDomains',
|
'WHITELISTED_DOMAINS': 'whitelistedDomains',
|
||||||
|
|
66
core/main.js
66
core/main.js
|
@ -31,8 +31,8 @@ main._initializeSettings = function () {
|
||||||
[Setting.BLOCK_MISSING]: false,
|
[Setting.BLOCK_MISSING]: false,
|
||||||
[Setting.DISABLE_PREFETCH]: true,
|
[Setting.DISABLE_PREFETCH]: true,
|
||||||
[Setting.ENFORCE_STAGING]: false,
|
[Setting.ENFORCE_STAGING]: false,
|
||||||
|
[Setting.HIDE_RELEASE_NOTES]: false,
|
||||||
[Setting.STRIP_METADATA]: true,
|
[Setting.STRIP_METADATA]: true,
|
||||||
[Setting.LAST_MAPPING_UPDATE]: "2020-01-01",
|
|
||||||
[Setting.WHITELISTED_DOMAINS]: {},
|
[Setting.WHITELISTED_DOMAINS]: {},
|
||||||
[Setting.LOGGING]: false
|
[Setting.LOGGING]: false
|
||||||
};
|
};
|
||||||
|
@ -69,41 +69,55 @@ main._showReleaseNotes = function (details) {
|
||||||
|
|
||||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
||||||
|
|
||||||
previousVersion = details.previousVersion;
|
chrome.storage.local.set({
|
||||||
|
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
||||||
|
}, function() {
|
||||||
|
|
||||||
if (previousVersion && previousVersion.charAt(0) === '2') {
|
previousVersion = details.previousVersion;
|
||||||
return; // Do not show release notes after minor updates.
|
|
||||||
}
|
|
||||||
|
|
||||||
if (details.temporary !== true) {
|
if (previousVersion && previousVersion.charAt(0) === '2') {
|
||||||
|
return; // Do not show release notes after minor updates.
|
||||||
|
}
|
||||||
|
|
||||||
chrome.storage.local.get({
|
if (details.temporary !== true) {
|
||||||
[Setting.SHOW_RELEASE_NOTES]: true
|
|
||||||
}, function (items) {
|
|
||||||
|
|
||||||
if (items.showReleaseNotes === true) {
|
chrome.storage.local.get([Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||||
|
|
||||||
chrome.tabs.create({
|
if (items.hideReleaseNotes !== true) {
|
||||||
'url': location,
|
|
||||||
'active': false
|
chrome.tabs.create({
|
||||||
});
|
'url': location,
|
||||||
}
|
'active': false
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
|
||||||
// If add-on update true, check last update of mappings.js
|
|
||||||
chrome.storage.local.get({[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate}, function (items) {
|
|
||||||
if (items.lastMappingUpdate !== lastMappingUpdate) {
|
|
||||||
// Updated mappings.js
|
|
||||||
chrome.tabs.create({
|
|
||||||
'url': updateAdBlockerRules,
|
|
||||||
'active': true
|
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else if (details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
||||||
|
|
||||||
|
let newValue = lastMappingUpdate;
|
||||||
|
let oldValue = "";
|
||||||
|
|
||||||
|
// If add-on update true, check last update of mappings.js
|
||||||
|
chrome.storage.local.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
|
||||||
|
|
||||||
|
oldValue = items.lastMappingUpdate;
|
||||||
|
|
||||||
|
if (oldValue !== newValue) {
|
||||||
|
// Updated mappings.js
|
||||||
chrome.storage.local.set({
|
chrome.storage.local.set({
|
||||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
[Setting.LAST_MAPPING_UPDATE]: newValue
|
||||||
|
}, function() {
|
||||||
|
if (!items.hideReleaseNotes) {
|
||||||
|
chrome.tabs.create({
|
||||||
|
'url': updateAdBlockerRules,
|
||||||
|
'active': true
|
||||||
|
});
|
||||||
|
}
|
||||||
});
|
});
|
||||||
} else {
|
} else {
|
||||||
// No mappings.js update
|
// No mappings.js update
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
@ -138,6 +138,23 @@
|
||||||
|
|
||||||
</section>
|
</section>
|
||||||
|
|
||||||
|
<section class="option">
|
||||||
|
|
||||||
|
<div class="title-option">
|
||||||
|
|
||||||
|
<label class="label-checkbox">
|
||||||
|
|
||||||
|
<input class="input-checkbox" data-option="hideReleaseNotes" type="checkbox">
|
||||||
|
<span data-i18n-content="hideReleaseNotesTitle"></span>
|
||||||
|
|
||||||
|
</label>
|
||||||
|
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="description-option" data-i18n-content="hideReleaseNotesDescription"></div>
|
||||||
|
|
||||||
|
</section>
|
||||||
|
|
||||||
<section class="option">
|
<section class="option">
|
||||||
|
|
||||||
<div class="title-option" data-i18n-content="whitelistedDomainsTitle"></div>
|
<div class="title-option" data-i18n-content="whitelistedDomainsTitle"></div>
|
||||||
|
|
|
@ -45,6 +45,7 @@ options._renderOptionsPanel = function () {
|
||||||
elements.blockMissing.checked = options._optionValues.blockMissing;
|
elements.blockMissing.checked = options._optionValues.blockMissing;
|
||||||
elements.disablePrefetch.checked = options._optionValues.disablePrefetch;
|
elements.disablePrefetch.checked = options._optionValues.disablePrefetch;
|
||||||
elements.stripMetadata.checked = options._optionValues.stripMetadata;
|
elements.stripMetadata.checked = options._optionValues.stripMetadata;
|
||||||
|
elements.hideReleaseNotes.checked = options._optionValues.hideReleaseNotes;
|
||||||
elements.enableLogging.checked = options._optionValues.enableLogging;
|
elements.enableLogging.checked = options._optionValues.enableLogging;
|
||||||
elements.whitelistedDomains.value = domainWhitelist;
|
elements.whitelistedDomains.value = domainWhitelist;
|
||||||
|
|
||||||
|
@ -87,6 +88,7 @@ options._registerOptionChangedEventListeners = function (elements) {
|
||||||
elements.disablePrefetch.addEventListener('change', options._onOptionChanged);
|
elements.disablePrefetch.addEventListener('change', options._onOptionChanged);
|
||||||
elements.stripMetadata.addEventListener('change', options._onOptionChanged);
|
elements.stripMetadata.addEventListener('change', options._onOptionChanged);
|
||||||
elements.enableLogging.addEventListener('change', options._onOptionChanged);
|
elements.enableLogging.addEventListener('change', options._onOptionChanged);
|
||||||
|
elements.hideReleaseNotes.addEventListener('change', options._onOptionChanged);
|
||||||
elements.whitelistedDomains.addEventListener('keyup', options._onOptionChanged);
|
elements.whitelistedDomains.addEventListener('keyup', options._onOptionChanged);
|
||||||
let type = elements.ruleSets;
|
let type = elements.ruleSets;
|
||||||
for(let i = 0; i < type.length; i++) {
|
for(let i = 0; i < type.length; i++) {
|
||||||
|
@ -134,6 +136,7 @@ options._getOptionElements = function () {
|
||||||
[Setting.DISABLE_PREFETCH]: options._getOptionElement(Setting.DISABLE_PREFETCH),
|
[Setting.DISABLE_PREFETCH]: options._getOptionElement(Setting.DISABLE_PREFETCH),
|
||||||
[Setting.STRIP_METADATA]: options._getOptionElement(Setting.STRIP_METADATA),
|
[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.HIDE_RELEASE_NOTES]: options._getOptionElement(Setting.HIDE_RELEASE_NOTES),
|
||||||
[Setting.LOGGING]: options._getOptionElement(Setting.LOGGING),
|
[Setting.LOGGING]: options._getOptionElement(Setting.LOGGING),
|
||||||
['ruleSets']: document.getElementsByName("rule-sets"),
|
['ruleSets']: document.getElementsByName("rule-sets"),
|
||||||
['copyRuleSet']: document.getElementById("button-copy-rule-set")
|
['copyRuleSet']: document.getElementById("button-copy-rule-set")
|
||||||
|
|
Loading…
Reference in New Issue