mirror of
https://codeberg.org/nobody/LocalCDN.git
synced 2025-03-16 19:40:03 +01:00
Implemented notification if something changed on CDNs or frameworks
This commit is contained in:
parent
40ea8a2625
commit
48283328c7
@ -62,6 +62,7 @@ const Setting = {
|
||||
'SHOW_ICON_BADGE': 'showIconBadge',
|
||||
'SHOW_RELEASE_NOTES': 'showReleaseNotes',
|
||||
'STRIP_METADATA': 'stripMetadata',
|
||||
'LAST_MAPPING_UPDATE': 'lastMappingUpdate',
|
||||
'WHITELISTED_DOMAINS': 'whitelistedDomains',
|
||||
'XHR_TEST_DOMAIN': 'xhrTestDomain'
|
||||
};
|
||||
|
23
core/main.js
23
core/main.js
@ -32,6 +32,7 @@ main._initializeSettings = function () {
|
||||
[Setting.DISABLE_PREFETCH]: true,
|
||||
[Setting.ENFORCE_STAGING]: false,
|
||||
[Setting.STRIP_METADATA]: true,
|
||||
[Setting.LAST_MAPPING_UPDATE]: "2020-01-01",
|
||||
[Setting.WHITELISTED_DOMAINS]: {}
|
||||
};
|
||||
|
||||
@ -60,12 +61,12 @@ main._initializeSettings = function () {
|
||||
|
||||
main._showReleaseNotes = function (details) {
|
||||
|
||||
let location, previousVersion;
|
||||
let location, updateAdBlockerRules, previousVersion;
|
||||
|
||||
location = chrome.extension.getURL('pages/welcome/welcome.html');
|
||||
updateAdBlockerRules = chrome.extension.getURL('pages/updates/updates.html');
|
||||
|
||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL ||
|
||||
details.reason === chrome.runtime.OnInstalledReason.UPDATE) {
|
||||
if (details.reason === chrome.runtime.OnInstalledReason.INSTALL) {
|
||||
|
||||
previousVersion = details.previousVersion;
|
||||
|
||||
@ -88,6 +89,22 @@ main._showReleaseNotes = function (details) {
|
||||
}
|
||||
});
|
||||
}
|
||||
} 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
|
||||
});
|
||||
chrome.storage.local.set({
|
||||
[Setting.LAST_MAPPING_UPDATE]: lastMappingUpdate
|
||||
});
|
||||
} else {
|
||||
// No mappings.js update
|
||||
}
|
||||
});
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -17,6 +17,8 @@
|
||||
* Mappings
|
||||
*/
|
||||
|
||||
var lastMappingUpdate = "2020-03-08";
|
||||
|
||||
var mappings = {
|
||||
|
||||
// Google Hosted Libraries
|
||||
|
@ -1,7 +1,7 @@
|
||||
{
|
||||
"manifest_version": 2,
|
||||
"name": "LocalCDN (fork from Decentraleyes)",
|
||||
"version": "2.1.0",
|
||||
"version": "2.1.1",
|
||||
|
||||
"author": "nobody",
|
||||
|
||||
|
@ -220,6 +220,10 @@ input[type=radio] {
|
||||
margin-left: 29px;
|
||||
}
|
||||
|
||||
.last-update {
|
||||
font-weight: bold;
|
||||
}
|
||||
|
||||
/**
|
||||
* Right to Left
|
||||
*/
|
||||
|
@ -130,7 +130,10 @@
|
||||
|
||||
<section class="option">
|
||||
<div class="title-option" data-i18n-content="generateRuleSetTitle"></div>
|
||||
<div class="description-option">In case you're using uBlock or uMatrix you can generate the rules here. You have to add these rules manually in uBlock or uMatrix.</div>
|
||||
<div class="description-option">
|
||||
<p>In case you're using uBlock or uMatrix you can generate the rules here. You have to add these rules manually in uBlock or uMatrix.</p>
|
||||
<p class="last-update">Last update: <span id="last-mapping-update"></span></p>
|
||||
</div>
|
||||
<div class="ruleset-generator">
|
||||
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
|
||||
<label for="generate-ublock-rules">uBlock</label>
|
||||
|
@ -57,6 +57,8 @@ options._renderOptionsPanel = function () {
|
||||
if (options._languageSupported === false) {
|
||||
options._renderLocaleNotice();
|
||||
}
|
||||
|
||||
document.getElementById('last-mapping-update').innerHTML = lastMappingUpdate;
|
||||
};
|
||||
|
||||
options._renderBlockMissingNotice = function () {
|
||||
|
26
pages/updates/updates.css
Normal file
26
pages/updates/updates.css
Normal file
@ -0,0 +1,26 @@
|
||||
/**
|
||||
* Controls
|
||||
*/
|
||||
|
||||
.input-text {
|
||||
margin-left: 29px;
|
||||
max-width: 320px;
|
||||
}
|
||||
|
||||
input[type=radio] {
|
||||
margin: 10px 10px 10px 0px;
|
||||
}
|
||||
|
||||
#button-copy-rule-set {
|
||||
display: none;
|
||||
padding: 5px;
|
||||
margin-left: 29px;
|
||||
width: calc(100% - 29px);
|
||||
font-size: 1.3em;
|
||||
}
|
||||
|
||||
#generated-rules {
|
||||
display: none;
|
||||
margin-left: 29px;
|
||||
width: calc(100% - 29px);
|
||||
}
|
84
pages/updates/updates.html
Normal file
84
pages/updates/updates.html
Normal file
@ -0,0 +1,84 @@
|
||||
<!DOCTYPE html>
|
||||
<html lang="en">
|
||||
<head>
|
||||
<title>LocalCDN release notes</title>
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||
<meta charset="utf-8">
|
||||
<link rel="stylesheet" type="text/css" href="../welcome/welcome.css">
|
||||
<link rel="stylesheet" type="text/css" href="../updates/updates.css">
|
||||
<script src="../../core/constants.js"></script>
|
||||
<script defer src="../../core/resources.js"></script>
|
||||
<script defer src="../../core/mappings.js"></script>
|
||||
<script src="updates.js"></script>
|
||||
<link rel="shortcut icon" href="../welcome/favicon.ico" type="image/x-icon">
|
||||
<link rel="icon" href="../welcome/favicon.ico" type="image/x-icon">
|
||||
</head>
|
||||
<body>
|
||||
<img src="../welcome/logo.svg" alt="Decentraleyes" class="logo"/>
|
||||
<div class="container">
|
||||
<h1>Release notes</h1>
|
||||
<div class="notice">
|
||||
<div class="subtle-hint">
|
||||
<div class="topic-label">
|
||||
New in LocalCDN:
|
||||
</div>
|
||||
<ul>
|
||||
<li>Added Bootstrap JavaScript to ajax.aspnetcdn.com</li>
|
||||
</ul>
|
||||
<div class="topic-label">
|
||||
Please update your uBlock/uMatrix rules
|
||||
</div>
|
||||
<div class="ruleset-generator">
|
||||
<input id="generate-ublock-rules" name="rule-sets" data-option="uBlock" type="radio" value="uBlock">
|
||||
<label for="generate-ublock-rules">uBlock</label>
|
||||
</div>
|
||||
<div class="ruleset-generator">
|
||||
<input id="generate-umatrix-rules" name="rule-sets" data-option="uMatrix" type="radio" value="uMatrix">
|
||||
<label for="generate-umatrix-rules">uMatrix</label>
|
||||
</div>
|
||||
<textarea rows="12" cols="15" id="generated-rules" readonly></textarea>
|
||||
<input id="button-copy-rule-set" type="button" value="Copy">
|
||||
<hr/>
|
||||
<h2>History</h2>
|
||||
<p>2020-03-03 (v2.0.24)<br/>
|
||||
<ul>
|
||||
<li>Framework: Bootstrap CSS v3.3.6, v3.1.1</li>
|
||||
<li>Framework: Bootstrap JavaScript v3.3.6, v3.1.1</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>2020-03-01 (v2.0.22)<br/>
|
||||
<ul>
|
||||
<li>Framework: Bootstrap CSS v4.1.0</li>
|
||||
<li>Framework: Bootstrap JavaScript v4.1.0</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>2020-02-29 (v2.0.20)<br/>
|
||||
<ul>
|
||||
<li>CDN: Baidu CDN, Staticfile CDN, BootCDN, Tencent Public Libraries, Qihoo 360 CDN</li>
|
||||
<li>CDN: Added endpoint for jsDelivr</li>
|
||||
<li>CDN: Baidu CDN</li>
|
||||
<li>CDN: Baidu CDN</li>
|
||||
<li>CDN: Added endpoints for Bootstrap (NetDNA Bootstrap, MaxCDN Bootstrap</li>
|
||||
<li>Framework: AngularJS (Standard, Animated, Sanitize, Cookies, Touch) v1.6.9, v1.7.0, v1.7.1, v1.7.2, v1.7.3, v1.7.4, v1.7.5, v1.7.6, v1.7.7, v1.7.8, v1.7.9</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>2020-02-28 (v2.0.19)<br/>
|
||||
<ul>
|
||||
<li>Framework: Bootstrap CSS v4.0.0, v3.3.7, v3.2.0, v2.3.2</li>
|
||||
<li>Framework: Bootstrap JavaScript v4.0.0, v3.3.7, v3.2.0, v2.3.2</li>
|
||||
</ul>
|
||||
</p>
|
||||
<p>2020-02-28 (v2.0.17)<br/>
|
||||
<ul>
|
||||
<li>CDN: stackpath.bootstrapcdn.com</li>
|
||||
<li>Framework: Bootstrap CSS v4.4.1</li>
|
||||
<li>Framework: Bootstrap CSS v4.3.1</li>
|
||||
<li>Framework: Bootstrap JavaScript v4.4.1</li>
|
||||
<li>Framework: Bootstrap JavaScript v4.3.1</li>
|
||||
</ul>
|
||||
</p>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
</html>
|
77
pages/updates/updates.js
Normal file
77
pages/updates/updates.js
Normal file
@ -0,0 +1,77 @@
|
||||
/**
|
||||
* Main Updates Page
|
||||
* Belongs to Decentraleyes.
|
||||
*
|
||||
* @author nobody42
|
||||
* @since 2020-03-08
|
||||
* @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';
|
||||
|
||||
/**
|
||||
* Updates
|
||||
*/
|
||||
|
||||
var updates = {};
|
||||
|
||||
/**
|
||||
* Private Methods
|
||||
*/
|
||||
updates._openRuleSet = function({target}) {
|
||||
|
||||
let urls = mappings;
|
||||
let updateKey = target.getAttribute('data-option');
|
||||
let updateType = target.getAttribute('value');
|
||||
|
||||
let textArea = document.getElementById("generated-rules");
|
||||
let btnCopy = document.getElementById("button-copy-rule-set");
|
||||
|
||||
let content = "";
|
||||
let ruleSyntax = "";
|
||||
|
||||
if (updateKey === "uMatrix") {
|
||||
ruleSyntax = " script allow";
|
||||
} else if (updateKey === "uBlock") {
|
||||
ruleSyntax = " * noop";
|
||||
}
|
||||
|
||||
textArea.style.display = "block";
|
||||
btnCopy.style.display = "block";
|
||||
|
||||
for (var domain in urls) {
|
||||
content += "* " + domain + ruleSyntax + '\n';
|
||||
}
|
||||
textArea.value = content.replace(/\n+$/, "");
|
||||
}
|
||||
|
||||
updates._copyRuleSet = function() {
|
||||
let textArea = document.getElementById("generated-rules");
|
||||
navigator.clipboard.writeText(textArea.value).then(function() {
|
||||
textArea.select();
|
||||
}, function() {
|
||||
alert("Rule set cannot be copied!");
|
||||
});
|
||||
}
|
||||
|
||||
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")
|
||||
};
|
||||
|
||||
for(let i = 0; i < updateElements.ruleSets.length; i++) {
|
||||
updateElements.ruleSets[i].addEventListener('change', updates._openRuleSet);
|
||||
}
|
||||
updateElements.copyRuleSet.addEventListener('click', updates._copyRuleSet);
|
||||
};
|
||||
|
||||
document.addEventListener('DOMContentLoaded', updates._onDocumentLoaded);
|
Loading…
x
Reference in New Issue
Block a user