huashi6.js 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460
  1. const channels_path = "hiker://files/rules/js/TyrantGenesis_触站关注.js"
  2. const base_url = "https://www.huashi6.com"
  3. const empty = "hiker://empty"
  4. const baseParse = _ => {
  5. // 初始化
  6. let d = [];
  7. const page = MY_URL.split('##')[1]
  8. const cateArray = [
  9. {
  10. title: '关注画师',
  11. url: empty,
  12. },
  13. {
  14. title: '新作',
  15. url: "https://rt.huashi6.com/front/works/sharelist?index="+page,
  16. },
  17. {
  18. title: '热门',
  19. url: "https://rt.huashi6.com/front/works/hotlist?index="+page,
  20. },
  21. /*{
  22. title: '标签',
  23. url: "https://www.huashi6.com/tags",
  24. },*/
  25. {
  26. title: '今日榜单',
  27. url: "https://rt.huashi6.com/front/works/rank_page?index=0&size=50",
  28. },
  29. {
  30. title: '推荐画师',
  31. url: "https://rt.huashi6.com/front/painter/list?index="+page+"&size=12",
  32. },
  33. ]
  34. let channels
  35. // 缓存
  36. let cate = getItem("cate_select", "0")
  37. let channel_select = getItem("channel_select", "0")
  38. let button_show = getItem("button_show", "1") // 1:热门,2:收起,3:取消,4:置顶
  39. if (fetch(channels_path)) {
  40. let local_channels = fetch(channels_path)
  41. channels = JSON.parse(local_channels)
  42. } else {
  43. let defaultChannels = [
  44. {name: 'wlop', uid: '7168', avatar: 'https://img2.huashi6.com/images/resource/2015/06/24/51h068746p0.jpg?imageView2/1/q/100/interlace/1/w/160/h/160'},
  45. ]
  46. writeFile(channels_path, JSON.stringify(defaultChannels))
  47. channels = defaultChannels
  48. }
  49. if (parseInt(page) === 1) {
  50. cateArray.forEach((item, index) => {
  51. d.push({
  52. title: parseInt(cate) === index ? '‘‘’’<strong><font color="red">'+item.title+'</font></strong>' : item.title,
  53. url: $(empty).lazyRule(params => {
  54. setItem("cate_select", params.index.toString())
  55. refreshPage(true)
  56. return "hiker://empty"
  57. }, {
  58. item: item,
  59. index: index
  60. }),
  61. col_type: 'scroll_button',
  62. })
  63. })
  64. }
  65. switch (cate) {
  66. case '0': {
  67. if (parseInt(page) === 1) {
  68. d.push({
  69. col_type: 'blank_block',
  70. })
  71. d.push({
  72. title: button_show === '1' ? '‘‘’’<strong><font color="red">展开</font></strong>' : '展开',
  73. url: $(empty).lazyRule(_ => {
  74. setItem("button_show", '1')
  75. refreshPage(true)
  76. return "hiker://empty"
  77. }),
  78. col_type: 'scroll_button',
  79. })
  80. d.push({
  81. title: button_show === '2' ? '‘‘’’<strong><font color="red">收起</font></strong>' : '收起',
  82. url: $(empty).lazyRule(_ => {
  83. setItem("button_show", '2')
  84. refreshPage(true)
  85. return "hiker://empty"
  86. }),
  87. col_type: 'scroll_button',
  88. })
  89. d.push({
  90. title: button_show === '3' ? '‘‘’’<strong><font color="red">置顶</font></strong>' : '置顶',
  91. url: $(empty).lazyRule(_ => {
  92. setItem("button_show", '3')
  93. refreshPage(true)
  94. return "hiker://empty"
  95. }),
  96. col_type: 'scroll_button',
  97. })
  98. d.push({
  99. title: button_show === '4' ? '‘‘’’<strong><font color="red">取关</font></strong>' : '取关',
  100. url: $(empty).lazyRule(_ => {
  101. setItem("button_show", '4')
  102. refreshPage(true)
  103. return "hiker://empty"
  104. }),
  105. col_type: 'scroll_button',
  106. })
  107. if (channels.length === 0) {
  108. d.push({
  109. title: '先关注几位画师吧~',
  110. col_type: 'long_text',
  111. })
  112. }
  113. }
  114. if (channels.length > 0) {
  115. if (button_show !== '2') {
  116. let prefix = ''
  117. switch (button_show) {
  118. case '1': prefix = '';break
  119. case '3': prefix = '🔝';break
  120. case '4': prefix = '❌';break
  121. }
  122. if (parseInt(page) === 1) {
  123. channels.forEach((channel, index) => {
  124. d.push({
  125. title: parseInt(channel_select) === index && button_show === '1' ? '✓' + channel.name : prefix + channel.name,
  126. pic_url: channel.avatar + '@Referer=' + base_url,
  127. url: $(empty).lazyRule(params => {
  128. const channels_path = "hiker://files/rules/js/TyrantGenesis_触站关注.js"
  129. if (params.button_show === '1') {
  130. setItem("channel_select", params.index.toString())
  131. } else if (params.button_show === '3') {
  132. let current = params.channels[params.index]
  133. params.channels.splice(params.index, 1)
  134. params.channels.unshift(current)
  135. writeFile(channels_path, JSON.stringify(params.channels))
  136. setItem("channel_select", '0')
  137. } else {
  138. params.channels.splice(params.index, 1)
  139. writeFile(channels_path, JSON.stringify(params.channels))
  140. setItem("channel_select", '0')
  141. }
  142. refreshPage(true)
  143. return "hiker://empty"
  144. }, {
  145. index: index,
  146. button_show: button_show,
  147. channels: channels
  148. }),
  149. col_type: 'icon_round_4',
  150. })
  151. })
  152. d.push({
  153. col_type: 'blank_block',
  154. })
  155. }
  156. }
  157. let uid = channels[channel_select].uid
  158. let url = "https://rt.huashi6.com/front/works/painter?painterId="+uid+"&index="+page
  159. let html = fetch(url, {headers:{"User-Agent": PC_UA}})
  160. // let list = parseDomForArray(html, '.px-container&&.c-px-waterfall-item')
  161. let list = JSON.parse(html).data.datas
  162. /*list.forEach(item => {
  163. d.push({
  164. title: parseDomForHtml(item, '.px-info-title&&Text'),
  165. pic_url: parseDomForHtml(item, 'img&&src')+'@Referer='+base_url,
  166. url: parseDomForHtml(item, 'a&&href'),
  167. desc: parseDomForHtml(item, '.px-info-title&&Text'),
  168. col_type: 'movie_2'
  169. })
  170. })*/
  171. list.forEach(item => {
  172. d.push({
  173. title: item.title,
  174. pic_url: "https://img2.huashi6.com/"+item.coverImage.originalPath+'@Referer='+base_url,
  175. url: "https://www.huashi6.com/draw/"+item.id,
  176. desc: item.likeNum+'次喜欢',
  177. col_type: 'movie_2'
  178. })
  179. })
  180. }
  181. break
  182. }
  183. case '1':
  184. case '2': {
  185. let html = fetch(cateArray[parseInt(cate)].url, {headers:{"User-Agent": PC_UA}})
  186. let list = JSON.parse(html).data.datas
  187. list.forEach(item => {
  188. d.push({
  189. title: item.title,
  190. pic_url: "https://img2.huashi6.com/"+item.coverImage.originalPath+'@Referer='+base_url,
  191. url: "https://www.huashi6.com/draw/"+item.id,
  192. desc: item.likeNum+'次喜欢',
  193. col_type: 'movie_2'
  194. })
  195. })
  196. break
  197. }
  198. case '3': {
  199. /*if (parseInt(page) === 1) {
  200. let html = fetch(cateArray[parseInt(cate)].url, {headers:{"User-Agent": PC_UA}})
  201. let list = parseDomForArray(html, '.c-tag-alphabet-list&&li')
  202. list.forEach((item, index) => {
  203. let title = parseDomForHtml(item, '.row-label&&Text')
  204. let tagList = parseDomForArray(item, '.label-list&&a')
  205. d.push({
  206. title: '首字母:'+title,
  207. col_type: 'text_1'
  208. })
  209. if (index === 1)
  210. tagList.forEach(tag => {
  211. d.push({
  212. title: parseDomForHtml(tag, 'a&&Text'),
  213. url: parseDomForHtml(tag, 'a&&href'),
  214. col_type: 'flex_button',
  215. })
  216. })
  217. d.push({
  218. col_type: 'line_blank'
  219. })
  220. })
  221. }*/
  222. if (parseInt(page) === 1) {
  223. let list_json = fetch(cateArray[parseInt(cate)].url, {headers:{
  224. "User-Agent": PC_UA,
  225. // "body": "index=0&size=50",
  226. // "method": "POST"
  227. }})
  228. let list = JSON.parse(list_json).data.works.datas
  229. list.forEach(item => {
  230. d.push({
  231. title: item.title,
  232. pic_url: "https://img2.huashi6.com/"+item.coverImage.path+'@Referer='+base_url,
  233. url: "https://www.huashi6.com/draw/"+item.id,
  234. desc: item.description,
  235. col_type: 'movie_2'
  236. })
  237. })
  238. }
  239. break
  240. }
  241. case '4': {
  242. let list_json = fetch(cateArray[parseInt(cate)].url, {headers:{"User-Agent": PC_UA}})
  243. let list = JSON.parse(list_json).data.datas
  244. list.forEach(item => {
  245. let userObj = {
  246. name: item.name,
  247. uid: item.id,
  248. avatar: item.coverImageUrl ? "https://img2.huashi6.com/"+item.coverImageUrl : "https://res2.huashi6.com/static/hst/pc/imgs/default_avatar.d59d546.png"
  249. }
  250. d.push({
  251. title: userObj.name,
  252. pic_url: userObj.avatar+'@Referer='+base_url,
  253. url: $("https://www.huashi6.com/painter/"+item.id+"?p=fypage##fypage").rule(userObj => {
  254. eval(fetch('hiker://files/TyrantG/IMAGE/huashi6.js'))
  255. userParse(userObj)
  256. }, userObj),
  257. desc: item.profile,
  258. col_type: 'movie_3_marquee'
  259. })
  260. })
  261. break
  262. }
  263. }
  264. setResult(d);
  265. }
  266. const secParse = _ => {
  267. let d = [];
  268. let channel_select = getItem("channel_select", "0")
  269. let channels = JSON.parse(fetch(channels_path))
  270. let html = fetch(MY_URL, {headers:{"User-Agent": PC_UA}})
  271. let userinfo = parseDomForArray(html, '.detail-painter-info&&a')[0]
  272. let url = parseDomForHtml(userinfo, 'a&&href')
  273. let url_arr = url.split('/')
  274. let uid = url_arr[url_arr.length-1]
  275. let title = parseDomForHtml(userinfo, 'a&&title')
  276. let avatar = parseDomForHtml(userinfo, 'img&&src')
  277. let userObj = {
  278. name: title,
  279. uid: uid,
  280. avatar: avatar
  281. }
  282. d.push({
  283. title: title,
  284. pic_url: avatar+'@Referer='+base_url,
  285. url: $(url+"?p=fypage##fypage").rule(userObj => {
  286. eval(fetch('hiker://files/TyrantG/IMAGE/huashi6.js'))
  287. userParse(userObj)
  288. }, userObj),
  289. col_type: 'icon_2_round',
  290. })
  291. let has_collect = false
  292. channels.forEach((item, index) => {
  293. if (item.uid.toString() === uid.toString()) has_collect = index
  294. })
  295. d.push({
  296. title: has_collect === false ? "关注用户" : "取消关注",
  297. url: $(empty).lazyRule(params => {
  298. const channels_path = "hiker://files/rules/js/TyrantGenesis_触站关注.js"
  299. if (params.has_collect) {
  300. params.channels.splice(params.index, 1)
  301. writeFile(channels_path, JSON.stringify(params.channels))
  302. if (parseInt(channel_select) === params.index) setItem("channel_select", '0')
  303. refreshPage(false)
  304. return 'toast://取消关注'
  305. } else {
  306. params.channels.push(params.userObj)
  307. writeFile(channels_path, JSON.stringify(params.channels))
  308. refreshPage(false)
  309. return 'toast://关注成功'
  310. }
  311. }, {
  312. index: has_collect,
  313. channel_select: channel_select,
  314. has_collect: has_collect,
  315. channels: channels,
  316. userObj: userObj
  317. }),
  318. col_type: 'text_2'
  319. })
  320. d.push({
  321. col_type: 'blank_block'
  322. })
  323. let list = fetch("https://rt.huashi6.com/front/works/detail?id="+MY_URL.split('/').pop())
  324. const data = JSON.parse(list).data
  325. setPageTitle(data.title)
  326. let images = data.images
  327. images.forEach(item => {
  328. d.push({
  329. pic_url: "https://img2.huashi6.com/"+item.originalPath+'@Referer='+base_url,
  330. url: "https://img2.huashi6.com/"+item.originalPath+'@Referer='+base_url,
  331. col_type: 'pic_1_full'
  332. })
  333. })
  334. setResult(d);
  335. }
  336. const userParse = userObj => {
  337. let d = [];
  338. setPageTitle(userObj.name)
  339. const url = MY_URL.split('##')[0]
  340. const page = MY_URL.split('##')[1]
  341. if (page === '1') {
  342. let channel_select = getItem("channel_select", "0")
  343. let channels = JSON.parse(fetch(channels_path))
  344. let has_collect = false
  345. channels.forEach(item => {
  346. if (item.uid.toString() === userObj.uid.toString()) has_collect = true
  347. })
  348. d.push({
  349. title: has_collect ? "取消关注" : "关注用户",
  350. url: $(empty).lazyRule(params => {
  351. const channels_path = "hiker://files/rules/js/TyrantGenesis_触站关注.js"
  352. if (params.has_collect) {
  353. params.channels.splice(params.index, 1)
  354. writeFile(channels_path, JSON.stringify(params.channels))
  355. if (parseInt(channel_select) === params.index) setItem("channel_select", '0')
  356. refreshPage(false)
  357. return 'toast://取消关注'
  358. } else {
  359. params.channels.push(params.userObj)
  360. writeFile(channels_path, JSON.stringify(params.channels))
  361. refreshPage(false)
  362. return 'toast://关注成功'
  363. }
  364. }, {
  365. index: has_collect,
  366. channel_select: channel_select,
  367. has_collect: has_collect,
  368. channels: channels,
  369. userObj: userObj
  370. }),
  371. col_type: 'text_center_1'
  372. })
  373. d.push({
  374. col_type: 'blank_block'
  375. })
  376. }
  377. let api_url = "https://rt.huashi6.com/front/works/painter?painterId="+userObj.uid+"&index="+page
  378. let html = fetch(api_url, {headers:{"User-Agent": PC_UA}})
  379. // let list = parseDomForArray(html, '.px-container&&.c-px-waterfall-item')
  380. let list = JSON.parse(html).data.datas
  381. list.forEach(item => {
  382. d.push({
  383. title: item.title,
  384. pic_url: "https://img2.huashi6.com/"+item.coverImage.originalPath+'@Referer='+base_url,
  385. url: $("https://www.huashi6.com/draw/"+item.id).rule(_ => {
  386. eval(fetch('hiker://files/TyrantG/IMAGE/huashi6.js'))
  387. secParse()
  388. }),
  389. desc: item.likeNum+'次喜欢',
  390. col_type: 'movie_2'
  391. })
  392. })
  393. setResult(d);
  394. }
  395. const searchParse = _ => {
  396. let d = [];
  397. let list = JSON.parse(getResCode()).data.datas
  398. list.forEach(item => {
  399. d.push({
  400. title: item.title,
  401. pic_url: "https://img2.huashi6.com/"+item.coverImage.path+'@Referer='+base_url,
  402. url: "https://www.huashi6.com/draw/"+item.id,
  403. desc: item.description,
  404. col_type: 'movie_2'
  405. })
  406. })
  407. setResult(d);
  408. }