Commit Graph

65 Commits

Author SHA1 Message Date
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
Jason
a01bdf7b5a chrome.extension.onMessage -> chrome.runtime.onMessage 2016-01-30 18:06:04 -06:00
Jason Barnabe
8f10fc291e Merge pull request #157 from tophf/sync-settings
Sync prefs
2016-01-30 16:05:07 -06:00
tophf
ac70503718 Apply styles upon direct URL hash modification 2015-12-31 19:07:55 +03:00
tophf
d971bbda8a Remove unneeded "Pref" word from prefs methods 2015-10-15 00:34:47 +03:00
tophf
1f961b0993 Deprecate localStorage, refactor prefs 2015-10-15 00:34:46 +03:00
tophf
69a085c116 Fix occasional Chrome mismatch requestUrl!=sender.tab.url 2015-10-05 18:06:05 +03:00
tophf
274584510f Fix getStyles returning global styles for extensions pages
This didn't work anyway but wrongly showed nonzero style count in an opened popup when the option was changed in another window.
2015-10-05 17:44:44 +03:00
tophf
73218c399b Support ftp urls 2015-08-11 07:36:48 +03:00
tophf
bbddba9532 Isolate try-catch in background script 2015-08-01 15:13:52 +03:00
tophf
ae8683873a fixes for Chrome 31 2015-08-01 15:11:32 +03:00
tophf
7d25709a7d Don't wrongly style tabs with identical openerTabId 2015-07-26 05:24:46 +03:00
tophf
c60a21cf12 New Tab Page: fixup for icon, badge, popup style list 2015-05-21 17:45:06 +03:00
tophf
f765934316 Dim toolbar icon on unstyled tabs, regenerate icons 2015-05-21 17:38:02 +03:00
tophf
a0c5674f6f Wait for background page to load on Chrome startup
At startup Chrome lazy-loads extension's background page,
thus occasionally breaking apply.js and Stylish own pages
2015-05-05 21:36:16 +03:00
tophf
bc6476bc52 Editor: option to select CodeMirror CSS theme 2015-05-05 21:14:11 +03:00
tophf
30598dbbf0 Fix old Chrome error: no 'browser_action' contextMenu type 2015-04-22 22:01:19 +03:00
tophf
1156b3f989 Fix 'const in strict mode' error in very old Chrome 2015-04-22 14:30:55 +03:00
tophf
d4382d3f08 Apply global changes to popups 2015-04-07 20:07:45 +03:00
tophf
bd9a91951f Add 2 global behavior toggles to the toolbar button context menu 2015-03-26 21:16:03 +03:00
tophf
2ed53db7ad Add Chrome shortcut keys; update popups on change
* hotkey to open Manage styles
* hotkey to enable/disable all styles

No default hotkeys are provided, to customize go to "Keyboard shortcuts" on the Extensions page
2015-03-25 18:04:51 +03:00
hideheader
f45a6506be Add 'Disable all styles' to popup 2015-03-24 20:21:19 +03:00
tophf
8e6e1f97b2 Manager: "Edit" button re-uses existing tabs, shift-click opens a new window 2015-03-20 17:29:47 +03:00
9adefaf01e5bf6426d838cd20eae582d2b6ba647
0ff7537a8d Actually use the show-badge preference 2015-03-07 05:02:13 +03:00
hideheader
f54a70fe07 Replace localStorage calls with prefs calls 2015-03-03 18:36:18 -05:00
hideheader
c6340e9617 Use a common webNavigation listener
Use the same listener for `webNavigation.onCommitted` and `webNavigation.onHistoryStateUpdated`.
2015-02-23 17:48:27 -05:00
hideheader
b377be8a18 Reload styles on history.pushState 2015-02-23 00:25:24 -05:00
Jason Barnabe
adb54a4a88 Disable logging of style applies logic 2015-02-17 13:57:17 -06:00
Jason Barnabe
e6df389f59 Explain why we 'Only push styles to the top-level document' #27 2015-02-17 12:52:32 -06:00
hideheader
6b178c9184 Only push styles to the top-level document.
Push styles only to the main frame of a tab; let the content script pull styles into child frames, as before.

`chrome.tabs.sendMessage` can only broadcast to all frames in a tab until Chrome 41. The main frame always fires `onCommit` before any child frame, so only the main frame hears its own message from `onCommit`. It (and every child frame that's already fired `onCommit`) hears the `onCommit` message for every frame that follows, with the result that the main frame applies all the styles for every frame in the tab.
https://forum.userstyles.org/discussion/45062/stylish-for-chrome-1-3-0b1#Comment_95474
2015-02-12 17:44:43 -05:00
Jason Barnabe
5e3efb3df6 Apply styles to Stylish pages 2015-02-08 22:25:35 -06:00
Jason Barnabe
d879b5e0c4 Add option for smart indentation in editor 2015-02-08 22:02:08 -06:00