Commit Graph

96 Commits

Author SHA1 Message Date
tophf
3daeab63cd Don't submit manifest.version on install since it's unused 2017-07-09 13:10:10 +03:00
tophf
5c1555c781 code cosmetics: fix some eslint complaints
Until https://github.com/eslint/eslint/issues/8594 is sorted out, we're switching to the old indent behavior (indent-legacy).
2017-07-09 12:22:45 +03:00
tophf
877d8b19e0 set default icon (shown before webNavigation API kicks in) 2017-07-09 12:22:45 +03:00
tophf
ece3822891 option to switch toolbar icon sets 2017-07-09 12:22:44 +03:00
tophf
fba85b36cc promisify chrome.tabs.query as queryTabs() 2017-06-17 13:00:10 +03:00
tophf
b4e00cd892 Lazify notifyAllTabs() and injectCS()
* notifyAllTabs: the active tab gets notified immediately, the rest lazily
* notifyAllTabs + injectCS: don't notify lazy-loaded tabs in FF
2017-06-17 09:33:32 +03:00
tophf
22a2086535 FF: suppress pingCS() errors in browser console 2017-06-10 21:33:37 +03:00
tophf
5f0b57bebf embed digest in DB as style.originalDigest 2017-05-03 18:58:09 +03:00
tophf
ee86ef3037 optionsUI: add 'editor.contextDelete' 2017-04-29 19:56:37 +03:00
tophf
acc4d83b9d promisify DB access 2017-04-26 01:36:08 +03:00
tophf
3628564961 reset L10N cache on update 2017-04-26 01:34:57 +03:00
tophf
fdc15d24d9 try to avoid setBadgeText errors 2017-04-23 23:05:35 +03:00
tophf
2e60af40f0 refactor bg updater; add prefs.subscribe() 2017-04-21 15:52:22 +03:00
tophf
c52b8c453f refactor background.js
* use runtime.onInstalled to open FAQ
* extract refreshAllTabs (now it may call applyOnMessage for own tab)
* extract getCodeMirrorThemes and use localStorage to cache the names
* put one-time init stuff inside blocks to help GC
2017-04-21 14:16:56 +03:00
tophf
aa5fc9f640 notify USO earlier in install.js by relaying xhr 2017-04-20 04:52:13 +03:00
tophf
3a8ac2d9dc inline reportError() 2017-04-19 19:22:13 +03:00
tophf
dca6aecd20 Show active NTP icon correctly on startup 2017-04-18 12:47:03 +03:00
tophf
b3b1d4a628 own page load microopt: reduce blocking on i18n
* localStorage cache is faster than chrome.i18n.get
* TreeWalker is faster than tHTML for removing extraneous whitespace
* simple for() is faster than for-of with [...iterable]
2017-04-18 12:47:02 +03:00
tophf
bec60f54ab fixup ccbccae2: add default CM theme entry for firefox 2017-04-18 12:46:37 +03:00
tophf
8f784a19d4 simplify saveStyle, invalidateCache 2017-04-18 12:46:37 +03:00
tophf
a93354de8c remove iframe observer
* documentElement may be overwritten right after iframe was initialized with contentDocument.write() and due to this change being external it's not reported in our existing rewrite observer so we enqueue an additional check using setTimeout(0).

* match_about_blank in manifest.json is back

* iframes with src = about: or javascript: don't have a proper URL when our content script runs so we get the real URL from the parent window

* minor refactoring
2017-04-18 12:46:35 +03:00
tophf
5c8d1950a7 Isolate storage.js in background context
To prevent cross-page leaks we need to create/copy prefs and cachedStyles inside the background page context.

* storage.js is now used only in the background page

* messaging.js now contains less bg-specific methods and more common methods. Added saveStyleSafe, deleteStyleSafe which automatically invoke onRuntimeMessage of the current page or just handleUpdate/handleDelete when notify:false

* prefs.js with 'prefs' for background and UI pages: separate objects because a UI page may load before the background page and it can read prefs from localStorage/sync/defaults
2017-04-18 12:46:34 +03:00
tophf
2bb7d31042 fixups for Opera/Vivaldi/Firefox-compatibility 2017-04-18 12:46:32 +03:00
tophf
26802e36df Optimize startup: coalesce & debounce prefs.set
Previously prefs.set broadcast many messages per each changed pref value to all open tabs, background page, popups. This lead to repeated and needless updates of various things like the toolbar icon, reapplying of styles, and whatnot. It could easily take more than 100ms on an average computer with many tabs open.

