本文整理匯總了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);
}