Google Presenter(在全屏窗口模式下)提供了一个下拉菜单来选择Slides,它只在第一次打开时填充div goog-menu goog-menu-vertical
。
是否有任何方法可以找出Google从何处提取此信息,我是否可以访问幻灯片标题,而不必触发鼠标按下事件来模拟打开/关闭操作?
否则,我能看到的唯一解决方案是通过javascript打开和关闭它,也许先隐藏它,这样操作就看不见了,但如果可能的话,我更喜欢直接访问数据。如何最好地检查开发控制台?
我想从goog-menu-vertical
div类中包含的.goog-menuitem-content
中提取textContent
(仅在打开select后可用)。
这里是HTML代码,虽然不确定这是否真的重要,因为我希望这是JS和其他一些来源,它必须从拉,因为我找不到HTML本身的内容。
<div id="punch-viewer-speakernotes">
<table class="punch-viewer-speakernotes punch-viewer-client-rendered-notes">
<tbody>
<tr>
<td class="punch-viewer-speakernotes-side-panel" style="width: 331px;">
<div class="punch-viewer-speakernotes-timer-panel">
<div class="punch-viewer-speakernotes-timer-main-container">
<div class="punch-viewer-speakernotes-timer-time-container" style="">
<div class="punch-viewer-speakernotes-timer-time">00:00:25</div>
</div>
<div class="punch-viewer-speakernotes-timer-button-container">
<div role="button" class="jfk-button jfk-button-standard punch-viewer-speakernotes-timer-button" tabindex="0" title="Pause timer" value="undefined" style="user-select: none; width: 54px;"><span class="jfk-button-label">Pause</span></div>
<div role="button" class="jfk-button jfk-button-standard punch-viewer-speakernotes-timer-button" tabindex="0" title="Reset timer (R)" value="undefined" style="user-select: none; width: 54px;"><span class="jfk-button-label">Reset</span></div>
</div>
</div>
</div>
<div class="punch-viewer-speakernotes-page-control-panel">
<div class="punch-viewer-speakernotes-page-control">
<div class="goog-inline-block goog-flat-menu-button jfk-select" role="listbox" aria-expanded="false" tabindex="0" aria-haspopup="true" aria-activedescendant=":39" style="user-select: none;">
<div class="goog-inline-block goog-flat-menu-button-caption" id=":39" role="option" aria-selected="true" aria-setsize="29" aria-posinset="5">Slide 5 </div>
<div class="goog-inline-block goog-flat-menu-button-dropdown" aria-hidden="true"> </div>
</div>
<div class="punch-viewer-speakernotes-page-container" style="width: 291px; height: 164px;">
<div class="punch-viewer-speakernotes-page" style="width: 291px; height: 164px;">
<div class="punch-viewer-loadstatus" style="display: none;">
<div class="punch-viewer-center punch-viewer-center-browser-modern punch-viewer-center-boxtype-all">
<div class="punch-viewer-center-content-container"><span class="punch-viewer-center-centering"></span>
<div class="punch-viewer-loadstatus-content goog-inline-block punch-viewer-center-content">
<div class="" style="display: none;"></div>
<div class="" style="display: none;"></div>
<div class="" style="display: none;"></div>
<div><span tabindex="0" class="punch-viewer-loadstatus-link" style="display: none;"></span><span tabindex="0" class="punch-viewer-loadstatus-link" style="display: none;"></span></div>
</div>
</div>
</div>
</div><svg xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" version="1.1" fill-rule="evenodd" fill="none" stroke="none" stroke-linecap="square" stroke-miterlimit="10" overflow="hidden" preserveAspectRatio="none" width="100%" height="100%" viewBox="0 0 365760 205740" style="line-height: normal; width: 291px; height: 164px;">
<rect fill="#ffffff" fill-opacity="0" width="100%" height="100%"></rect>
<g transform="translate(0 0) scale(1)">
<defs cursor="default"></defs>
<g>
<path fill="#fff" fill-opacity="1" d="M 0 0 L 365760 0 365760 205740 0 205740 Z"></path>
<g id="g1e02d4ec510_1_0-bg">
<g>
<g>
<path fill="#FF9900" fill-opacity="1" d="M 0 0 L 365760 0 365760 205740 0 205740 Z"></path>
</g>
</g>
</g>
<g id="g1e02d4ec510_1_1">
<g>
<g>
<path d="M 2041 0 L 367801 0 367801 205740 2041 205740 Z"></path>
</g>
<g>
<g direction="ltr">
<g transform="matrix(380.99999999999994,0,0,380.99999999999994,5698,75438)">
<g pointer-events="none">
<g id="g1e02d4ec510_1_1-paragraph-0">
<g>
<g class="sketchy-text-background" visibility="visible"></g>
<g></g>
<g class="sketchy-text-content" visibility="visible">
<g class="sketchy-text-content-text" transform="translate(0 115.19999999999999)"><text style="font-family:Arial;font-size:120px;fill:#595959;white-space:pre;" text-rendering="geometricPrecision" x="437.02657480314963">4</text></g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</g>
</svg>
</div>
</div>
<div role="button" tabindex="0" class="punch-viewer-speakernotes-page-previous" style="width: 131px; border-width: 1px;"><iframe class="punch-viewer-speakernotes-page-iframe" frameborder="0" tabindex="-1" style="width: 129px; height: 73px;"></iframe>
<div class="punch-viewer-speakernotes-page-caption">Previous</div>
</div>
<div role="button" tabindex="0" class="punch-viewer-speakernotes-page-next" style="width: 131px; border-width: 1px;"><iframe class="punch-viewer-speakernotes-page-iframe" frameborder="0" tabindex="-1" style="width: 129px; height: 73px;"></iframe>
<div class="punch-viewer-speakernotes-page-caption">Next</div>
</div>
</div>
</div>
</td>
<td class="punch-viewer-speakernotes-main-panel punch-viewer-speakernotes-qanda">
<div class="goog-tab-bar goog-tab-bar-horizontal goog-tab-bar-top" role="tablist" style="user-select: none;">
<div class="goog-tab" role="tab" aria-selected="false" tabindex="0" id=":2a" style="user-select: none;">Audience tools<div aria-live="polite" role="status">
<div class="docs-offscreen-z-index"></div>
<div class="punch-viewer-speaker-questions-badge" style="display: none;"></div>
</div>
</div>
<div class="goog-tab goog-tab-selected" role="tab" aria-selected="true" tabindex="0" id=":2b" style="user-select: none;">Speaker notes</div>
</div>
<div class="punch-viewer-speakernotes-base" role="tabpanel">
<div class="punch-viewer-speakernotes-text-header-container">
<h3 class="punch-viewer-speakernotes-text-header">Slide 5 of 29</h3>
<div class="punch-viewer-speakernotes-zoom-container">
<div role="button" class="goog-inline-block jfk-button jfk-button-standard jfk-button-narrow jfk-button-collapse-right" tabindex="0" title="Zoom out" value="undefined" style="user-select: none;">
<div class="punch-viewer-speakernotes-zoom-minus punch-viewer-speakernotes-zoom-button jfk-button-img punch-viewer-icon-large"></div>
</div>
<div role="button" class="goog-inline-block jfk-button jfk-button-standard jfk-button-narrow jfk-button-collapse-left" tabindex="0" title="Zoom in" value="undefined" style="user-select: none;">
<div class="punch-viewer-speakernotes-zoom-plus punch-viewer-speakernotes-zoom-button jfk-button-img punch-viewer-icon-large"></div>
</div>
</div>
</div>
<div class="punch-viewer-speakernotes-text-body-scrollable" style="left: 331.885px;">
<div class="punch-viewer-speakernotes-text-body">
<div class="punch-viewer-speakernotes-text-body-zoomable">
<p dir="ltr" style="line-height:1.2;margin-top:0pt;margin-bottom:0pt;"><span style="font-size:11pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">Speaker notes </span><span style="font-size:10pt;font-family:Arial;color:#000000;background-color:transparent;font-weight:400;font-style:normal;font-variant:normal;text-decoration:none;vertical-align:baseline;white-space:pre;white-space:pre-wrap;">[Slide 00:00:50][Chapter 00:01:00][Presentation 00:02:45]</span></p><br>
</div>
</div>
</div>
</div>
<div style="display: none; left: 331.885px;" class="punch-viewer-speaker-qanda-content">
<div class="punch-viewer-speaker-series-intro-container punch-viewer-speaker-series-intro-onboard-step2" tabindex="-1" role="tabpanel">
<div class="punch-viewer-speaker-series-intro-onboard-container">
<div class="punch-viewer-speaker-series-intro-onboard-card punch-viewer-speaker-series-intro-onboard-card0" aria-hidden="true">
<div class="punch-viewer-speaker-series-intro-image"><img alt="" src="//ssl.gstatic.com/docs/presentations/images/qanda_onboard_1_v2.png"></div>
<div class="punch-viewer-speaker-series-intro-header">Audience Q&A</div>
</div>
<div class="punch-viewer-speaker-series-intro-onboard-card punch-viewer-speaker-series-intro-onboard-card1" aria-hidden="true">
<div class="punch-viewer-speaker-series-intro-image"><img alt="" src="//ssl.gstatic.com/docs/presentations/images/qanda_onboard_2_v2.png"></div>
<div class="punch-viewer-speaker-series-intro-header">Just click to present</div>
</div>
<div class="punch-viewer-speaker-series-intro-onboard-card punch-viewer-speaker-series-intro-onboard-card2" aria-hidden="false">
<div class="punch-viewer-speaker-series-intro-image"><img alt="" src="//ssl.gstatic.com/docs/presentations/images/qanda_onboard_3_v2.png"></div>
<div class="punch-viewer-speaker-series-intro-header">Answer all the right questions</div>
</div>
</div>
<div class="punch-viewer-speaker-series-intro-buttons">
<div role="button" class="goog-inline-block jfk-button jfk-button-standard" aria-hidden="true" style="user-select: none; display: none;">Continue recent</div>
<div role="button" class="goog-inline-block jfk-button jfk-button-standard" tabindex="0" value="undefined" style="user-select: none;">Start new</div>
</div>
</div>
<div class="punch-viewer-speaker-series-list-container" tabindex="-1" role="tabpanel" style="display: none;">
<div class="punch-viewer-speaker-series-list-header">
<div class="punch-viewer-speaker-series-list-exit goog-flat-button goog-inline-block" aria-label="Back" role="button" tabindex="0">
<div class="goog-flat-button-outer-box goog-inline-block">
<div class="goog-flat-button-inner-box goog-inline-block">
<div class="docs-icon goog-inline-block ">
<div class="docs-icon-img-container docs-icon-img docs-icon-arrow-back-dark" aria-hidden="true"> </div>
</div>
</div>
</div>
</div>Choose a session
</div>
<div class="punch-viewer-speaker-series-list"></div>
</div>
<div class="punch-viewer-speaker-series-container" tabindex="-1" role="tabpanel" style="display: none;">
<h1 class="punch-viewer-speaker-series">
<div aria-live="polite" role="status">
<div class="punch-viewer-speaker-series-status"></div>
<div class="punch-viewer-speaker-series-domain">
<div class="goog-inline-block goog-flat-menu-button jfk-select" role="listbox" aria-expanded="false" tabindex="0" aria-haspopup="false" aria-activedescendant=":38" style="user-select: none;">
<div class="goog-inline-block goog-flat-menu-button-caption" id=":38" role="option" aria-selected="true">Select an audience</div>
<div class="goog-inline-block goog-flat-menu-button-dropdown" aria-hidden="true"> </div>
</div>
</div>
</div>
<div class="punch-viewer-speaker-series-domain-notice">Includes whitelisted domains</div>
<div class="punch-viewer-speaker-series-checkbox">
<div class="jfk-slideToggle goog-inline-block" role="button" aria-disabled="true" aria-pressed="false" style="user-select: none;">
<div class="jfk-slideToggle-on">on</div>
<div class="jfk-slideToggle-off">off</div>
<div class="jfk-slideToggle-thumb"></div>
</div>
</div>
<div class="punch-viewer-speaker-series-url"></div>
</h1>
<div class="punch-viewer-speaker-questions" style="display: none"></div>
<div class="punch-viewer-speaker-empty-questions">
<div class="punch-viewer-speaker-empty-questions-image"><img alt="" src="//ssl.gstatic.com/docs/presentations/images/qanda_empty_v2.png"></div>
<div class="punch-viewer-speaker-empty-questions-header">Questions appear here</div>
</div>
<div class="punch-viewer-speaker-questions-a11y docs-offscreen-z-index" aria-live="polite" role="status"></div>
</div>
<div class="docs-ui-toast" role="complementary" tabindex="0" aria-describedby=":27.d-u-t-c" style="display: none;">
<div class="docs-ui-toast-content" id=":27.d-u-t-c">New top questions</div>
<div class="docs-ui-toast-control-bar" id=":27.d-u-t-cb">
<div class="docs-ui-toast-control punch-qanda-toast-action-label" role="button" tabindex="0" id="punch-qanda-toast-show">Show</div>
</div>
</div>
<div class="punch-viewer-speaker-qanda-not-available" style="display: none;">
<div class="punch-viewer-speaker-qanda-not-available-title">You need permission</div>
<div class="punch-viewer-speaker-qanda-not-available-text">You can only view this presentation. To accept audience questions, ask the owner for comment or edit access.</div>
</div>
</div>
</td>
</tr>
</tbody>
</table>
<div class="punch-viewer-speakernotes-dragger" style="left: 326px;">
<div class="punch-viewer-speakernotes-dragger-icon"></div>
</div>
</div>
初始负载时缺失的Div是<div class="goog-menu goog-menu-vertical" role="listbox" aria-haspopup="true" style="user-select: none; visibility: visible; overflow-y: auto; height: 628px; left: 17.9861px; top: 0px; box-sizing: border-box; width: 898px; display: none;">
,位于<div class="docs-loading-indicator"
下方的最底部
我已经尝试过迭代div类,但是由于它没有在开始时加载,所以显然不会工作。
//$('.jfk-select').dispatchEvent(new MouseEvent('mousedown'));
//$('.jfk-select').dispatchEvent(new MouseEvent('mousedown'));
document.querySelectorAll('.goog-menuitem-content').forEach(function(text) {
console.log(text);
console.log(text.innerHTML);
});
1条答案
按热度按时间smtd7mpg1#
我在这里使用了一个带有click事件的按钮来添加新元素,但是您可以(应该?)使用一个mutation observer来监听DOM更改,如下所示:Determining if a HTML element has been added to the DOM dynamically参考:https://developer.mozilla.org/en-US/docs/Web/API/MutationObserver
所以我添加了点击按钮的元素,然后启动了在变异观察器中添加事件处理程序(可能需要您的设置)的方法;
超级冗长和大量的日志记录,但应该告诉你如何开始在这里。
注意:由于新元素在添加时会隐藏,所以我只是简单地记录了这些元素以显示它们的存在。