|
@@ -673,7 +673,13 @@ export function findTweetByIdDoTask({ tweet_Id = '', follow_names = [] }, task_t
|
|
|
}
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+function clickByDataTestId(e, id, callback) {
|
|
|
+ if (e.target.dataset && e.target.dataset.testid && e.target.dataset.testid == id) {
|
|
|
+ callback()
|
|
|
+ } else if (e.target.closest('div[data-testid=' + id + ']')) {
|
|
|
+ callback()
|
|
|
+ }
|
|
|
+}
|
|
|
|
|
|
// 校验关注推特状态
|
|
|
export function checkTwitterTaskState() {
|
|
@@ -696,49 +702,46 @@ export function checkTwitterTaskState() {
|
|
|
}
|
|
|
tweet_Id = getQueryString('tweet_id')
|
|
|
|
|
|
- // 获取关注名字 获取推特Id
|
|
|
- let confirm_btn = document.querySelector('div[data-testid=confirmationSheetConfirm]')
|
|
|
- let confirm_btn_status
|
|
|
- let cancel_btn = document.querySelector('div[data-testid=confirmationSheetCancel]')
|
|
|
- let cancel_btn_status
|
|
|
-
|
|
|
- // let page_follow_btn = document.querySelector('div[aria-describedby]')
|
|
|
- // let page_follow_btn_status
|
|
|
-
|
|
|
- let observer = new MutationObserver(() => {
|
|
|
- if (confirm_btn && !confirm_btn_status) {
|
|
|
- confirm_btn_status = true
|
|
|
- confirm_btn.onclick = (e) => {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data ,task_done:true}, () => { })
|
|
|
- }
|
|
|
- } else {
|
|
|
- confirm_btn = document.querySelector('div[data-testid=confirmationSheetConfirm]')
|
|
|
- }
|
|
|
- if(cancel_btn && !cancel_btn_status){
|
|
|
- cancel_btn_status= true
|
|
|
- cancel_btn.onclick = (e) => {
|
|
|
- chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data ,task_done:false}, () => { })
|
|
|
- }
|
|
|
- }else{
|
|
|
- cancel_btn = document.querySelector('div[data-testid=confirmationSheetCancel]')
|
|
|
+ // let root_status
|
|
|
+ document.body.addEventListener('click', (e) => {
|
|
|
+ // 点击 确认
|
|
|
+ clickByDataTestId(e, 'confirmationSheetConfirm', () => {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: true }, () => { })
|
|
|
+ })
|
|
|
+ // 点击取消
|
|
|
+ clickByDataTestId(e, 'confirmationSheetCancel', () => {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: false }, () => { })
|
|
|
+ })
|
|
|
+ // 点击 蒙层
|
|
|
+ if (e.target && e.target.nextSibling && e.target.nextSibling.dataset && e.target.nextSibling.dataset.testid == 'confirmationSheetDialog') {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: false }, () => { })
|
|
|
}
|
|
|
- // if (page_follow_btn && page_follow_btn.dataset && page_follow_btn.dataset.testid && !page_follow_btn_status) {
|
|
|
- // page_follow_btn_status = true
|
|
|
- // if (page_follow_btn.dataset.testid.includes('unfollow')) {
|
|
|
- // // 发送
|
|
|
- // chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id }, () => { })
|
|
|
- // }
|
|
|
- // } else {
|
|
|
- // page_follow_btn = document.querySelector('div[aria-describedby]')
|
|
|
- // }
|
|
|
+ }, true)
|
|
|
|
|
|
- if (confirm_btn_status && cancel_btn_status) {
|
|
|
- observer.disconnect()
|
|
|
+ let timer = setInterval(() => {
|
|
|
+ // 喜欢
|
|
|
+ if (document.querySelector('div[data-testid=unlike]') && task_type == 'like') {
|
|
|
+ clearInterval(timer)
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: true }, () => { })
|
|
|
}
|
|
|
- });
|
|
|
- observer.observe(document.body, { attributes: false, childList: true, subtree: true });
|
|
|
-
|
|
|
- // 打开iframe
|
|
|
- // 点击操作
|
|
|
- // 删除iframe
|
|
|
+ // 转推
|
|
|
+ if (document.querySelector('div[data-testid=unretweet]') && task_type == 'retweet') {
|
|
|
+ clearInterval(timer)
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: true }, () => { })
|
|
|
+ }
|
|
|
+ // 关注
|
|
|
+ if (task_type == 'follow') {
|
|
|
+ let follow_area = document.querySelector('div[data-testid=placementTracking]')
|
|
|
+ if (follow_area && follow_area.querySelectorAll('div')) {
|
|
|
+ follow_area = follow_area.querySelectorAll('div')
|
|
|
+ clearInterval(timer)
|
|
|
+ for (let i in follow_area) {
|
|
|
+ if (follow_area[i] && follow_area[i].dataset && follow_area[i].dataset.testid && follow_area[i].dataset.testid.indexOf('unfollow') > 0) {
|
|
|
+ chrome.runtime.sendMessage({ actionType: "DO_TASK", tweet_Id, task_type, task_data, task_done: true }, () => { })
|
|
|
+ break
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }, 1000)
|
|
|
}
|