-
-
Save shreevatsa/c5677d91884b323ad2d5 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Newer version: clicks on right slider buttons and waits before looking for new ones | |
function print_new() { | |
var known = ["Z71EAAAAcAAJ", "Y78IAAAAQAAJ", "cL1EAAAAcAAJ", "g78IAAAAQAAJ", "OSgJAAAAQAAJ", "0b8IAAAAQAAJ", "878IAAAAQAAJ", "ESgJAAAAQAAJ", "Sr8IAAAAQAAJ", "JigJAAAAQAAJ", "eL1EAAAAcAAJ", "m78IAAAAQAAJ", "WygJAAAAQAAJ", "g71EAAAAcAAJ", "vr8IAAAAQAAJ", "eCgJAAAAQAAJ", "24dSAAAAcAAJ", "nigJAAAAQAAJ", "5YdSAAAAcAAJ", "uCgJAAAAQAAJ", "TrZUAAAAcAAJ", "6ygJAAAAQAAJ", "KMAIAAAAQAAJ", "ASkJAAAAQAAJ", "ICkJAAAAQAAJ", "CcAIAAAAQAAJ", "jHxFAQAAIAAJ", "A_lSAAAAYAAJ", "M31FAQAAIAAJ", "ZQspAAAAYAAJ", "rgspAAAAYAAJ", "EA0pAAAAYAAJ", "Pn5FAQAAIAAJ", "XA0pAAAAYAAJ", "zSkJAAAAQAAJ", "vQ0pAAAAYAAJ", "FQ4pAAAAYAAJ", "JwopAAAAYAAJ", "fQ4pAAAAYAAJ", "gAopAAAAYAAJ", "2wopAAAAYAAJ", "LwspAAAAYAAJ", "pAspAAAAYAAJ", "BAwpAAAAYAAJ", "UwwpAAAAYAAJ", "1wwpAAAAYAAJ", "1g0pAAAAYAAJ", "Xg4pAAAAYAAJ", "MhApAAAAYAAJ", "4w4pAAAAYAAJ", "Tw8pAAAAYAAJ", "vw8pAAAAYAAJ", "iBApAAAAYAAJ", "bQ0pAAAAYAAJ", "Bv1SAAAAYAAJ", "gzoJAAAAQAAJ", "jikJAAAAQAAJ", "Oi8JAAAAQAAJ", "iBNAAQAAMAAJ", "w31FAQAAIAAJ", "3X5FAQAAIAAJ", "wdc9AQAAMAAJ", "JAspAAAAYAAJ", "LNA9AQAAMAAJ", "ctA9AQAAMAAJ", "3dA9AQAAMAAJ", "a9E9AQAAMAAJ", "N9E9AQAAMAAJ"]; | |
neigh = document.getElementsByClassName("slider-link goog-inline-block"); | |
var ignored = 0; | |
for (var i = 0; i < neigh.length; ++i) { | |
var n = neigh[i]; | |
var seen = -1; | |
if (n.search.substr(0, 4) == '?id=') { | |
var book_id = n.search.substr(4, n.search.indexOf('&') - 4); | |
seen = known.indexOf(book_id); | |
} | |
if (seen !== -1) { | |
// console.log("Ignoring " + n.href + " which occurs at " + seen); | |
ignored += 1; | |
} else { | |
console.log(n.href + " " + n.nextSibling.innerText.split("\n").join(" -- ")); | |
} | |
} | |
console.log("Ignored " + ignored); | |
} | |
// Click the button, wait a while, and call cb | |
function clickButton(button, cb) { | |
// console.log(button.classList + " clicking right"); | |
button.click(); | |
setTimeout(cb, 1000); | |
} | |
// After clicking all buttons, call cb | |
function clickFirstScrollableButtonOrDoNext(buttons, cb) { | |
var good_button; | |
while (buttons.length > 0 && good_button === undefined) { | |
button = buttons[0]; | |
if (button.classList.contains("slider-button-disabled")) { | |
// console.log("Done clicking this button."); | |
buttons.shift(); | |
} else { | |
good_button = button; | |
} | |
} | |
if (good_button) { | |
clickButton(button, function() { clickFirstScrollableButtonOrDoNext(buttons, cb); }); | |
} else { | |
// console.log("Done all clicking"); | |
cb(); | |
} | |
} | |
var scrollers_collection = document.getElementsByClassName("slider-button-right"); | |
var scrollers = [].slice.call(scrollers_collection); // Convert HTMLCollection to array | |
clickFirstScrollableButtonOrDoNext(scrollers, print_new); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment