
// 根据提示dom 跳转到推文详情页面
export const jumpTwitterDetailByAlert = () => {
    let num = 10
    let timer = setInterval(() => {
        if (num <= 0) {
            clearInterval(timer)
            return
        }
        let alert = document.querySelector('div[role=alert]')
        if (alert) {
            let a = alert.querySelector('a')
            if (a) {
                clearInterval(timer)
                a.click()
            }
        }
        num--
    }, 500)
}

export const showEditTweet = (callback) => {
    let bigBtn = document.querySelector('a[data-testid="SideNav_NewTweet_Button"]');
    if (bigBtn) {
        bigBtn.click();
    } else {
        let smallBtn = document.querySelector('a[href="/compose/tweet"]')
        smallBtn && smallBtn.click();
    }
    let num = 10
    let timer = setInterval(() => {
        if(num <= 0){
            clearInterval(timer)
            return
        }
        let inputEle = document.querySelector('div[contenteditable="true"]');
        if(inputEle){
            clearInterval(timer)
            callback && callback()
        }
        num-- 
    }, 500);
}