diff options
author | Josh Rickmar <jrick@conformal.com> | 2013-06-13 17:55:10 -0400 |
---|---|---|
committer | Josh Rickmar <jrick@conformal.com> | 2013-06-13 17:55:10 -0400 |
commit | 9e71181da730dc2b5d989292fb6c69ccc02db4b6 (patch) | |
tree | e70b2e71e9021471dd320d1490658a2b41a47605 | |
parent | 293ca84a3f92f86bdc85682bdf3db5e7e9e65a6c (diff) | |
download | xombrero-9e71181da730dc2b5d989292fb6c69ccc02db4b6.tar.gz |
Make link hinting case insensitive
Patch from holger@zedat.fu-berlin.de
-rw-r--r-- | hinting.js | 9 |
1 files changed, 8 insertions, 1 deletions
diff --git a/hinting.js b/hinting.js index f3ca601..0ceeb2b 100644 --- a/hinting.js +++ b/hinting.js @@ -78,7 +78,7 @@ function Hints() { if (typeof(inputText) == "undefined" || inputText == "") { xpath_expr = "//*[@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href] | //input[not(@type='hidden')] | //a[href] | //area | //textarea | //button | //select"; } else { - xpath_expr = "//*[(@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href) and contains(., '" + inputText + "')] | //input[not(@type='hidden') and contains(., '" + inputText + "')] | //a[@href and contains(., '" + inputText + "')] | //area[contains(., '" + inputText + "')] | //textarea[contains(., '" + inputText + "')] | //button[contains(@value, '" + inputText + "')] | //select[contains(., '" + inputText + "')]"; + xpath_expr = _caseInsensitiveExpr("//*[(@onclick or @onmouseover or @onmousedown or @onmouseup or @oncommand or @class='lk' or @role='link' or @href) and contains(translate(., '$u', '$l'), '$l')] | //input[not(@type='hidden') and contains(translate(., '$u', '$l'), '$l')] | //a[@href and contains(translate(., '$u', '$l'), '$l')] | //area[contains(translate(., '$u', '$l'), '$l')] | //textarea[contains(translate(., '$u', '$l'), '$l')] | //button[contains(translate(@value, '$u', '$l'), '$l')] | //select[contains(translate(., '$u', '$l'), '$l')]", inputText); } var res = doc.evaluate(xpath_expr, doc, @@ -454,5 +454,12 @@ function Hints() { var url = elem.href || elem.src; return url; } + + /* returns a case-insensitive version of the XPath expression */ + function _caseInsensitiveExpr(xpath, searchString) + { + return xpath.split("$u").join(searchString.toUpperCase()) + .split("$l").join(searchString.toLowerCase()); + } } hints = new Hints(); |