aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorStephen Blott2018-08-23 10:51:09 +0100
committerStephen Blott2018-08-23 10:51:09 +0100
commit922ec56512a897627e3669ff4ba16118a4423453 (patch)
tree34e8e60b9abdffe1499060ad26788a8a3e661429
parenta4a9c4e4625b6a5ad0622a3a84a096238969b13c (diff)
downloadvimium-922ec56512a897627e3669ff4ba16118a4423453.tar.bz2
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 #3045.
-rw-r--r--content_scripts/scroller.coffee13
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?