1
0
mirror of https://codeberg.org/nobody/LocalCDN.git synced 2024-12-22 16:12:13 +01:00

Show the rule set generator only when there are new CDNs

This commit is contained in:
nobody 2020-07-24 08:16:25 +02:00
parent 107051e518
commit 7daee86505
No known key found for this signature in database
GPG Key ID: 8F6DE3D614FCFD7A
4 changed files with 37 additions and 31 deletions

View File

@ -93,22 +93,19 @@ main._showReleaseNotes = function (details) {
});
} 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.sync.get([Setting.LAST_MAPPING_UPDATE, Setting.HIDE_RELEASE_NOTES], function (items) {
oldValue = items.lastMappingUpdate;
let mappingUpdate = items.lastMappingUpdate !== lastMappingUpdate;
if (oldValue !== newValue || !items.hideReleaseNotes) {
if (mappingUpdate || !items.hideReleaseNotes) {
// Updated mappings.js
chrome.storage.sync.set({
[Setting.LAST_MAPPING_UPDATE]: newValue
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
}, function() {
if (!items.hideReleaseNotes) {
chrome.tabs.create({
'url': chrome.extension.getURL('pages/updates/updates.html'),
'url': chrome.extension.getURL('pages/updates/updates.html?mappingupdate=' + mappingUpdate),
'active': false
});
}

View File

@ -39,11 +39,11 @@ input[type=radio], label {
}
#history {
cursor: pointer;
font-size: 24px;
font-weight: bold;
cursor: pointer;
font-size: 24px;
font-weight: bold;
}
#history-release-notes {
#generator-section {
display: none;
}

View File

@ -25,27 +25,30 @@
</div>
<ul>
<li>Implemented: Hide icon setting if not supported</li>
<li>Implemented: Show the rule set generator only when there are new CDNs (reported by <a href="https://addons.mozilla.org/en-US/firefox/addon/localcdn-fork-of-decentraleyes/reviews/1572952/">review</a>)</li>
</ul>
<div class="topic-label">
Generate rule sets for uBlock or uMatrix
<div id="generator-section">
<div class="topic-label">
Generate rule sets for uBlock or uMatrix
</div>
<div class="ruleset-generator">
<label class="b-contain" for="generate-ublock-rules">uBlock
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
<div class="b-input"></div>
</label>
</div>
<div class="ruleset-generator">
<label class="b-contain" for="generate-umatrix-rules">uMatrix
<input id="generate-umatrix-rules" name="rule-sets" data-option="uMatrix" type="radio" value="uMatrix">
<div class="b-input"></div>
</label>
</div>
<div>
<textarea rows="12" cols="15" id="generated-rules" readonly></textarea>
<input id="button-copy-rule-set" type="button" value="Copy">
</div>
<hr/>
</div>
<div class="ruleset-generator">
<label class="b-contain" for="generate-ublock-rules">uBlock
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
<div class="b-input"></div>
</label>
</div>
<div class="ruleset-generator">
<label class="b-contain" for="generate-umatrix-rules">uMatrix
<input id="generate-umatrix-rules" name="rule-sets" data-option="uMatrix" type="radio" value="uMatrix">
<div class="b-input"></div>
</label>
</div>
<div>
<textarea rows="12" cols="15" id="generated-rules" readonly></textarea>
<input id="button-copy-rule-set" type="button" value="Copy">
</div>
<hr/>
<div id="history"><span id="history-indicator">+</span> Previous Versions</div>
<div id="history-release-notes" style="display: none;">
<p class='release-date'>2020-07-19 (v2.2.14)</p>

View File

@ -89,6 +89,12 @@ updates._onDocumentLoaded = function () {
updateElements.copyRuleSet.addEventListener('click', updates._copyRuleSet);
document.getElementById('history').addEventListener('click', updates._openHistoryReleaseNotes);
// GET parameter to display the rule set generator
let urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('mappingupdate') === 'true') {
document.getElementById('generator-section').style.display = 'block';
}
};