2020-02-09 04:47:50 +01:00
doctype html
html
2020-05-23 06:19:31 +02:00
#msg
2020-02-09 04:47:50 +01:00
script.
2020-05-23 06:19:31 +02:00
const msg = document.getElementById('msg');
2023-09-26 18:06:21 +02:00
const successText = `\nSuccess Flush! <a href="/">Back to Sharkey</a>\n成功しました。<a href="/">Sharkeyを開き直してください。</a>`;
2020-02-09 04:47:50 +01:00
2021-03-13 02:55:29 +01:00
message('Start flushing.');
(async function() {
try {
localStorage.clear();
message('localStorage cleared.');
const idbPromises = ['MisskeyClient', 'keyval-store'].map((name, i, arr) => new Promise((res, rej) => {
const delidb = indexedDB.deleteDatabase(name);
delidb.onsuccess = () => res(message(`indexedDB "${name}" cleared. (${i + 1}/${arr.length})`));
delidb.onerror = e => rej(e)
}));
await Promise.all(idbPromises);
if (navigator.serviceWorker.controller) {
navigator.serviceWorker.controller.postMessage('clear');
await navigator.serviceWorker.getRegistrations()
.then(registrations => {
return Promise.all(registrations.map(registration => registration.unregister()));
})
2022-08-01 10:44:53 +02:00
.catch(e => { throw new Error(e) });
2021-03-13 02:55:29 +01:00
}
message(successText);
} catch (e) {
message(`\n${e}\n\nFlush Failed. <a href="/flush">Please retry.</a>\n失敗しました。<a href="/flush">もう一度試してみてください。</a>`);
message(`\nIf you retry more than 3 times, clear the browser cache or contact to instance admin.\n3回以上試しても失敗する場合、ブラウザのキャッシュを消去し、それでもだめならインスタンス管理者に連絡してみてください。\n`)
console.error(e);
setTimeout(() => {
location = '/';
}, 10000)
2020-05-23 06:19:31 +02:00
}
2021-03-13 02:55:29 +01:00
})();
2020-05-23 06:19:31 +02:00
function message(text) {
2021-03-13 02:55:29 +01:00
msg.insertAdjacentHTML('beforeend', `<p>[${(new Date()).toString()}] ${text.replace(/\n/g,'<br>')}</p>`)
2020-05-23 06:19:31 +02:00
}