update markup, & simplify big image browse?

This commit is contained in:
Barbara Miller 2016-11-04 17:21:18 -07:00
parent 02bf23059e
commit 2f6767627b

View file

@ -33,7 +33,7 @@ var umbraInstagramBehavior = {
return; return;
} }
var moreButtons = document.querySelectorAll(".PhotoGridMoreButton:not(.pgmbDisabled)"); var moreButtons = document.querySelectorAll("a._oidfu");
if (moreButtons.length > 0) { if (moreButtons.length > 0) {
console.log("clicking load more button"); console.log("clicking load more button");
moreButtons[0].click(); moreButtons[0].click();
@ -46,8 +46,7 @@ var umbraInstagramBehavior = {
this.idleSince = Date.now(); this.idleSince = Date.now();
return; return;
} else { } else {
var doneButtons = document.querySelectorAll(".PhotoGridMoreButton.pgmbDisabled"); if ((Date.now() - this.idleSince) > 9000) {
if (Date.now() - this.idleSince > 9000 || (doneButtons.length > 0 && doneButtons[0].innerText === "All items loaded") ) {
console.log("finished loading-thumbs, it appears we have reached the bottom"); console.log("finished loading-thumbs, it appears we have reached the bottom");
this.state = "clicking-first-thumb"; this.state = "clicking-first-thumb";
this.idleSince = null; this.idleSince = null;
@ -60,7 +59,7 @@ var umbraInstagramBehavior = {
} }
if (this.state === "clicking-first-thumb") { if (this.state === "clicking-first-thumb") {
var images = document.querySelectorAll("a.pgmiImageLink"); var images = document.querySelectorAll("div._ovg3g");
if (images && images !== "undefined") { if (images && images !== "undefined") {
this.imageCount = images.length; this.imageCount = images.length;
if (images.length > 0) { if (images.length > 0) {
@ -68,6 +67,7 @@ var umbraInstagramBehavior = {
images[0].click(); images[0].click();
this.idleSince = null; this.idleSince = null;
this.state = "waiting-big-image"; this.state = "waiting-big-image";
this.bigImagesLoaded++;
return; return;
} }
} }
@ -78,59 +78,26 @@ var umbraInstagramBehavior = {
} }
if (this.state === "waiting-big-image") { if (this.state === "waiting-big-image") {
if(this.currentBigImage == null) { if(this.bigImagesLoaded < this.imageCount) {
var imageFrame = document.querySelectorAll("div.Modal div.Item div.iMedia div.Image"); var rightArrow = document.querySelectorAll(".coreSpriteRightPaginationArrow");
if (imageFrame.length > 0 && imageFrame[0].getAttribute("src") !== this.previousBigImage ) { if (rightArrow.length > 0) {
this.currentBigImage = new Image(); // console.log("clicking right arrow");
this.currentBigImage.src = imageFrame[0].getAttribute("src"); rightArrow[0].click();
//console.log("this.currentBigImage.naturalWidth=" + this.currentBigImage.naturalWidth + " this.currentBigImage.src=" + this.currentBigImage.src); this.idleSince = null;
return; this.bigImagesLoaded++;
} else if(this.idleSince == null ) {
console.log("waiting for image frame to load");
this.idleSince = Date.now();
return;
} }
} else if (this.currentBigImage.src !== this.previousBigImage && this.currentBigImage.naturalWidth !== 0) {
console.log("next big image appears loaded, will click right arrow next time");
this.state = "click-next-big-image";
this.previousBigImage = this.currentBigImage.src;
this.currentBigImage = null;
this.bigImagesLoaded++;
this.idleSince = null;
if (this.bigImagesLoaded >= this.imageCount) {
console.log("looks like we're done, we've loaded all " + this.bigImagesLoaded + " of " + this.imageCount + " big images");
this.state = "finished";
this.idleSince = Date.now();
}
return;
} else if(this.idleSince == null) {
console.log("Waiting for big image to load");
this.idleSince = Date.now();
return;
}
}
if (this.state === "click-next-big-image") {
var rightArrow = document.querySelectorAll("a.mmRightArrow");
if (rightArrow.length > 0) {
// console.log("clicking right arrow");
rightArrow[0].click();
this.state = "waiting-big-image";
this.idleSince = null;
return;
} else { } else {
console.warn("no right arrow to click?? weird"); console.log("looks like we're done, we've loaded all " + this.bigImagesLoaded + " of " + this.imageCount + " big images");
this.state = "finished";
this.idleSince = Date.now(); this.idleSince = Date.now();
return;
} }
return;
} }
}, },
start: function() { start: function() {
var that = this; var that = this;
this.intervalId = setInterval(function(){ that.intervalFunc() }, 50); this.intervalId = setInterval(function(){ that.intervalFunc() }, 300);
}, },
isFinished: function() { isFinished: function() {