diff --git a/.eslintrc b/.eslintrc index b3a88c0a..2e335468 100644 --- a/.eslintrc +++ b/.eslintrc @@ -151,7 +151,7 @@ rules: no-implicit-coercion: [1] no-implicit-globals: [0] no-implied-eval: [2] - no-inline-comments: [2] + no-inline-comments: [0] no-inner-declarations: [2] no-invalid-regexp: [2] no-invalid-this: [0] diff --git a/background/storage.js b/background/storage.js index 3277231d..9b105357 100644 --- a/background/storage.js +++ b/background/storage.js @@ -10,21 +10,14 @@ var SLOPPY_REGEXP_PREFIX = '\0'; // Note, only 'var'-declared variables are visible from another extension page // eslint-disable-next-line no-var var cachedStyles = { - // array of all styles - list: null, - // all styles indexed by id - byId: new Map(), - // filterStyles() parameters mapped to the returned results, 10k max - filters: new Map(), - // compiled style regexps - regexps: new Map(), - // getDomain() results for 100 last checked urls - urlDomains: new Map(), + list: null, // array of all styles + byId: new Map(), // all styles indexed by id + filters: new Map(), // filterStyles() parameters mapped to the returned results, 10k max + regexps: new Map(), // compiled style regexps + urlDomains: new Map(), // getDomain() results for 100 last checked urls mutex: { - // while getStyles() is reading IndexedDB all subsequent calls - inProgress: false, - // to getStyles() are queued and resolved when the first one finishes - onDone: [], + inProgress: false, // while getStyles() is reading IndexedDB all subsequent calls + onDone: [], // to getStyles() are queued and resolved when the first one finishes }, }; @@ -255,10 +248,8 @@ function saveStyle(style) { }); } if (reason === 'import') { - // TODO: remove in the future - style.originalDigest = style.originalDigest || style.styleDigest; - // TODO: remove in the future - delete style.styleDigest; + style.originalDigest = style.originalDigest || style.styleDigest; // TODO: remove in the future + delete style.styleDigest; // TODO: remove in the future if (typeof style.originalDigest !== 'string' || style.originalDigest.length !== 40) { delete style.originalDigest; } @@ -533,8 +524,7 @@ function cleanupCachedFilters({force = false} = {}) { const now = Date.now(); const timeSpan = now - oldestHit; const recencyWeight = 5 / size; - // we make ~4 hits per URL - const hitWeight = 1 / 4; + const hitWeight = 1 / 4; // we make ~4 hits per URL const lastHitWeight = 10; // delete the oldest 10% [...cachedStyles.filters.entries()] diff --git a/background/update.js b/background/update.js index 73c1cd21..69f12d3f 100644 --- a/background/update.js +++ b/background/update.js @@ -100,8 +100,7 @@ var updater = { } return !save ? json : saveStyle(Object.assign(json, { - // keep local name customizations - name: null, + name: null, // keep local name customizations reason: 'update', })); } diff --git a/content/apply.js b/content/apply.js index db13ab9b..f29b6e4a 100644 --- a/content/apply.js +++ b/content/apply.js @@ -276,8 +276,7 @@ function initDocRewriteObserver() { } ROOT = document.documentElement; for (const el of styleElements.values()) { - // invalidate CSSOM cache - el.textContent += ' '; + el.textContent += ' '; // invalidate CSSOM cache addStyleElement(document.importNode(el, true)); } }; @@ -351,8 +350,7 @@ function orphanCheck() { window.removeEventListener(chrome.runtime.id, orphanCheck, true); // we can't detach chrome.runtime.onMessage because it's no longer connected internally // we can destroy our globals in this context to free up memory - [ - // functions + [ // functions 'addStyleElement', 'applyOnMessage', 'applySections', diff --git a/content/install.js b/content/install.js index 35bdc3a3..0445af7f 100644 --- a/content/install.js +++ b/content/install.js @@ -1,7 +1,6 @@ 'use strict'; -// non-Windows Chromium -const CHROMIUM = /Chromium/.test(navigator.userAgent); +const CHROMIUM = /Chromium/.test(navigator.userAgent); // non-Windows Chromium const FIREFOX = /Firefox/.test(navigator.userAgent); const VIVALDI = /Vivaldi/.test(navigator.userAgent); const OPERA = /OPR/.test(navigator.userAgent); diff --git a/js/prefs.js b/js/prefs.js index 2da67e45..fdfb2cce 100644 --- a/js/prefs.js +++ b/js/prefs.js @@ -4,56 +4,34 @@ // eslint-disable-next-line no-var var prefs = new function Prefs() { const defaults = { - // new editor opens in a own browser window - 'openEditInWindow': false, - // detached window position - 'windowPosition': {}, - // display text on popup menu icon - 'show-badge': true, - // boss key - 'disableAll': false, - // Add 'stylus-iframe' attribute to HTML element in all iframes - 'exposeIframes': false, + 'openEditInWindow': false, // new editor opens in a own browser window + 'windowPosition': {}, // detached window position + 'show-badge': true, // display text on popup menu icon + 'disableAll': false, // boss key + 'exposeIframes': false, // Add 'stylus-iframe' attribute to HTML element in all iframes - // display 'New style' links as URL breadcrumbs - 'popup.breadcrumbs': true, - // use URL path for 'this URL' - 'popup.breadcrumbs.usePath': false, - // display enabled styles before disabled styles - 'popup.enabledFirst': true, - // display enabled styles before disabled styles - 'popup.stylesFirst': true, + 'popup.breadcrumbs': true, // display 'New style' links as URL breadcrumbs + 'popup.breadcrumbs.usePath': false, // use URL path for 'this URL' + 'popup.enabledFirst': true, // display enabled styles before disabled styles + 'popup.stylesFirst': true, // display enabled styles before disabled styles - // display only enabled styles - 'manage.onlyEnabled': false, - // display only styles created locally - 'manage.onlyLocal': false, + 'manage.onlyEnabled': false, // display only enabled styles + 'manage.onlyLocal': false, // display only styles created locally 'manage.onlyEnabled.invert': false, // display only disabled styles 'manage.onlyLocal.invert': false, // display only externally installed styles - // use the new compact layout - 'manage.newUI': true, - // show favicons for the sites in applies-to - 'manage.newUI.favicons': false, - // gray out favicons - 'manage.newUI.faviconsGray': true, - // max number of applies-to targets visible: 0 = none - 'manage.newUI.targets': 3, + 'manage.newUI': true, // use the new compact layout + 'manage.newUI.favicons': false, // show favicons for the sites in applies-to + 'manage.newUI.faviconsGray': true, // gray out favicons + 'manage.newUI.targets': 3, // max number of applies-to targets visible: 0 = none - // CodeMirror.defaults.* - 'editor.options': {}, - // word wrap - 'editor.lineWrapping': true, - // 'smart' indent - 'editor.smartIndent': true, - // smart indent with tabs - 'editor.indentWithTabs': false, - // tab width, in spaces - 'editor.tabSize': 4, + 'editor.options': {}, // CodeMirror.defaults.* + 'editor.lineWrapping': true, // word wrap + 'editor.smartIndent': true, // 'smart' indent + 'editor.indentWithTabs': false, // smart indent with tabs + 'editor.tabSize': 4, // tab width, in spaces 'editor.keyMap': navigator.appVersion.indexOf('Windows') > 0 ? 'sublime' : 'default', - // CSS theme - 'editor.theme': 'default', - // CSS beautifier - 'editor.beautify': { + 'editor.theme': 'default', // CSS theme + 'editor.beautify': { // CSS beautifier selector_separator_newline: true, newline_before_open_brace: false, newline_after_open_brace: true, @@ -63,34 +41,24 @@ var prefs = new function Prefs() { end_with_newline: false, indent_conditional: true, }, - // lint gutter marker update delay, ms - 'editor.lintDelay': 500, - // Options: 'csslint', 'stylelint' or 'null' - 'editor.linter': 'csslint', - // lint report update delay, ms - 'editor.lintReportDelay': 4500, - // token = token/word under cursor even if nothing is selected - // selection = only when something is selected - // '' (empty string) = disabled - 'editor.matchHighlight': 'token', - // show autocomplete dropdown on typing a word token - 'editor.autocompleteOnTyping': false, - // "Delete" item in context menu - 'editor.contextDelete': contextDeleteMissing(), + 'editor.lintDelay': 500, // lint gutter marker update delay, ms + 'editor.linter': 'csslint', // Choose csslint or stylelint + 'editor.lintReportDelay': 4500, // lint report update delay, ms + 'editor.matchHighlight': 'token', // token = token/word under cursor even if nothing is selected + // selection = only when something is selected + // '' (empty string) = disabled + 'editor.autocompleteOnTyping': false, // show autocomplete dropdown on typing a word token + 'editor.contextDelete': contextDeleteMissing(), // "Delete" item in context menu - // 0 = dark-themed icon; 1 = light-themed icon - 'iconset': 0, + 'iconset': 0, // 0 = dark-themed icon + // 1 = light-themed icon - // badge background color when disabled - 'badgeDisabled': '#8B0000', - // badge background color - 'badgeNormal': '#006666', + 'badgeDisabled': '#8B0000', // badge background color when disabled + 'badgeNormal': '#006666', // badge background color - // popup width in pixels - 'popupWidth': 246, + 'popupWidth': 246, // popup width in pixels - // user-style automatic update interval, hours (0 = disable) - 'updateInterval': 24, + 'updateInterval': 24, // user-style automatic update interval, hours (0 = disable) }; const values = deepCopy(defaults); diff --git a/manage/fileSaveLoad.js b/manage/fileSaveLoad.js index 122bb49c..4a8397ec 100644 --- a/manage/fileSaveLoad.js +++ b/manage/fileSaveLoad.js @@ -72,10 +72,8 @@ function importFromString(jsonString) { let index = 0; let lastRenderTime = performance.now(); const renderQueue = []; - // ms - const RENDER_NAP_TIME_MAX = 1000; - // number of styles - const RENDER_QUEUE_MAX = 50; + const RENDER_NAP_TIME_MAX = 1000; // ms + const RENDER_QUEUE_MAX = 50; // number of styles const SAVE_OPTIONS = {reason: 'import', notify: false}; return new Promise(proceed); diff --git a/msgbox/msgbox.js b/msgbox/msgbox.js index 8809e4bd..4e418832 100644 --- a/msgbox/msgbox.js +++ b/msgbox/msgbox.js @@ -1,20 +1,13 @@ 'use strict'; function messageBox({ - // [mandatory] string - title, - // [mandatory] 1) DOM element 2) string - contents, - // string, CSS class name of the message box element - className = '', - // array of strings used as labels - buttons = [], - // function(messageboxElement) invoked after the messagebox is shown - onshow, - // boolean, blocks the page scroll - blockScroll, - // RETURNS: Promise resolved to {button[number], enter[boolean], esc[boolean]} -}) { + title, // [mandatory] string + contents, // [mandatory] 1) DOM element 2) string + className = '', // string, CSS class name of the message box element + buttons = [], // array of strings used as labels + onshow, // function(messageboxElement) invoked after the messagebox is shown + blockScroll, // boolean, blocks the page scroll +}) { // RETURNS: Promise resolved to {button[number], enter[boolean], esc[boolean]} initOwnListeners(); bindGlobalListeners(); createElement();