Now we debounce the broadcast & sync.set and coalesce all values in one object which is then sent just once per destination.
2017-04-18 12:46:28 +03:00
tophf
668e3a7b56 ignoreChromeError -> messaging; use it in editor's menu update 2017-04-18 12:46:27 +03:00
tophf
4be9dc0413 fixup f7659343: getStyles is callback-based, not return-based 2017-04-18 12:46:25 +03:00
tophf
64c830caa9 webNavigation.onReferenceFragmentUpdated instead of tabs.onUpdated
Also send a Do-It-Yourself to our built-in pages to fetch the styles directly which is faster because IPC messaging JSON-ifies everything internally
2017-04-18 12:46:25 +03:00
tophf
ac4a420e2b ESLint: customize the rules; fix the issues 2017-04-18 12:46:23 +03:00
tophf
19f1490f0a Add context menu 'delete' in editor for browsers without it 2017-04-18 12:43:30 +03:00
tophf
80130797ce Refactor contextMenus and commands 2017-04-18 12:43:30 +03:00
tophf
2f4da37fdb Refactor and speed up popup & manager
Popup:
* Enforce 200-800px range for the popup width option

Manage:
* faster search via cachedStyles.byId
* faster restoration of search results on history nav
* style name is clickable and opens the editor
* animated highlight of style element on update/add/save
* expandable extra applies-to targets
* remember scroll position on normal history navigation
* boz-sizing in #header, also in editor
* applies-to targets use structured markup
* get*Tab*, enableStyle and deleteStyle are promisified
2017-04-18 12:43:29 +03:00
tophf
f4e689721a Improve style caching, cache requests too, add code:false mode
Previously, when a cache was invalidated and every tab/iframe issued a getStyles request, we previous needlessly accessed IndexedDB for each of these requests. It happened because 1) the global cachedStyles was created only at the end of the async DB-reading, 2) and each style record is retrieved asynchronously so the single threaded JS engine interleaved all these operations. It could easily span a few seconds when many tabs are open and you have like 100 styles.

Now, in getStyles: all requests issued while cachedStyles is being populated are queued and invoked at the end.

Now, in filterStyles: all requests are cached using the request's options combined in a string as a key. It also helps on each navigation because we monitor page loading process at different stages: before, when committed, history traversal, requesting applicable styles by a content script. Icon badge update also may issue a copy of the just issued request by one of the navigation listeners.

Now, the caches are invalidated smartly: style add/update/delete/toggle only purges filtering cache, and modifies style cache in-place without re-reading the entire IndexedDB.

Now, code:false mode for manage page that only needs style meta. It reduces the transferred message size 10-100 times thus reducing the overhead caused by to internal JSON-fication in the extensions API.

Also fast&direct getStylesSafe for own pages; code cosmetics
2017-04-18 12:43:28 +03:00
tophf
f86a6489ef Always try CS reinjection (safe since we ping first) 2017-03-16 13:32:13 +03:00
tophf
08509b8cc2 Support file drag-n-drop on the entire manage page 2017-03-16 13:32:13 +03:00
tophf
e658255c36 Reinject content scripts on install/update/enabling the extension
The injection code also runs outside of onInstalled event so we check first if a content script belonging to our execution context "generation" is already injected. This can happen on browser startup: the background page is loaded in several seconds after the normal web page tabs are loaded with our content script(s) already injected. The check itself is simply a "ping" message to each tab that should return true if the content script is alive and kicking.
2017-03-16 13:32:12 +03:00
tophf
38006847f7 Don't apply styles until import is finished 2017-03-16 13:32:12 +03:00
tophf
94836b92d7 Revert "compatibility fix for Chrome v57.0.2987.98 based on https://github.com/schomery/stylish-chrome/issues/43#issuecomment-286348011"
This reverts commit 9e4faa9a29.
2017-03-14 15:15:33 +03:00
Jeremy Schomery
177e5127db do not display the FAQs page in development mode 2017-03-14 12:44:10 +03:30
Jeremy Schomery
9e4faa9a29 compatibility fix for Chrome v57.0.2987.98 based on https://github.com/schomery/stylish-chrome/issues/43#issuecomment-286348011 2017-03-14 12:32:53 +03:30
Jeremy Schomery
74cbefc427 adding the new FAQs page 2017-03-11 12:56:24 +03:30
Jeremy Schomery
218cd46670 updating 'turn all styles off' in the right click context menu when prefs are loaded 2017-02-23 11:07:25 +03:30
Jeremy Schomery
fadf1a070c fixes syncing issue of 'turn all styles off' in the right click context menu with the panel item 2017-02-23 10:39:35 +03:30
Jeremy Schomery
65a3cc195b new context menu item to open styles manager from right click context menu over the toolbar button 2017-02-20 17:25:56 +03:30
Jeremy Schomery
d6ec816ea9 adding options UI (fixes #22, #24) 2017-02-14 19:05:53 +03:30
Jason
4c80d9255f Stop health check from spinning its wheels 2016-03-21 22:29:57 -05:00
Jason
380bfc6ed7 Bring back caching styles in memory 2016-03-19 18:27:28 -05:00
Jason
f4d30838f9 Remove (unnecessary) parentheses #166 2016-03-07 23:24:35 -06:00
Jason
cc95a62c7c Various Firefox error and warning fixes #166 2016-03-07 23:22:28 -06:00
Jason
2973cac28f Switch to IndexedDB #167 2016-03-06 20:27:17 -06:00
Jason
bc477eeef9 Check for onHistoryStateUpdated before use #166 2016-01-30 18:17:25 -06:00