From b6a0bd0cf29fc3621f4c337616ed119f239c0ed0 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Sat, 16 Dec 2017 11:07:22 +0000 Subject: Guard against failure. Since these are executing in the page's context, they could break the page if they were to fail (for whatever reason). So we add some (possibly unnecessary) guards, just in case. --- content_scripts/injected.coffee | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/content_scripts/injected.coffee b/content_scripts/injected.coffee index d833d09c..1c743134 100644 --- a/content_scripts/injected.coffee +++ b/content_scripts/injected.coffee @@ -10,8 +10,9 @@ injectedCode = (vimiumOnClickAttributeName) -> _addEventListener = Element::addEventListener Element::addEventListener = (type, listener, useCapture) -> - @setAttribute vimiumOnClickAttributeName, "" if type == "click" - _addEventListener.apply this, arguments + if type == "click" + try @setAttribute vimiumOnClickAttributeName, "" + _addEventListener?.apply this, arguments script = document.createElement "script" script.textContent = "(#{injectedCode.toString()})('#{vimiumOnClickAttributeName}')" -- cgit v1.2.3