From d9b6d5e18839d1af509d859af5faed880f43fe1e Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 18 Dec 2017 13:03:54 +0000 Subject: Do not use vimiumOnClickAttributeName variable... ... use literals instead. For some reason, on Firefox, using `vimiumOnClickAttributeName` was causing link hints to fail silently (on Facebook). It's not at all clear why this was happening. Simply repeating the literal fixes the issue. Fixes #2879. --- content_scripts/injected.coffee | 8 +++----- content_scripts/link_hints.coffee | 2 +- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/content_scripts/injected.coffee b/content_scripts/injected.coffee index 1c743134..4148ffa5 100644 --- a/content_scripts/injected.coffee +++ b/content_scripts/injected.coffee @@ -3,19 +3,17 @@ # This is based on method 2b here: http://stackoverflow.com/a/9517879, and # @mrmr1993's #1167. -window.vimiumOnClickAttributeName = "_vimium-has-onclick-listener" - -injectedCode = (vimiumOnClickAttributeName) -> +injectedCode = () -> # Note the presence of "click" listeners installed with `addEventListener()` (for link hints). _addEventListener = Element::addEventListener Element::addEventListener = (type, listener, useCapture) -> if type == "click" - try @setAttribute vimiumOnClickAttributeName, "" + try @setAttribute "_vimium-has-onclick-listener", "" _addEventListener?.apply this, arguments script = document.createElement "script" -script.textContent = "(#{injectedCode.toString()})('#{vimiumOnClickAttributeName}')" +script.textContent = "(#{injectedCode.toString()})()" (document.head || document.documentElement).appendChild script script.remove() diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index ba9ada38..44f7a5f5 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -707,7 +707,7 @@ LocalHints = reason = "Open." # Detect elements with "click" listeners installed with `addEventListener()`. - isClickable ||= element.hasAttribute vimiumOnClickAttributeName + isClickable ||= element.hasAttribute "_vimium-has-onclick-listener" # An element with a class name containing the text "button" might be clickable. However, real clickables # are often wrapped in elements with such class names. So, when we find clickables based only on their -- cgit v1.2.3