mirror of
https://github.com/internetarchive/brozzler.git
synced 2025-04-20 23:56:34 -04:00
ARI-3956 simple behavior for usask.ca slideshows (which also required enhancing the simple behavior logic)
This commit is contained in:
parent
c5c642a990
commit
9e5900c61f
@ -1,24 +1,30 @@
|
||||
var umbraSimpleClicksBehavior = {
|
||||
IDLE_TIMEOUT_SEC: 10,
|
||||
idleSince: null,
|
||||
clickTargets: [],
|
||||
nextClickIndex: 0,
|
||||
alreadyClicked: {},
|
||||
|
||||
intervalFunc: function() {
|
||||
if (this.nextClickIndex < this.clickTargets.length) {
|
||||
this.clickTargets[this.nextClickIndex].click();
|
||||
this.idleSince = null;
|
||||
this.nextClickIndex++;
|
||||
} else if (this.idleSince == null) {
|
||||
var clickTargets = document.querySelectorAll("${click_css_selector}");
|
||||
|
||||
for (var i = 0; i < clickTargets.length; i++) {
|
||||
var key = clickTargets[i].outerHTML;
|
||||
if (!this.alreadyClicked[key]) {
|
||||
console.log("clicking on " + key);
|
||||
clickTargets[i].click();
|
||||
this.alreadyClicked[key] = true;
|
||||
this.idleSince = null;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (!this.idleSince) {
|
||||
this.idleSince = Date.now();
|
||||
}
|
||||
},
|
||||
|
||||
start: function() {
|
||||
this.clickTargets = document.querySelectorAll("${click_css_selector}");
|
||||
|
||||
var that = this;
|
||||
this.intervalId = setInterval(function(){ that.intervalFunc() }, 50);
|
||||
this.intervalId = setInterval(function(){ that.intervalFunc() }, 250);
|
||||
},
|
||||
|
||||
isFinished: function() {
|
||||
|
@ -20,7 +20,11 @@ behaviors:
|
||||
url_regex: '^https?://.*[?&]catoid=[^?]*$'
|
||||
click_css_selector: a[onclick]
|
||||
request_idle_timeout_sec: 10
|
||||
-
|
||||
- # https://webarchive.jira.com/browse/ARI-3956
|
||||
url_regex: '^https?://(?:www\.)?usask.ca/.*$'
|
||||
click_css_selector: a[id='feature-next']
|
||||
request_idle_timeout_sec: 10
|
||||
- # default fallback brhavior
|
||||
url_regex: '^.*$'
|
||||
request_idle_timeout_sec: 10
|
||||
behavior_js: default.js
|
||||
|
Loading…
x
Reference in New Issue
Block a user