mine.js 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277
  1. const API = require("./API");
  2. var api = API(cookie);
  3. // 添加UID和用户信息
  4. async function putUID(uid) {
  5. let pd = true
  6. let UID = $storage.get("UID")
  7. UID.forEach(f => {
  8. if (f.uid == uid) {
  9. pd = false
  10. $ui.toast(`${uid} 已存在`)
  11. }
  12. })
  13. if (pd) {
  14. await api.getInfoByUID(uid).then(async res => {
  15. var ip
  16. await api.getIPByUID(uid).then(res => {
  17. ip = res.data.data.ip_location
  18. }).catch(err => {
  19. $ui.alert("未知错误!!有可能是Cookie失效了")
  20. })
  21. UID.push({
  22. uid: uid,
  23. name: res.data.data.user.screen_name,
  24. avatar: res.data.data.user.avatar_hd,
  25. location: res.data.data.user.location,
  26. ip: ip
  27. })
  28. $storage.put("UID", UID)
  29. $ui.toast(`${uid} 添加成功`)
  30. }).catch(err => {
  31. $ui.alert("未知错误!!有可能是Cookie失效了")
  32. })
  33. }
  34. }
  35. // 删除用户
  36. async function deleteLogin(f) {
  37. let UID = $storage.get("UID")
  38. let myUID = []
  39. UID.forEach(ff => {
  40. if (ff.uid != f.uid) {
  41. myUID.push(ff)
  42. }
  43. })
  44. $storage.put("UID", myUID)
  45. $ui.toast("删除成功")
  46. }
  47. // 复制UID
  48. async function copyUID(f) {
  49. $clipboard.text = f.uid
  50. $ui.toast("复制成功")
  51. }
  52. // 显示属性
  53. async function attribute(f) {
  54. $ui.showCode(JSON.stringify(f, null, 2));
  55. }
  56. // 切换排序
  57. async function sorting(f) {
  58. var UID = $storage.get("UID");
  59. var new_userlist = [], new_index=[], sort, sort_index;
  60. UID.forEach((ff, i) => {
  61. if (ff.uid != f.uid) {
  62. new_userlist.push(ff);
  63. new_index.push({
  64. title: `切换到第 ${i+1}`,
  65. value: i
  66. });
  67. } else {
  68. sort = ff;
  69. sort_index = i;
  70. }
  71. })
  72. var selected = await $input.select({
  73. title: `当前排序为第 ${sort_index+1}`,
  74. options: new_index
  75. })
  76. if (selected != null) {
  77. new_userlist.splice(selected.value, 0, sort);
  78. $storage.put("UID", new_userlist);
  79. $ui.toast("切换成功");
  80. } else {
  81. $ui.toast("取消切换");
  82. }
  83. }
  84. // 更新用户信息
  85. async function update() {
  86. UID.forEach(async (f, i, arr) => {
  87. await api.getInfoByUID(f.uid).then(async res => {
  88. arr[i] = {
  89. uid: f.uid,
  90. name: res.data.data.user.screen_name,
  91. avatar: res.data.data.user.avatar_hd,
  92. location: res.data.data.user.location
  93. }
  94. await api.getIPByUID(f.uid).then(res => {
  95. arr[i].ip = res.data.data.ip_location
  96. }).catch(err => {
  97. $ui.alert("未知错误!!有可能是Cookie失效了")
  98. })
  99. }).catch(err => {
  100. $ui.alert("未知错误!!有可能是Cookie失效了")
  101. })
  102. $storage.put("UID", UID)
  103. $ui.toast("更新成功")
  104. })
  105. }
  106. // 批量复制
  107. async function copyAll() {
  108. var uidAll = []
  109. this.UID.forEach(f => {
  110. uidAll.push(f.uid)
  111. })
  112. $clipboard.text = uidAll.toString()
  113. $ui.toast("复制成功")
  114. }
  115. // 批量添加
  116. async function insertAll() {
  117. let uidAll = await $input.text({
  118. title: '请输入批量UID',
  119. hint: 'UID',
  120. value: ''
  121. })
  122. uidAll = uidAll.split(',')
  123. uidAll.forEach(f => {
  124. putUID(f)
  125. })
  126. }
  127. module.exports = {
  128. type: 'list',
  129. title: '微博视频号 - 配置',
  130. beforeCreate() {
  131. getCookie()
  132. api = API(cookie)
  133. },
  134. async fetch() {
  135. var data = []
  136. data.push({
  137. style: 'article',
  138. title: "设置展示",
  139. time: `${formateTimeStamp(new Date().getTime())}`,
  140. summary: `视频展示:${$storage.get("top") ? "顶部显示" : "list显示"} 视频排序:${$storage.get("tab_code") == 0 ? "默认排序" : "热门排序"}\n首页样式:${$storage.get('style') ? "总体版": "名称版"} 当前用户列表数:${$storage.get("UID").length}人\n注意:顶部显示后视频排序就设置不了了,切换成list才能显示。视频排序只对分类视频有效。`
  141. });
  142. data.push({title: "Cookie操作",style: 'category'})
  143. data.push({
  144. title: "添加Cookie",
  145. spanCount: 4,
  146. onClick: async () => {
  147. let cookie = await $input.text({
  148. title: '请输入微博Cookie',
  149. hint: 'SUB',
  150. value: ''
  151. })
  152. if (cookie.indexOf("SUB") > -1) {
  153. $storage.put("cookie", cookie)
  154. } else {
  155. $storage.put("cookie", `SUB=${cookie}`)
  156. }
  157. $ui.toast("添加成功")
  158. }
  159. })
  160. data.push({
  161. title: "删除Cookie",
  162. spanCount: 4,
  163. onClick: async () => {
  164. let pd = await $input.confirm({
  165. title: "确认框",
  166. message: "是否清除当前Cookie",
  167. okBtn: "删除"
  168. })
  169. if (pd) {
  170. $storage.put("cookie", "")
  171. $ui.toast("删除成功")
  172. getCookie()
  173. } else {
  174. $ui.toast("取消删除")
  175. }
  176. }
  177. })
  178. data.push({
  179. title: "复制Cookie",
  180. spanCount: 4,
  181. onClick: async () => {
  182. $clipboard.text = $storage.get("cookie")
  183. $ui.toast("复制成功")
  184. }
  185. })
  186. data.push({
  187. title: "游客登录",
  188. spanCount: 4,
  189. onClick: async () => {
  190. $router.to($route('web'))
  191. }
  192. })
  193. data.push({title: "UID操作",style: 'category'})
  194. data.push({
  195. title: "添加用户UID",
  196. spanCount: 4,
  197. onClick: async () => {
  198. let uid = await $input.number({
  199. title: '请输入要添加用户的UID',
  200. hint: 'UID',
  201. value: ''
  202. })
  203. if (uid != undefined) {
  204. putUID(uid)
  205. } else {
  206. $ui.toast("取消添加")
  207. }
  208. }
  209. })
  210. data.push({
  211. title: "删除所有UID",
  212. spanCount: 4,
  213. onClick: async () => {
  214. let pd = await $input.confirm({
  215. title: "确认框",
  216. message: "是否清除所有用户的UID",
  217. okBtn: "删除"
  218. })
  219. if (pd) {
  220. $storage.put("UID", [])
  221. $ui.toast("删除成功")
  222. getCookie()
  223. } else {
  224. $ui.toast("取消删除")
  225. }
  226. }
  227. })
  228. data.push({
  229. title: "更新用户信息",
  230. spanCount: 4,
  231. onClick: async () => {
  232. await update()
  233. }
  234. })
  235. data.push({
  236. title: "批量复制",
  237. spanCount: 4,
  238. onClick: async () => {
  239. await copyAll()
  240. }
  241. })
  242. data.push({
  243. title: "批量添加",
  244. spanCount: 4,
  245. onClick: async () => {
  246. await insertAll()
  247. }
  248. })
  249. data.push({title: "用户列表",style: 'category'})
  250. $storage.get("UID").forEach(f => {
  251. data.push({
  252. style: 'simple',
  253. title: f.name,
  254. summary: `${f.ip} || ${f.location}`,
  255. thumb: f.avatar,
  256. onLongClick: async () => {
  257. var selected = await $input.select({
  258. title: '选择哪一个',
  259. options: [
  260. {title: '删除用户', fun: deleteLogin},
  261. {title: '切换排序', fun: sorting},
  262. {title: '复制UID', fun: copyUID},
  263. {title: '属性', fun: attribute}
  264. ]
  265. })
  266. selected != null ? selected.fun(f) : null;
  267. },
  268. onClick: async () => {
  269. $router.to($route('list/onelist', f))
  270. }
  271. })
  272. })
  273. return data
  274. }
  275. }