Commit Graph

76 Commits

Author SHA1 Message Date
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
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