Skip to content

Commit 922ec56

Browse files
Site-specific hack to make expanded tweets scrollable.
Twitter is an important site and Vimium's scrolling is currently broken when a tweet is expanded. In my opinion, the existing bahviour is so bad and that a site-specific hack is warranted. Fixes philc#3045.
1 parent a4a9c4e commit 922ec56

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

content_scripts/scroller.coffee

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@ activatedElement = null
88
# is enabled, then we need to use document.scrollingElement instead. There's an explanation in #2168:
99
# https://github.com/philc/vimium/pull/2168#issuecomment-236488091
1010

11-
getScrollingElement = -> document.scrollingElement ? document.body
11+
getScrollingElement = ->
12+
document.scrollingElement ? document.body
1213

1314
# Return 0, -1 or 1: the sign of the argument.
1415
# NOTE(smblott; 2014/12/17) We would like to use Math.sign(). However, according to this site
@@ -308,6 +309,16 @@ Scroller =
308309
element = findScrollableElement element, "x", amount, 1
309310
CoreScroller.scroll element, "x", amount, false
310311

312+
# Hack to make expanded tweets scrollable on Twitter (See #3045).
313+
if DomUtils.isTopFrame() and window.location.host == "twitter.com"
314+
for method in ["scrollTo", "scrollBy"]
315+
do ->
316+
func = Scroller[method]
317+
Scroller[method] = ->
318+
element = document.querySelector "#permalink-overlay-body div.permalink-container div[role=main]"
319+
activatedElement = element ? getScrollingElement()
320+
func arguments...
321+
311322
root = exports ? (window.root ?= {})
312323
root.Scroller = Scroller
313324
extend window, root unless exports?

0 commit comments

Comments
 (0)