當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript element-ready.default函數代碼示例

本文整理匯總了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);
}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:31,代碼來源:browser.ts

示例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();
	}
}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:8,代碼來源:browser.ts

示例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);
		}
	}
}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:15,代碼來源:browser.ts

示例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)
    }
  })
開發者ID:,項目名稱:,代碼行數:16,代碼來源:

示例5:

(async () => {
	const startCallButton = await elementReady<HTMLElement>('._3quh._30yy._2t_');
	startCallButton.click();
})();
開發者ID:kusamakura,項目名稱:caprine,代碼行數:4,代碼來源:browser-call.ts

示例6: withSettingsMenu

async function withSettingsMenu(callback: () => Promise<void> | void): Promise<void> {
	await withMenu(await elementReady<HTMLElement>('._30yy._2fug._p'), callback);
}
開發者ID:kusamakura,項目名稱:caprine,代碼行數:3,代碼來源:browser.ts


注:本文中的element-ready.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。