From afeb65f5af849f04df8380212dbf50a6bf186bc4 Mon Sep 17 00:00:00 2001 From: Stephen Blott Date: Mon, 26 Sep 2016 13:44:16 +0100 Subject: Tweak jsaction detection and add tests. This tweaks the jsaction detection, in particular excluding elements where the "actionName" is "_". I see a lot of these, and clicking them doesn't do anything. Also, added corresponding tests. --- content_scripts/link_hints.coffee | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) (limited to 'content_scripts') diff --git a/content_scripts/link_hints.coffee b/content_scripts/link_hints.coffee index b4b63b1f..4bfd3ef2 100644 --- a/content_scripts/link_hints.coffee +++ b/content_scripts/link_hints.coffee @@ -670,11 +670,17 @@ LocalHints = isClickable = true # Check for jsaction event listeners on the element. - if element.hasAttribute "jsaction" + if not isClickable and element.hasAttribute "jsaction" jsactionRules = element.getAttribute("jsaction").split(";") for jsactionRule in jsactionRules - ruleSplit = jsactionRule.split ":" - isClickable ||= ruleSplit[0] == "click" or (ruleSplit.length == 1 and ruleSplit[0] != "none") + ruleSplit = jsactionRule.trim().split ":" + if 1 <= ruleSplit.length <= 2 + [eventType, namespace, actionName ] = + if ruleSplit.length == 1 + ["click", ruleSplit[0].trim().split(".")..., "_"] + else + [ruleSplit[0], ruleSplit[1].trim().split(".")..., "_"] + isClickable ||= eventType == "click" and namespace != "none" and actionName != "_" # Check for tagNames which are natively clickable. switch tagName -- cgit v1.2.3