diff options
| author | Stephen Blott | 2018-08-23 10:58:00 +0100 |
|---|---|---|
| committer | GitHub | 2018-08-23 10:58:00 +0100 |
| commit | 086df70918056ac1e842bf124d052c6c0eb6920c (patch) | |
| tree | 6962e9af708f6e6087dd3e93ed846b5ea29a75d1 | |
| parent | d4a409d64bba9b23545e26935c35c60c6b4dd301 (diff) | |
| parent | 922ec56512a897627e3669ff4ba16118a4423453 (diff) | |
| download | vimium-086df70918056ac1e842bf124d052c6c0eb6920c.tar.bz2 | |
Merge pull request #3101 from smblott-github/twitter-hack
Site-specific hack to make expanded tweets scrollable.
| -rw-r--r-- | content_scripts/scroller.coffee | 13 |
1 files changed, 12 insertions, 1 deletions
diff --git a/content_scripts/scroller.coffee b/content_scripts/scroller.coffee index f65062e4..e9638c0e 100644 --- a/content_scripts/scroller.coffee +++ b/content_scripts/scroller.coffee @@ -8,7 +8,8 @@ activatedElement = null # is enabled, then we need to use document.scrollingElement instead. There's an explanation in #2168: # https://github.com/philc/vimium/pull/2168#issuecomment-236488091 -getScrollingElement = -> document.scrollingElement ? document.body +getScrollingElement = -> + document.scrollingElement ? document.body # Return 0, -1 or 1: the sign of the argument. # NOTE(smblott; 2014/12/17) We would like to use Math.sign(). However, according to this site @@ -308,6 +309,16 @@ Scroller = element = findScrollableElement element, "x", amount, 1 CoreScroller.scroll element, "x", amount, false +# Hack to make expanded tweets scrollable on Twitter (See #3045). +if DomUtils.isTopFrame() and window.location.host == "twitter.com" + for method in ["scrollTo", "scrollBy"] + do -> + func = Scroller[method] + Scroller[method] = -> + element = document.querySelector "#permalink-overlay-body div.permalink-container div[role=main]" + activatedElement = element ? getScrollingElement() + func arguments... + root = exports ? (window.root ?= {}) root.Scroller = Scroller extend window, root unless exports? |
