Driving clicks (and downloads) via javascript console.

37 views
Skip to first unread message

विश्वासो वासुकिजः (Vishvas Vasuki)

unread,
Nov 10, 2017, 8:53:11 PM11/10/17
to sanskrit-programmers
shrI shrIvatsa pointed out that we can programmatically click links using the javascript console to do various things (such as downloading a bunch of files from pravachanam.com ). A snippet is below:

t = 0;
for (let w of document.getElementsByClassName('views-field views-field-nothing-1')) {
  if(w.tagName == 'TH') continue;
  console.log(w.children[0].textContent);
  setTimeout(() => { w.parentNode.querySelector('a[type]').click()}, t);
  t += 800;
}


​This is a neat trick!​ Prior to that I was putting off the formidable task of writing a chrome-driver-based-code.

--
--
Vishvas /विश्वासः

विश्वासो वासुकिजः (Vishvas Vasuki)

unread,
Nov 10, 2017, 8:55:51 PM11/10/17
to sanskrit-programmers
PS: You paste such code into javascript console (see https://developers.google.com/web/tools/chrome-devtools/console/ ) to run it on a given page.
Reply all
Reply to author
Forward
0 new messages