| | |
| | | package com.shsening.autouploadvideos |
| | | package com.shsening.autouploadvideos.action |
| | | |
| | | |
| | | import android.app.Instrumentation |
| | |
| | | import android.os.Bundle |
| | | import android.os.Looper |
| | | import androidx.appcompat.app.AppCompatActivity |
| | | import com.shsening.autouploadvideos.UploadSessionActivity |
| | | import com.shsening.autouploadvideos.WebviewUtils |
| | | import com.shsening.autouploadvideos.action.PlatformActionInterface |
| | | import com.shsening.autouploadvideos.utils.Utils |
| | | |
| | |
| | | private fun updatePostDescription(){ |
| | | WebviewUtils.addValueToInput(webView,"#publish-container > div > div.body > div.content > div.input.titleInput > div.d-input-wrapper.d-inline-block.c-input_inner > div > input",videoInfo.title) |
| | | WebviewUtils.addValueToDiv(webView,"#quillEditor > div > p",videoInfo.description) |
| | | WebviewUtils.simpleElementClick(webView,"#topicBtn") |
| | | SystemClock.sleep(500) |
| | | WebviewUtils.simpleElementClick(webView,"#quill-mention-item-0") |
| | | WebviewUtils.simpleElementClick(webView,"#topicBtn") |
| | | SystemClock.sleep(500) |
| | | WebviewUtils.simpleElementClick(webView,"#quill-mention-item-1") |
| | | |
| | | // WebviewUtils.simpleElementClick(webView,"#el-id-3410-26 > label:nth-child(1)") |
| | | WebviewUtils.simpleElementClick(webView,"html > body > div:nth-of-type(1) > div > div:nth-of-type(2) > div > div:nth-of-type(2) > main > div:nth-of-type(3) > div > div > div:nth-of-type(1) > div > div > div > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(10) > div > div:nth-of-type(5) > div:nth-of-type(2) > label:nth-of-type(2)") |
| | | addValueToDatePickerInput(true,"html > body > div:nth-of-type(1) > div > div:nth-of-type(2) > div > div:nth-of-type(2) > main > div:nth-of-type(3) > div > div > div:nth-of-type(1) > div > div > div > div:nth-of-type(2) > div:nth-of-type(1) > div:nth-of-type(1) > div:nth-of-type(10) > div > div:nth-of-type(5) > div:nth-of-type(2) > div > div:nth-of-type(1) > div",videoInfo.datetime) |
| | | // 在主线程中设置延迟执行 |
| | |
| | | webView.evaluateJavascript(jsCode_CheckVideoUploadFinished) { result -> |
| | | if (result == "true") { |
| | | // 等待视频检测和生成封面 |
| | | // WebviewUtils.simpleElementClick(webView,"#web > div > div > div > div.upload-content > div.upload-wrapper > div > input") |
| | | println("33333333333333333333333333333333333333") |
| | | threadHandler.postDelayed({updatePostDescription()},3000) |
| | | |
| | | } else { |
| | | println("11111111111111111111111") |
| | | // 元素不存在,1秒后再次检查 |
| | | webView.postDelayed({ |
| | | checkVideoUploadFinished() |
| | |
| | | } |
| | | }, 1000) // 每秒检查一次 |
| | | } |
| | | |
| | | private fun checkVideoPublishFinished(){ |
| | | webView.postDelayed({ |
| | | webView.evaluateJavascript(jsCode_PublishVideo_Finished) { result -> |
| | |
| | | val displayMetrics = activity.resources.displayMetrics |
| | | val width = displayMetrics.widthPixels |
| | | val height = displayMetrics.heightPixels |
| | | |
| | | val startX = width.toFloat() * 0.9f // 从右侧滑动 |
| | | val endX = width.toFloat() * 0.1f // 滑动到左侧 |
| | | val y = height / 3f // Y 坐标在屏幕中间 |
| | | |
| | | Thread { |
| | | Utils.instrumentationSwipe(instrumentation, startX, y, endX, y) |
| | | SystemClock.sleep(500) |
| | |
| | | SystemClock.sleep(500) |
| | | Utils.instrumentationClick(instrumentation, width / 2f, height * 2 / 4f) |
| | | // back to main thread |
| | | |
| | | threadHandler.post { |
| | | checkVideoUploadFinished() |
| | | } |