Skip to content

Commit

Permalink
Post script values to embedded webext.
Browse files Browse the repository at this point in the history
  • Loading branch information
arantius committed Sep 13, 2017
1 parent 4e1e0d5 commit 00479da
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 1 deletion.
26 changes: 26 additions & 0 deletions content/config.js
Expand Up @@ -461,6 +461,32 @@ Config.prototype._convertScriptToWebext = function(script) {
'name': 'MigrateUserScript',
'script': messageScript,
});

let storage = new GM_ScriptStorageBack(script);
let names = storage.listValues();
for (let i = 0, name = null; name = names[i]; i++) {
let val = storage.getValue(name);
this.migrateSetValue(script, name, val);
}
}


Config.prototype.migrateDeleteValue = function(script, key) {
gWebextPort.postMessage({
'name': 'ApiDeleteValue',
'key': key,
'uuid': script.uuid,
});
}


Config.prototype.migrateSetValue = function(script, key, val) {
gWebextPort.postMessage({
'name': 'ApiSetValue',
'key': key,
'uuid': script.uuid,
'value': val,
});
}


Expand Down
2 changes: 2 additions & 0 deletions modules/storageBack.js
Expand Up @@ -81,6 +81,7 @@ GM_ScriptStorageBack.prototype.setValue = function(name, val) {
}

this._script.changed('val-set', name);
GM_util.getService().config.migrateSetValue(this._script, name, val);
};


Expand Down Expand Up @@ -114,6 +115,7 @@ GM_ScriptStorageBack.prototype.deleteValue = function(name) {
}

this._script.changed('val-del', name);
GM_util.getService().config.migrateDeleteValue(this._script, name);
};


Expand Down
2 changes: 1 addition & 1 deletion webextension

0 comments on commit 00479da

Please sign in to comment.