本文整理汇总了TypeScript中element-ready.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: sendConversationList
async function sendConversationList(): Promise<void> {
const conversations: Conversation[] = await Promise.all(
([...(await elementReady(listSelector)).children] as HTMLElement[])
.splice(0, 10)
.map(async (el: HTMLElement) => {
const profilePic = el.querySelector<HTMLImageElement>('._55lt img');
const groupPic = el.querySelector<HTMLImageElement>('._4ld- div');
// This is only for group chats
if (groupPic) {
// Slice image source from background-image style property of div
const bgImage = groupPic.style.backgroundImage!;
groupPic.src = bgImage.slice(5, bgImage.length - 2);
}
const isConversationMuted = el.classList.contains('_569x');
return {
label: el.querySelector<HTMLElement>('._1ht6')!.textContent!,
selected: el.classList.contains('_1ht2'),
unread: el.classList.contains('_1ht3') && !isConversationMuted,
icon: await getDataUrlFromImg(
profilePic ? profilePic : groupPic!,
el.classList.contains('_1ht3')
)
};
})
);
ipc.send('conversations', conversations);
}
示例2: selectConversation
// Focus on the conversation with the given index
async function selectConversation(index: number): Promise<void> {
const conversationElement = (await elementReady(listSelector)).children[index];
if (conversationElement) {
(conversationElement.firstChild!.firstChild as HTMLElement).click();
}
}
示例3: sendReply
async function sendReply(message: string): Promise<void> {
const inputField = document.querySelector<HTMLElement>('[contenteditable="true"]');
if (inputField) {
const previousMessage = inputField.textContent;
// Send message
inputField.focus();
insertMessageText(message, inputField);
(await elementReady<HTMLElement>('._30yy._38lh')).click();
// Restore (possible) previous message
if (previousMessage) {
insertMessageText(previousMessage, inputField);
}
}
}
示例4: elementReady
selectors.forEach(async selector => {
try {
const buttonReady = elementReady(`body.xE .G-atb .${selector}`)
const readyTimeout = setTimeout(() => {
buttonReady.cancel(`Detect button "${selector}" timed out`)
}, 10000)
const button = await buttonReady
clearTimeout(readyTimeout)
button.addEventListener('click', () => window.close())
} catch (error) {
log.error(error)
}
})
示例5:
(async () => {
const startCallButton = await elementReady<HTMLElement>('._3quh._30yy._2t_');
startCallButton.click();
})();
示例6: withSettingsMenu
async function withSettingsMenu(callback: () => Promise<void> | void): Promise<void> {
await withMenu(await elementReady<HTMLElement>('._30yy._2fug._p'), callback);
}