Auto reset settings & warning page for incompatible versions #292

This commit is contained in:
ManeraKai 2022-05-31 01:49:09 +03:00
parent 46e78b9231
commit 2b048f6af1
No known key found for this signature in database
GPG Key ID: 5ABC31FFD562E337
2 changed files with 60 additions and 1 deletions

View File

@ -23,8 +23,11 @@ window.browser = window.browser || window.chrome;
browser.runtime.onInstalled.addListener(
async details => {
if (details.reason == 'install') {
// if (details.reason == 'install') {
if (details.reason == 'install' || details.reason == "update") {
browser.tabs.create({ url: browser.extension.getURL("/pages/background/reset_warning.html") });
fetch('/instances/blocklist.json').then(response => response.text()).then(async data => {
await browser.storage.local.clear();
await browser.storage.local.set({ cloudflareList: JSON.parse(data) })
generalHelper.initDefaults();
youtubeHelper.initDefaults();

View File

@ -0,0 +1,56 @@
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title data-localise="__MSG_instanceIsOff__">Instance is offline</title>
<link href="../stylesheets/styles.css" rel="stylesheet" />
<style>
body {
margin: 0;
padding: 0;
height: 100vh;
width: 100vw;
flex-wrap: wrap;
justify-content: center;
align-items: center;
font-size: 30px;
display: flex;
}
div {
width: 80%;
}
div.logo{
display: flex;
}
img {
width: 90px;
height: auto;
}
</style>
</head>
<body>
<div>
<div class="logo">
<img src="/assets/images/libredirect.svg" alt="LibRedirect icon">
<h1>LibRedirect</h1>
</div>
<p data-localise="__MSG_instanceOffline__">All settings have been reset as they're incompatible with the
previous version.</p>
<p>Sorry for the inconvenience, but we're going in a fast development process and can't
support nor convert older settings. It will reach at the end a stable plateau though.</p>
</div>
<script src="instance_offline.js"></script>
<script src="../../assets/javascripts/localise.js"></script>
</body>
</html>