diff --git a/brozzler/js-templates/simpleclicks.js.j2 b/brozzler/js-templates/simpleclicks.js.j2 index 95f0008..14652b8 100644 --- a/brozzler/js-templates/simpleclicks.js.j2 +++ b/brozzler/js-templates/simpleclicks.js.j2 @@ -22,6 +22,13 @@ var umbraBehavior = { idleSince : null, alreadyClicked : {}, + // https://github.com/jquery/jquery/blob/master/src/css/hiddenVisibleSelectors.js + // n.b. returns true for elements with visibility:hidden, which occupy + // screen real estate but are not visible, or clickable with the ui + isVisible : function(elem) { + return !!(elem.offsetWidth || elem.offsetHeight || elem.getClientRects().length); + }, + intervalFunc : function() { var clickedSomething = false; var somethingLeftBelow = false; @@ -38,10 +45,11 @@ var umbraBehavior = { } for (var j = 0; j < documents.length; j++) { - var clickTargets = documents[j].querySelectorAll(cssSelector); - for ( var i = 0; i < clickTargets.length; i++) { + if (!this.isVisible(clickTargets[i])) { + continue; + } if (clickTargets[i].umbraClicked && !clickUntilTimeout) { continue; } @@ -78,12 +86,12 @@ var umbraBehavior = { this.idleSince = null; } else if (somethingLeftBelow) { // console.log("scrolling because everything on this screen has been clicked but there's more below document.body.clientHeight=" - // + document.body.clientHeight); + // + document.body.clientHeight); window.scrollBy(0, 200); this.idleSince = null; } else if (window.scrollY + window.innerHeight < document.documentElement.scrollHeight) { // console.log("scrolling because we're not to the bottom yet document.body.clientHeight=" - // + document.body.clientHeight); + // + document.body.clientHeight); window.scrollBy(0, 200); this.idleSince = null; } else if (this.idleSince == null) { diff --git a/setup.py b/setup.py index 4c00492..4601475 100644 --- a/setup.py +++ b/setup.py @@ -32,7 +32,7 @@ def find_package_data(package): setuptools.setup( name='brozzler', - version='1.1b9.dev164', + version='1.1b9.dev165', description='Distributed web crawling with browsers', url='https://github.com/internetarchive/brozzler', author='Noah Levitt',