| | |
| | | import android.app.Instrumentation |
| | | import android.os.SystemClock |
| | | import android.os.Handler |
| | | import android.util.Log |
| | | import com.shsening.autouploadvideos.UploadSessionActivity |
| | | import com.shsening.autouploadvideos.utils.Utils |
| | | import com.shsening.autouploadvideos.WebviewUtils |
| | |
| | | |
| | | |
| | | private var webView = activity.sessionProfileWebView |
| | | private var TAG = "ActionDouyin" |
| | | |
| | | |
| | | var jsCode_CheckContentLoaded = """ |
| | |
| | | |
| | | |
| | | private fun updatePostDescription(){ |
| | | WebviewUtils.addValueToInput( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div.editor-container-zRPSAi > div > div > div > div:nth-child(1) > div > div > input", |
| | | videoInfo.title |
| | | ) |
| | | WebviewUtils.addValueToInput(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div.editor-container-zRPSAi > div > div > div > div:nth-child(1) > div > div > input",videoInfo.title) |
| | | |
| | | WebviewUtils.addValueToDiv( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div.editor-container-zRPSAi > div > div > div > div.outerdocbody.editor-kit-outer-container > div", |
| | | videoInfo.description |
| | | ) |
| | | WebviewUtils.addValueToDiv(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div.editor-container-zRPSAi > div > div > div > div.outerdocbody.editor-kit-outer-container > div",videoInfo.description) |
| | | |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div:nth-child(3) > div > div.activity-list-container-AZzfdV > div:nth-child(1)" |
| | | ) |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div:nth-child(3) > div > div.activity-list-container-AZzfdV > div:nth-child(2)" |
| | | ) |
| | | WebviewUtils.simpleElementClick(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div:nth-child(3) > div > div.activity-list-container-AZzfdV > div:nth-child(1)") |
| | | WebviewUtils.simpleElementClick(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-mention-wrapper-LWv5ed > div:nth-child(3) > div > div.activity-list-container-AZzfdV > div:nth-child(2)") |
| | | |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.content-upload-new > div > div.recommendContainer-HXvL9W > div.recommendDisplay-ifUYki > div > div:nth-child(1) > div" |
| | | ) |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.download-content-Lci5tL > div > label:nth-child(2)" |
| | | ) |
| | | WebviewUtils.simpleElementClick( |
| | | webView, |
| | | "#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-settings-WtW_ZW > div.schedule-part-V615Zn > div.row-suTOx_ > label:nth-child(2)" |
| | | ) |
| | | WebviewUtils.simpleElementClick(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.content-upload-new > div > div.recommendContainer-HXvL9W > div.recommendDisplay-ifUYki > div > div:nth-child(1) > div") |
| | | WebviewUtils.simpleElementClick(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.download-content-Lci5tL > div > label:nth-child(2)") |
| | | WebviewUtils.simpleElementClick(webView,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-settings-WtW_ZW > div.schedule-part-V615Zn > div.row-suTOx_ > label:nth-child(2)") |
| | | |
| | | addValueToDatePickerInput(true,"#root > div > div > div.content-body-v8tuJQ > div.form-kSES6A > div.publish-settings-WtW_ZW > div.schedule-part-V615Zn > div.row-suTOx_ > div.date-picker-ioPchj > div > div",videoInfo.datetime) |
| | | |
| | |
| | | webView.postDelayed({ |
| | | webView.evaluateJavascript(jsCode_PublishVideo_Finished) { result -> |
| | | if (result == "true") { |
| | | |
| | | // video published successfully!!! |
| | | activity.checkAndStartNextTask() |
| | | |
| | | |
| | | } else { |
| | | // 元素不存在,1秒后再次检查 |
| | | webView.postDelayed({ |
| | |
| | | // need time to popup date-picker |
| | | setTimeout(() => { |
| | | var dpPanel = document.querySelector('.semi-popover-content'); |
| | | var dpPanelSpan = dpPanel.querySelector('div > div > div > div:nth-child(1) > div.semi-datepicker-navigation > div > button > span > span'); |
| | | var dpPanelSpan = document.querySelectorAll(".semi-datepicker")[1].querySelector(".semi-datepicker-navigation-month"); |
| | | if (dpPanelSpan && dpPanelSpan.textContent != '${dpPanelText}'){ |
| | | dpPanel.querySelector('div > div > div > div > div:nth-child(1) > div.semi-datepicker-navigation > button:nth-child(3)').click(); |
| | | document.querySelectorAll(".semi-datepicker")[1].querySelectorAll(".semi-button-content")[2].click(); |
| | | } |
| | | dpPanel.querySelector('div > div > div > div > div:nth-child(1) > div.semi-datepicker-month > div.semi-datepicker-weeks > div:nth-child(${dateRowColum[0]}) > div:nth-child(${dateRowColum[1]})').click() |
| | | document.querySelectorAll(".semi-datepicker-month")[0].querySelectorAll(".semi-datepicker-weeks")[0].querySelector("div:nth-child(${dateRowColum[0]}) > div:nth-child(${dateRowColum[1]})").click(); |
| | | |
| | | //switch to time selection |
| | | dpPanel.querySelector('div > div > div > div > div.semi-datepicker-switch > div.semi-datepicker-switch-time').click(); |
| | | document.querySelectorAll(".semi-datepicker-switch-time")[0].click() |
| | | setTimeout(() => { |
| | | dpPanel.querySelector('div > div > div > div.semi-datepicker-tpk > div > div > div.semi-scrolllist-body > div.semi-scrolllist-item-wheel.undefined-list-hour > div.semi-scrolllist-list-outer > ul > li:nth-child(${(datetimes[3]+1)})').click(); |
| | | dpPanel.querySelector('div > div > div > div.semi-datepicker-tpk > div > div > div.semi-scrolllist-body > div.semi-scrolllist-item-wheel.undefined-list-minute > div.semi-scrolllist-list-outer > ul > li:nth-child(${(datetimes[4]+1)})').click(); |
| | | document.querySelectorAll('.semi-scrolllist-body')[0].querySelectorAll('.semi-scrolllist-item-wheel')[0].querySelector('div.semi-scrolllist-list-outer > ul > li:nth-child(${(datetimes[3]+1)})').click(); |
| | | document.querySelectorAll('.semi-scrolllist-body')[0].querySelectorAll('.semi-scrolllist-item-wheel')[1].querySelector('div.semi-scrolllist-list-outer > ul > li:nth-child(${(datetimes[4]+1)})').click(); |
| | | }, 500); |
| | | }, 500); |
| | | } catch (error) { |
| | |
| | | val y = height / 3f // Y 坐标在屏幕中间 |
| | | |
| | | Thread { |
| | | try { |
| | | Utils.instrumentationSwipe(instrumentation, startX, y, endX, y) |
| | | SystemClock.sleep(500) |
| | | Utils.instrumentationSwipe(instrumentation, startX, y, endX, y) |
| | | SystemClock.sleep(500) |
| | | Utils.instrumentationClick(instrumentation, width / 2f, height * 2 / 4f) |
| | | Utils.instrumentationClick(instrumentation, width / 2f, height * 2 / 3f) |
| | | // back to main thread |
| | | |
| | | } catch (e: Exception) { |
| | | Log.e(TAG, "滑动操作失败:应用可能在后台", e) |
| | | } |
| | | threadHandler.post { |
| | | checkVideoUploadFinished() |
| | | } |