fdbfb23547
* parserlib: fast section extraction, tweaks and speedups
* csslint: "simple-not" rule
* csslint: enable and fix "selector-newline" rule
* simplify db: resolve with result
* simplify download()
* remove noCode param as it wastes more time/memory on copying
* styleManager: switch style<->data names to reflect their actual contents
* inline method bodies to avoid indirection and enable better autocomplete/hint/jump support in IDE
* upgrade getEventKeyName to handle mouse clicks
* don't trust location.href as it hides text fragment
* getAllKeys is implemented since Chrome48, FF44
* allow recoverable css errors + async'ify usercss.js
* openManage: unminimize windows
* remove the obsolete Chrome pre-65 workaround
* fix temporal dead zone in apply.js
* ff bug workaround for simple editor window
* consistent window scrolling in scrollToEditor and jumpToPos
* rework waitForSelector and collapsible <details>
* blank paint frame workaround for new Chrome
* extract stuff from edit.js and load on demand
* simplify regexpTester::isShown
* move MozDocMapper to sections-util.js
* extract fitSelectBox()
* initialize router earlier
* use helpPopup.close()
* fix autofocus in popups, follow-up to 5bb1b5ef
* clone objects in prefs.get() + cosmetics
* reuse getAll result for INC
53 lines
1.6 KiB
JavaScript
53 lines
1.6 KiB
JavaScript
/* global tryJSONparse */// toolbox.js
|
|
'use strict';
|
|
|
|
(() => {
|
|
let LZString;
|
|
|
|
/** @namespace StorageExtras */
|
|
const StorageExtras = {
|
|
async getValue(key) {
|
|
return (await this.get(key))[key];
|
|
},
|
|
async setValue(key, value) {
|
|
await this.set({[key]: value});
|
|
},
|
|
async getLZValue(key) {
|
|
return (await this.getLZValues([key]))[key];
|
|
},
|
|
async getLZValues(keys = Object.values(this.LZ_KEY)) {
|
|
const [data] = await Promise.all([
|
|
this.get(keys),
|
|
LZString || loadLZString(),
|
|
]);
|
|
for (const key of keys) {
|
|
const value = data[key];
|
|
data[key] = value && tryJSONparse(LZString.decompressFromUTF16(value));
|
|
}
|
|
return data;
|
|
},
|
|
async setLZValue(key, value) {
|
|
if (!LZString) await loadLZString();
|
|
return this.setValue(key, LZString.compressToUTF16(JSON.stringify(value)));
|
|
},
|
|
};
|
|
/** @namespace StorageExtrasSync */
|
|
const StorageExtrasSync = {
|
|
LZ_KEY: {
|
|
csslint: 'editorCSSLintConfig',
|
|
stylelint: 'editorStylelintConfig',
|
|
usercssTemplate: 'usercssTemplate',
|
|
},
|
|
};
|
|
|
|
async function loadLZString() {
|
|
await require(['/vendor/lz-string-unsafe/lz-string-unsafe.min']);
|
|
LZString = window.LZString || window.LZStringUnsafe;
|
|
}
|
|
|
|
/** @type {chrome.storage.StorageArea|StorageExtras} */
|
|
window.chromeLocal = Object.assign(browser.storage.local, StorageExtras);
|
|
/** @type {chrome.storage.StorageArea|StorageExtras|StorageExtrasSync} */
|
|
window.chromeSync = Object.assign(browser.storage.sync, StorageExtras, StorageExtrasSync);
|
|
})();
|