Home > Software design >  Extract Google Slide numbers in presenter view from div which requires dropdown to be open before th
Extract Google Slide numbers in presenter view from div which requires dropdown to be open before th

Time:11-13

I would like to extract the Slide numbers from Google Slide Presenter View.

They all get listed under goog-menuitem-checkbox but only when once clicked on the slide selection dropdown.

Is there any way I could trigger this with javascript to already load them so i can extract them?

Drop down when presenter view is loaded

<div  role="listbox" aria-expanded="false" tabindex="0" aria-haspopup="true" aria-activedescendant=":2p" style="user-select: none;"><div  id=":2p" role="option" aria-selected="true" aria-setsize="19" aria-posinset="1">Slide 1 </div><div  aria-hidden="true">&nbsp;</div></div>

Dropdown when clicked/opened

<div  role="listbox" aria-expanded="false" tabindex="0" aria-haspopup="true" style="user-select: none;" aria-activedescendant=":2p"><div  id=":2p" role="option" aria-selected="true" aria-setsize="19" aria-posinset="1">Slide 1 </div><div  aria-hidden="true">&nbsp;</div></div>

console.log(document.getElementsByClassName('goog-menuitem-checkbox')[0].nextSibling.data); 

CodePudding user response:

Well it's interesting that I came across this exact problem while trying to extract published google slides, so I can share what I used.

You don't actually need to trigger open the slide selection menu, the html of the div itself has two attributes for the same:

  • aria-posinset : For Current Slide Index
  • aria-setsize : For Total Slides count in the presentation

Reading it something like this should get you what you need:

document.querySelectorAll('[class$="-caption"]')[0].getAttribute("aria-setsize")
  • Related