Add compat.js for getPref and setPref
This commit is contained in:
parent
74b1010881
commit
c3fab882f2
44
chrome_addon/compat.js
Normal file
44
chrome_addon/compat.js
Normal file
|
@ -0,0 +1,44 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2013-2017 Grégory Soutadé
|
||||||
|
|
||||||
|
This file is part of gPass.
|
||||||
|
|
||||||
|
gPass is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
gPass is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getPref(key)
|
||||||
|
{
|
||||||
|
var promise = new Promise((resolve, reject) => {
|
||||||
|
chrome.storage.local.get(key, (items) => {
|
||||||
|
let err = chrome.runtime.lastError;
|
||||||
|
if (err) {
|
||||||
|
reject(err);
|
||||||
|
} else {
|
||||||
|
resolve(items);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
})
|
||||||
|
.then(function (pref) {
|
||||||
|
if (!pref.hasOwnProperty(key))
|
||||||
|
return default_preferences[key];
|
||||||
|
return pref[key];
|
||||||
|
});
|
||||||
|
|
||||||
|
return promise;
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPref(key, value)
|
||||||
|
{
|
||||||
|
chrome.storage.local.set({key:value}, function ok() {});
|
||||||
|
}
|
|
@ -175,25 +175,3 @@ async function decrypt(mkey, data)
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
function getPref(key)
|
|
||||||
{
|
|
||||||
return browser.storage.local.get(key)
|
|
||||||
.then(
|
|
||||||
function (pref) {
|
|
||||||
if (!pref.hasOwnProperty(key))
|
|
||||||
return default_preferences[key];
|
|
||||||
return pref[key];
|
|
||||||
}
|
|
||||||
,
|
|
||||||
function (err) {
|
|
||||||
console.log("Error getting preference " + err);
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
|
||||||
|
|
||||||
function setPref(key, value)
|
|
||||||
{
|
|
||||||
browser.storage.local.set({key:value});
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
|
|
||||||
"name": "gPass",
|
"name": "gPass",
|
||||||
"short_name": "gPass",
|
"short_name": "gPass",
|
||||||
"version": "0.7",
|
"version": "0.8",
|
||||||
"description": "gPass : global password manager",
|
"description": "gPass : global password manager",
|
||||||
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
|
"icons" : {"16":"icons/gpass_icon_16.png", "32":"icons/gpass_icon_32.png", "64":"icons/gpass_icon_64.png", "128":"icons/gpass_icon_128.png"},
|
||||||
"author" : "Grégory Soutadé",
|
"author" : "Grégory Soutadé",
|
||||||
|
@ -12,7 +12,7 @@
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*/*", "http://*/*"],
|
"matches": ["https://*/*", "http://*/*"],
|
||||||
"js": ["lib/parseuri.js", "lib/misc.js", "lib/main.js"],
|
"js": ["lib/parseuri.js", "lib/misc.js", "compat.js", "lib/main.js"],
|
||||||
"run_at" : "document_idle",
|
"run_at" : "document_idle",
|
||||||
"all_frames" : true
|
"all_frames" : true
|
||||||
}
|
}
|
||||||
|
|
39
firefox_webextension/compat.js
Normal file
39
firefox_webextension/compat.js
Normal file
|
@ -0,0 +1,39 @@
|
||||||
|
/*
|
||||||
|
Copyright (C) 2013-2017 Grégory Soutadé
|
||||||
|
|
||||||
|
This file is part of gPass.
|
||||||
|
|
||||||
|
gPass is free software: you can redistribute it and/or modify
|
||||||
|
it under the terms of the GNU General Public License as published by
|
||||||
|
the Free Software Foundation, either version 3 of the License, or
|
||||||
|
(at your option) any later version.
|
||||||
|
|
||||||
|
gPass is distributed in the hope that it will be useful,
|
||||||
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
GNU General Public License for more details.
|
||||||
|
|
||||||
|
You should have received a copy of the GNU General Public License
|
||||||
|
along with gPass. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
function getPref(key)
|
||||||
|
{
|
||||||
|
return browser.storage.local.get(key)
|
||||||
|
.then(
|
||||||
|
function (pref) {
|
||||||
|
if (!pref.hasOwnProperty(key))
|
||||||
|
return default_preferences[key];
|
||||||
|
return pref[key];
|
||||||
|
}
|
||||||
|
,
|
||||||
|
function (err) {
|
||||||
|
console.log("Error getting preference " + err);
|
||||||
|
}
|
||||||
|
);
|
||||||
|
}
|
||||||
|
|
||||||
|
function setPref(key, value)
|
||||||
|
{
|
||||||
|
browser.storage.local.set({key:value});
|
||||||
|
}
|
|
@ -12,7 +12,7 @@
|
||||||
"content_scripts": [
|
"content_scripts": [
|
||||||
{
|
{
|
||||||
"matches": ["https://*/*", "http://*/*"],
|
"matches": ["https://*/*", "http://*/*"],
|
||||||
"js": ["lib/parseuri.js", "lib/misc.js", "lib/main.js"],
|
"js": ["lib/parseuri.js", "lib/misc.js", "compat.js", "lib/main.js"],
|
||||||
"run_at" : "document_idle",
|
"run_at" : "document_idle",
|
||||||
"all_frames" : true
|
"all_frames" : true
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user