INNER CODE UNIT · TypeScript
withMenu
sindresorhus/caprine · source/browser.ts:11
async function withMenu(
menuButtonElement: HTMLElement,
callback: () => Promise<void> | void,
): Promise<void> {
const {classList} = document.documentElement;
// Prevent the dropdown menu from displaying
classList.add('hide-dropdowns');
// Click the menu button
menuButtonElement.click();
// Wait for the menu to close before removing the 'hide-dropdowns' class
await elementReady('.x78zum5.xdt5ytf.x1n2onr6.xat3117.xxzkxad > div:nth-child(2) > div', {stopOnDomReady: false});
const menuLayer = document.querySelector('.x78zum5.xdt5ytf.x1n2onr6.xat3117.xxzkxad > div:nth-child(2) > div');
if (menuLayer) {
const observer = new MutationObserver(() => {