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