Commit Graph

60 Commits

Author SHA1 Message Date
tophf
c0fe8dbf43 Move styles after <head> once it appears; fixes #103 2017-06-22 12:16:39 +03:00
tophf
54a875fab3 Map() keys must be of the same type 2017-05-05 18:04:17 +03:00
tophf
6f478cbc57 invalidate CSSOM cache in DocRewriteObserver 2017-05-05 18:02:40 +03:00
tophf
6d65d2a2b6 Expose iframes via HTML[stylus-iframe]
* convert actions to buttons
2017-04-29 03:27:47 +03:00
tophf
3b433adb42 check if orphaned in docRewriteObserver 2017-04-21 15:52:23 +03:00
tophf
9e9723cfd2 code cosmetics 2017-04-21 15:52:22 +03:00
tophf
aaa50d6b7b fixup for Chrome 49 without Symbol.iterator 2017-04-18 12:46:38 +03:00
tophf
dad1d1fe5f get rid of switch-fallthrough; reuse requestStyles 2017-04-18 12:46:35 +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
7ec41bcea1 apply: refactor observers 2017-04-18 12:46:35 +03:00
tophf
4d143a03dc Apply styles to XML documents 2017-04-18 12:46:31 +03:00
tophf
f47b1438dd apply: do orphanCheck only on injection 2017-04-18 12:46:30 +03:00
tophf
071a4d6f26 applyStyleState: use a separate cache for disabled styles 2017-04-18 12:46:29 +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
4bc7b55b91 apply.js: a bad typo caused ghosts to linger 2017-04-18 12:46:28 +03:00
tophf
486d4258d3 Reinject styles on document-rewrite
uBlock-extra rewrites html of some sites known to have bad scripts. Such new documentElement doesn't have our styles so we need to detect this case by observing the parent document node non-recursively, meaning we don't add overhead to the normal browsing experience.
2017-04-18 12:46:26 +03:00
tophf
e4c8ff9ff1 TEMPORARY: restore style elements removed by hostile sites 2017-04-18 12:46:26 +03:00
tophf
0c6b74d999 Apply styles to more iframes
Previously we incorrectly assumed that each sub-element is present in addedNodes array, but actually we need to inspect each added node's children e.g. using the superfast getElementsByTagName.
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
49cba8cced apply.js: don't alter DOM stylesheet state if same 2017-04-18 12:43:31 +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
ac2a1a1c48 Orphaned content script case self-destruction tweaks#2 for apply.js 2017-03-19 05:24:10 +03:00
tophf
b77823c365 Orphaned content script case self-destruction tweaks for apply.js 2017-03-19 04:59:28 +03:00
tophf
71ea723728 Fixup 59e0f3f4: explicitly list our functions in self-destruct
Seems simpler and more robust. Otherwise Chrome spams console warnings about its webkit* aliases we touch.
2017-03-16 15:47:58 +03:00
tophf
59e0f3f45e Self-destruct orphaned content scripts 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
6b49afaa48 Apply enable/disable state of style to popup itself 2017-03-14 15:18:58 +03:00
narcolepticinsomniac
3427c2d433 Rebrand style tags
https://github.com/schomery/stylish-chrome/issues/20#issuecomment-279298239
2017-02-13 01:17:53 -05:00
Jason
2973cac28f Switch to IndexedDB #167 2016-03-06 20:27:17 -06:00
Jason
a01bdf7b5a chrome.extension.onMessage -> chrome.runtime.onMessage 2016-01-30 18:06:04 -06:00
Jason
d957cd1b3b chrome.extension.sendMessage -> chrome.runtime.sendMessage 2016-01-30 17:08:10 -06:00
tophf
a1ab89e7ea Don't needlessly observe iframes while loading
because the browser starts loading iframes after DOMContentLoaded event anyway
2016-01-25 07:10:00 +03:00
tophf
3cf32048ed Apply styles to application/xml autogenerated pages 2016-01-25 07:07:43 +03:00
tophf
cbece7ce25 Bind only one DOMContentLoaded event 2015-12-26 21:23:34 +03:00
Jason Barnabe
7f0557df57 Merge pull request #143 from tophf/fixes
Fixes
2015-08-04 22:37:17 -05:00
tophf
92c2e743d6 Don't break gmail chat iframe by iframeObserver
Apparently some same-domain (!) iframes fail to load when their "contentDocument" is accessed (!)
2015-08-04 21:55:04 +03:00
tophf
99a956c383 Avoid flicker when updating applied styles 2015-08-03 08:25:59 +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
aafa909109 Make iframe observer faster
* Process dynamic frames on DOMContentLoaded
* Apply styles to iframes with srcdoc while loading
2015-05-21 17:16:09 +03:00
tophf
2faead9732 Normalize line endings in apply.js 2015-05-21 17:15:10 +03:00
tophf
539be4ce43 Code review & cosmetics 2015-05-05 23:42:38 +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
d4382d3f08 Apply global changes to popups 2015-04-07 20:07:45 +03:00
tophf
7c53643b19 Apply styles to own pages earlier to avoid flicker 2015-04-07 18:05:23 +03:00
hideheader
f45a6506be Add 'Disable all styles' to popup 2015-03-24 20:21:19 +03:00
Jason
d74dd20931 Fix pop-up when dealing with newtab #80 2015-03-23 13:56:11 -05:00
Jason
74d83e2640 Fix pushState logic for iframe changes #3+ 2015-03-05 12:02:26 -06:00
Jason
d151dd0303 Fix iframe mutation observer #3 2015-03-04 14:03:29 -06:00