From 696983f86315f13cef473f2baa6d1e601091f6a8 Mon Sep 17 00:00:00 2001 From: "Ilya Ig. Petrov" Date: Thu, 1 Jun 2017 18:15:15 +0500 Subject: [PATCH] Keep update date in title --- .../src/extension-common/00-init-apis.js | 1 + .../src/extension-common/11-error-handlers-api.js | 2 +- .../37-sync-pac-script-with-pac-provider-api.js | 14 +++++++++++++- 3 files changed, 15 insertions(+), 2 deletions(-) diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/00-init-apis.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/00-init-apis.js index d359622..fff4a1a 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/00-init-apis.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/00-init-apis.js @@ -188,6 +188,7 @@ window.apis = { version: { ifMini: false, + build: chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''), }, }; diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/11-error-handlers-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/11-error-handlers-api.js index b4cbac3..96d3263 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/11-error-handlers-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/11-error-handlers-api.js @@ -61,7 +61,7 @@ const ifPrefix = 'if-on-'; const extName = chrome.runtime.getManifest().name; - const extVersion = chrome.runtime.getManifest().version.replace(/\d+\.\d+\./g, ''); + const extVersion = window.apis.version.build; window.apis.errorHandlers = { diff --git a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js index 2775f08..1ab7194 100644 --- a/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js +++ b/extensions/chromium/runet-censorship-bypass/src/extension-common/37-sync-pac-script-with-pac-provider-api.js @@ -225,6 +225,16 @@ ifFirstInstall: false, lastPacUpdateStamp: 0, + setTitle() { + + const upDate = new Date(this.lastPacUpdateStamp).toLocaleString('ru-RU') + .replace(/:\d+$/, ''); + chrome.browserAction.setTitle({ + title: `Обновлялись ${upDate} | Версия ${window.apis.version.build}`, + }); + + }, + _currentPacProviderLastModified: 0, // Not initialized. getLastModifiedForKey(key = mandatory()) { @@ -331,6 +341,7 @@ this.lastPacUpdateStamp = Date.now(); this.ifFirstInstall = false; this.setAlarms(); + this.setTitle(); } resolve([err, null, ...warns]); @@ -509,10 +520,10 @@ 2. We have to check storage for migration before using it. Better on each launch then on each pull. */ - const ifUpdating = antiCensorRu.version !== oldStorage.version; await new Promise((resolve) => { + const ifUpdating = antiCensorRu.version !== oldStorage.version; if (!ifUpdating) { // LAUNCH, RELOAD, ENABLE @@ -549,6 +560,7 @@ if (antiCensorRu.getPacProvider()) { antiCensorRu.setAlarms(); } + antiCensorRu.setTitle(); /* History of Changes to Storage (Migration Guide)