mirror of
https://github.com/anticensority/runet-censorship-bypass.git
synced 2024-11-27 20:03:45 +03:00
added code for migrating prop name from 0.7 to 0.8
This commit is contained in:
parent
4dc16667df
commit
03cec0b7bd
|
@ -3,7 +3,7 @@
|
|||
|
||||
"name": "Ненавязчивый РосКомНадзор",
|
||||
"description": "Аргументы против цензуры: https://git.io/vEkI9",
|
||||
"version": "0.0.0.8",
|
||||
"version": "0.0.0.9",
|
||||
"icons": {
|
||||
"128": "/icons/ribbon128.png"
|
||||
},
|
||||
|
|
|
@ -57,21 +57,30 @@ window.antiCensorRu = {
|
|||
// PROTECTED
|
||||
|
||||
pushToStorage(cb) {
|
||||
// Copy only settable properties.
|
||||
var onlySettable = {};
|
||||
for(var key of Object.keys(this))
|
||||
if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function')
|
||||
onlySettable[key] = this[key]
|
||||
|
||||
return chrome.storage.local.set(onlySettable, () => cb && cb(chrome.runtime.lastError, onlySettable) );
|
||||
// Copy only settable properties.
|
||||
var onlySettable = {};
|
||||
for(var key of Object.keys(this))
|
||||
if (Object.getOwnPropertyDescriptor(this, key).writable && typeof(this[key]) !== 'function')
|
||||
onlySettable[key] = this[key]
|
||||
|
||||
return chrome.storage.local.clear(
|
||||
() => chrome.storage.local.set(
|
||||
onlySettable,
|
||||
() => cb && cb(chrome.runtime.lastError, onlySettable)
|
||||
)
|
||||
);
|
||||
|
||||
},
|
||||
|
||||
pullFromStorage(cb) {
|
||||
chrome.storage.local.get(null, storage => {
|
||||
console.log('In storage:', storage);
|
||||
for(var key of Object.keys(storage))
|
||||
this[key] = storage[key];
|
||||
|
||||
console.log('Synced with storage, any callback?', !!cb);
|
||||
console.log('ifFirstInstall?', this.ifFirstInstall);
|
||||
if (cb)
|
||||
cb(chrome.runtime.lastError, storage);
|
||||
});
|
||||
|
@ -179,6 +188,11 @@ chrome.runtime.onInstalled.addListener( details => {
|
|||
console.log('Extension just installed, reason:', details.reason);
|
||||
window.storageSyncedPromise.then(
|
||||
storage => {
|
||||
|
||||
// Change property name from version 0.0.0.7
|
||||
window.antiCensorRu.ifFirstInstall = window.antiCensorRu.ifNotInstalled;
|
||||
delete window.antiCensorRu.ifNotInstalled;
|
||||
|
||||
switch(details.reason) {
|
||||
case 'update':
|
||||
console.log('Ah, it\'s just an update or reload. Do nothing.');
|
||||
|
|
Loading…
Reference in New Issue
Block a user