From 922ec56512a897627e3669ff4ba16118a4423453 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Thu, 23 Aug 2018 10:51:09 +0100 Subject: 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. --- content_scripts/scroller.coffee | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) 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? -- cgit v1.2.3