-哔哩猫-(试用版)

注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )

当前为 2021-08-03 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/956978/-%E5%93%94%E5%93%A9%E7%8C%AB-%EF%BC%88%E8%AF%95%E7%94%A8%E7%89%88%EF%BC%89.js

  1. // ==UserScript==
  2. // @name -哔哩猫-(试用版)
  3. // @description 注:练手作品,多多包涵,不接受恶意差评,有问题群内咨询(Q群1031014013):批量播放视频;批量拉黑;批量关注;动态艾特消息提醒(友情天选群746790091 )
  4. // @namespace http://tampermonkey.net/
  5. // @version 2.0.00
  6. // @iconURL https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif
  7. // @author 荒年(QQ:2019676120)
  8. // @match *://space.bilibili.com/*
  9. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  10. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  11. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  12. // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
  13. // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
  14. // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
  15. // @grant unsafeWindow
  16. // @grant GM_getValue
  17. // @grant GM_setValue
  18. // @grant GM_xmlhttpRequest
  19. // @grant GM_getResourceText
  20. // @grant GM_openInTab
  21. // @grant GM_addStyle
  22. // @run-at document-idle
  23. // @license MIT License
  24. // @connect github.com
  25. // @connect gitee.com
  26. // @connect api.bilibili.com
  27. // @connect qmsg.zendee.cn
  28. // @connect passport.bilibili.com
  29. // @connect api.live.bilibili.com
  30. // @namespace http://tampermonkey.net/
  31. // ==/UserScript==
  32.  
  33.  
  34.  
  35.  
  36. GM_addStyle(
  37. `
  38.  
  39. #switch-qsmg:before {
  40. content: "开关";
  41. letter-spacing: 16px;
  42. top: 4px;
  43. left: 10px;
  44. }
  45. #left_navbar{
  46. z-index: 1000;
  47. position: absolute;
  48. top: 100px;
  49. left: 5px;
  50. }
  51. button[hnBtn="btn_open"] {
  52. z-index: 1001;
  53. z-index: 1000px;
  54. position: absolute;
  55. top: 58px;
  56. left: 220px;
  57. }
  58. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  59. top: 60px;
  60. }
  61. .javaex-menu-container {
  62. border: 1px solid #eee;
  63. }
  64. .javaex-panel-box p {
  65. text-align: center;
  66. background: #fb7299;
  67. }
  68. .fontbold{
  69. color: #00a1d6;
  70. font-weight: bold;
  71. cursor: pointer;
  72. }
  73. `
  74. );
  75.  
  76.  
  77. let HN_SETUP_CONFIG = {
  78.  
  79. qmsg_key: null, //后期改为kull 存储到本地
  80. qmsg_checked: false,
  81. Booking_last_sid: null,
  82. }
  83.  
  84. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  85. "酋长在线拉低中奖率", "好耶(✪▽✪)", "好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  86. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "今天去吃面", "从不缺席",
  87. "站友保佑抽到", "可以", "恰", "不会吧", "233", "好耶", "rush", "来了!!!", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  88. "是我的", "我是天选之子?", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "我下手了",
  89. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  90. ]
  91.  
  92.  
  93. let Live_info = {
  94. room_id: undefined,
  95. uid: undefined,
  96. blocked: undefined,
  97. csrf_token: undefined,
  98. SESSDATA: undefined,
  99. visit_id: undefined,
  100. rnd: undefined,
  101. ruid: undefined,
  102. uname: undefined,
  103. user_level: undefined,
  104. ruid: undefined,
  105. };
  106.  
  107. let BILIBLI_PATH = {
  108.  
  109. "live": "https://api.live.bilibili.com",
  110. "vcapi": "https://api.vc.bilibili.com",
  111. "passport": "https://passport.bilibili.com",
  112. "api": "https://api.bilibili.com",
  113. "video": "https://www.bilibili.com/video/",
  114. "single_unread": "http://api.vc.bilibili.com/",
  115.  
  116. }
  117.  
  118. let BILIBILI_URL = {
  119. // 导航栏用户信息
  120. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  121. }
  122.  
  123. let BiliData = {
  124.  
  125. this_uid: window.location.href.split("/")[3], //当前页面uid
  126. author_uid: 99439379,
  127. login_code: null,
  128. login_message: "",
  129. LoginData: {},
  130. CoinLog: {},
  131. Unread: null,
  132. Video: {},
  133. replyAction: {},
  134. upCard: {},
  135. BVList: [],
  136. }
  137.  
  138. window.onload = function() {
  139.  
  140.  
  141. //界面显示
  142. init();
  143.  
  144. /* var myVar = setInterval(function() {
  145. console.log("yunxing");
  146. AA ();
  147. }, 1000);
  148. function AA (){
  149. if ((new Date()).getMinutes() == 47) {
  150. console.log("stop");
  151. clearInterval(myVar);
  152. }
  153. } */
  154.  
  155.  
  156. }
  157.  
  158.  
  159. function init() {
  160.  
  161. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  162. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  163. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  164.  
  165. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  166.  
  167.  
  168. addStyle();
  169. addSetPage();
  170.  
  171. HNTOOL.chackAtMsg();
  172.  
  173. $("#getCoinLog").bind("click", async function() {
  174.  
  175.  
  176. if (HNAPI.getCoinLog()) {
  177.  
  178. await HNTOOL.Sleep(500);
  179. let html = '';
  180. html += '<div class="javaex-panel-box" style="width: 250px;">';
  181. html += ' <ul>';
  182. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  183.  
  184. BiliData.CoinLog.list.forEach(function(item) {
  185.  
  186. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  187. if (BV.indexOf("BV") != -1) {
  188. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  189. }
  190. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  191.  
  192.  
  193. });
  194. html += ' <hr class="javaex-divider"></hr>';
  195. html += ' </ul>';
  196. html += '</div>';
  197.  
  198. javaex.panel(this, {
  199. position: "right",
  200. //offsetTop: "104",
  201. content: html
  202. });
  203. javaex.tip({
  204. content: "获取用户成功!",
  205. type: "success"
  206. });
  207.  
  208. } else {
  209. javaex.tip({
  210. content: "获取硬币记录失败,请稍后重试!",
  211. type: "error"
  212. });
  213. }
  214.  
  215.  
  216. });
  217.  
  218. $("#getUnread").bind("click", async function() {
  219.  
  220. javaex.tip({
  221. content: "获取中,请稍候...",
  222. type: "submit"
  223. });
  224. HNAPI.getUnread();
  225.  
  226.  
  227. });
  228.  
  229.  
  230. $("#likeInDynamicComments").bind("click", async function() {
  231.  
  232. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  233. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  234.  
  235. let html = '';
  236.  
  237. html += '<div style="padding: 10px 10px 10px 0px;">'
  238. html += '<form id="likeInDynamic_form">'
  239. html += ' <div class="javaex-unit clear">'
  240. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  241. html += ' <div class="javaex-unit-right">'
  242. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  243. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  244. html += ' </div>'
  245. html += ' </div>'
  246. html += ' <div class="javaex-unit clear">'
  247. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  248. html += ' <div class="javaex-unit-right">'
  249. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  250. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  251. html += ' </div>'
  252. html += ' </div>'
  253. html += ' <div class="javaex-unit clear tc">'
  254. html +=
  255. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  256. html +=
  257. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  258. html += ' </div>'
  259. html += '</form>';
  260. html += '<hr class="javaex-divider"></hr>';
  261. html += '</div>';
  262.  
  263.  
  264. javaex.panel(this, {
  265. position: "right",
  266. content: html
  267. });
  268.  
  269.  
  270. // 监听点击保存按钮事件
  271. $("#likeInDynamic_yes").click(async function() {
  272. // 表单验证函数
  273. if (javaexVerify()) {
  274.  
  275. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal(
  276. "#likeInDynamic_PRID"), 1);
  277. await HNTOOL.Sleep(1000);
  278.  
  279. if (BiliData.replyAction.code == 0) {
  280.  
  281. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  282. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  283.  
  284. javaex.tip({
  285. content: "评论区点赞成功!",
  286. type: "success"
  287. });
  288. } else {
  289. javaex.tip({
  290. content: "评论区点赞失败!",
  291. type: "error"
  292. });
  293. }
  294. if (BiliData.replyAction.code == 65006) {
  295. javaex.tip({
  296. content: "请勿重复点赞!",
  297. type: "error"
  298. });
  299. }
  300. }
  301. });
  302.  
  303. // 监听点击返回按钮事件
  304. $("#likeInDynamic_no").click(async function() {
  305.  
  306. if (javaexVerify()) {
  307.  
  308. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage(
  309. "#likeInDynamic_PRID"), 0);
  310. await HNTOOL.Sleep(500);
  311.  
  312. if (BiliData.replyAction.code == 0) {
  313.  
  314. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  315. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  316.  
  317. javaex.tip({
  318. content: "评论区取消点赞成功!",
  319. type: "success"
  320. });
  321. } else {
  322. javaex.tip({
  323. content: "评论区取消点赞失败!",
  324. type: "error"
  325. });
  326. }
  327. if (BiliData.replyAction.code == 65006) {
  328. javaex.tip({
  329. content: "请勿重复取消点赞!",
  330. type: "error"
  331. });
  332. }
  333. }
  334. });
  335.  
  336. });
  337.  
  338. $("#biliUserMsg").bind("click", async function() {
  339.  
  340.  
  341. //刷新信息
  342. HNAPI.getUserNav();
  343. await HNTOOL.Sleep(500);
  344.  
  345. let isLogin = "未登录";
  346. let vipType = "无";
  347. //判断是否成功
  348. if (BiliData.login_code == 0) {
  349.  
  350.  
  351. if (BiliData.LoginData.isLogin) {
  352. isLogin = "已登录";
  353. }
  354.  
  355. if (BiliData.LoginData.vipType == 1) {
  356. vipType = "月度大会员";
  357. } else if (BiliData.LoginData.vipType == 2) {
  358. vipType = "年度大会员";
  359. }
  360.  
  361. let html = '';
  362. html += '<div class="javaex-panel-box" style="width: 250px;">';
  363. html += ' <ul>';
  364. html += ` <p style="color: #FFF;">用户信息</p>`;
  365. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  366. html += ` <li>用户状态:${isLogin} </li> `;
  367. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  368. html +=
  369. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  370. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  371. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  372. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  373. html += ` <li>会员:${vipType} </li> `;
  374. html += ' <hr class="javaex-divider"></hr>';
  375. html += ' </ul>';
  376. html += '</div>';
  377.  
  378.  
  379. javaex.panel(this, {
  380. position: "right",
  381. content: html
  382. });
  383.  
  384. javaex.tip({
  385. content: "获取用户成功!",
  386. type: "success"
  387. });
  388.  
  389. } else {
  390. javaex.tip({
  391. content: "获取用户信息失败!",
  392. type: "error"
  393. });
  394. }
  395.  
  396.  
  397. });
  398.  
  399. $("#getAtMsg").bind("click", async function() {
  400.  
  401. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  402.  
  403. javaex.tip({
  404. content: "可能中奖了!!!",
  405. type: "success"
  406. });
  407. }
  408. });
  409.  
  410.  
  411. $("#disUser").bind("click", async function() {
  412.  
  413. let html = '';
  414. html += '<div class="javaex-panel-box" style="width: 500px;">';
  415. html += ' <div class="javaex-unit clear">';
  416. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  417. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  418. html +=
  419. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  420. html += ' </div>';
  421. html += ' </div>';
  422. html += ' <div class="javaex-unit clear tc">';
  423. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  424. html += ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  425. html += ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  426. html += ' </div>';
  427. html += '</div>';
  428.  
  429. javaex.panel(this, {
  430. position: "right",
  431. content: html
  432. });
  433.  
  434. let disUser_str;
  435. //拉黑
  436. $("#disUser_block").bind("click", async function() {
  437.  
  438. disUser_str = javaex.getSelectVal("#disUser_uidList");
  439. let disUser_uidList = disUser_str.split(",");
  440. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  441.  
  442. for (const vmid of disUserStr) {
  443.  
  444. HNAPI.batchModify(vmid.toString(), 5);
  445. await HNTOOL.Sleep(2000);
  446. }
  447. });
  448. //取关uid
  449. $("#disUser_cancelAtt_uid").bind("click", async function() {
  450. disUser_str = javaex.getSelectVal("#disUser_uidList");
  451. let disUser_uidList = disUser_str.split(",");
  452.  
  453. javaex.tip({
  454. content: "根据uid批量取关开始!!!",
  455. type: "success"
  456. });
  457.  
  458. /*
  459. let disuidList = [];
  460. let PN = 100;
  461. PN = disUser_uidList.length == 1 ? 0 : PN;
  462.  
  463. for (var i = 0; i < PN; i++) {
  464.  
  465. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  466. javaex.tip({
  467. content: "获取第" + i + "页黑名单成功!",
  468. type: "success"
  469. });
  470. await HNTOOL.Sleep(1000);
  471.  
  472. if (uidList.length == 0) {
  473. break;
  474. }
  475. if (uidList == null) {
  476. continue;
  477. }
  478.  
  479. for (let disuid of uidList) {
  480. if (disuidList.indexOf(disuid.mid) == -1) {
  481. disuidList.push(disuid.mid + "");
  482. }
  483. }
  484.  
  485.  
  486. } */
  487. let J = 1;
  488.  
  489. for (let uid of disUser_uidList) {
  490.  
  491. /* let uidType = "未在黑名单";
  492. if (disuidList.indexOf(uid) == -1) {
  493.  
  494. await HNAPI.cancelAtt(uid, 2);
  495. } else {
  496.  
  497. await HNAPI.cancelAtt(uid, 6, 116);
  498. uidType = "黑名单用户";
  499. } */
  500. await HNAPI.cancelAtt(uid, 2);
  501.  
  502. javaex.tip({
  503. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_uidList.length + ")",
  504. type: "success"
  505. });
  506. await HNTOOL.Sleep(1000);
  507. }
  508.  
  509.  
  510. alert("根据uid批量取关完成!");
  511.  
  512. /* javaex.alert({
  513. content: "根据uid批量取关完成!",
  514. confirm: function() {
  515.  
  516. //return false;
  517. }
  518. }); */
  519.  
  520. });
  521. //取关room
  522. $("#disUser_cancelAtt_room").bind("click", async function() {
  523.  
  524. javaex.tip({
  525. content: "根据房间号批量取关开始!!!",
  526. type: "success"
  527. });
  528.  
  529. disUser_str = javaex.getSelectVal("#disUser_uidList");
  530. let disUser_roomList = disUser_str.split(",");
  531. /* let disuidList = [];
  532. let PN = 100;
  533. PN = disUser_roomList.length == 1 ? 0 : PN;
  534.  
  535. for (var i = 0; i < PN; i++) {
  536.  
  537. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  538. javaex.tip({
  539. content: "获取第" + i + "页黑名单成功!",
  540. type: "success"
  541. });
  542. await HNTOOL.Sleep(1000);
  543.  
  544. if (uidList.length == 0) {
  545. break;
  546. }
  547. if (uidList == null) {
  548. continue;
  549. }
  550.  
  551. for (let disuid of uidList) {
  552.  
  553. if (disuidList.indexOf(disuid.mid) == -1) {
  554. disuidList.push(disuid.mid);
  555. }
  556.  
  557. }
  558.  
  559.  
  560. } */
  561. let J = 1;
  562. for (let room of disUser_roomList) {
  563.  
  564. let uid = await HNAPI.getRoomMsg(room);
  565.  
  566. await HNTOOL.Sleep(1000);
  567.  
  568. if (uid == false) {
  569. javaex.tip({
  570. content: "uid查询失败跳过!",
  571. type: "error"
  572. });
  573. continue;
  574. }
  575. /* let uidType = "未在黑名单";
  576. if (disuidList.indexOf(uid) == -1) {
  577.  
  578. await HNAPI.cancelAtt(uid, 2);
  579. } else {
  580.  
  581. await HNAPI.cancelAtt(uid, 6, 116);
  582. uidType = "黑名单用户";
  583. } */
  584. await HNAPI.cancelAtt(uid, 2);
  585.  
  586. javaex.tip({
  587. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" + disUser_roomList.length +
  588. ")",
  589. type: "success"
  590. });
  591. await HNTOOL.Sleep(1000);
  592.  
  593.  
  594. }
  595. alert("根据房间号批量取关完成!");
  596. /* javaex.alert({
  597. content: ,
  598. confirm: function() {
  599.  
  600. return false;
  601. }
  602. }); */
  603.  
  604. });
  605.  
  606. });
  607.  
  608. $("#getNeetCookie").bind("click", async function() {
  609.  
  610. let html = '';
  611. html += '<div class="javaex-panel-box" style="width: 750px;">';
  612. html += ' <div class="javaex-unit clear">';
  613. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  614. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  615. html +=
  616. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  617. html += ' </div>';
  618. html += ' </div>';
  619. html += ' <div class="javaex-unit clear tc">';
  620. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  621. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  622. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  623. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  624. html += ' </div>';
  625. html += '</div>';
  626.  
  627. javaex.panel(this, {
  628. position: "right",
  629. content: html
  630. });
  631.  
  632. $('#getCookie_copy').bind('click', function() {
  633.  
  634. HNTOOL.copyText("neetCookie");
  635.  
  636. });
  637.  
  638. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  639. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  640. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  641.  
  642.  
  643. $("#getCookie_type1").bind("click", async function() {
  644.  
  645. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%") +
  646. "; bili_jct=" + Live_info.csrf_token +
  647. "; "
  648. document.getElementById("neetCookie").value = cookie01;
  649.  
  650. });
  651. $("#getCookie_type3").bind("click", async function() {
  652.  
  653. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA.replace(/%25/g, "%%") +
  654. "; bili_jct=" + Live_info.csrf_token +
  655. "; "
  656. document.getElementById("neetCookie").value = cookie01;
  657.  
  658. });
  659.  
  660. $("#getCookie_type2").bind("click", async function() {
  661.  
  662. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") + "\n" + Live_info.csrf_token;
  663. document.getElementById("neetCookie").value = cookie02;
  664. });
  665.  
  666. });
  667.  
  668. $("#arrUnique").bind("click", async function() {
  669.  
  670. let html = '';
  671. html += '<div class="javaex-panel-box" style="width: 500px;">';
  672. html += ' <div class="javaex-unit clear">';
  673. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  674. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  675. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  676. html += ' </div>';
  677. html += ' </div>';
  678. html += ' <div class="javaex-unit clear tc">';
  679. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  680. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  681. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  682. html += ' </div>';
  683. html += '</div>';
  684.  
  685. javaex.panel(this, {
  686. position: "right",
  687. content: html
  688. });
  689.  
  690. $('#arrUnique_str').bind('input propertychange', function() {
  691.  
  692. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  693.  
  694. });
  695. $('#arrUnique_copy').bind('click', function() {
  696.  
  697. HNTOOL.copyText("arrUnique_str");
  698.  
  699. });
  700.  
  701.  
  702.  
  703.  
  704. $("#arrUnique_beg").bind("click", async function() {
  705.  
  706. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  707. let arrUnique_uidList = arrUnique_str.split(",");
  708.  
  709. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  710.  
  711. document.getElementById("arrUnique_str").value = new_arr.toString();
  712.  
  713. $('#arrNub').text("*数组" + new_arr.length);
  714.  
  715. });
  716.  
  717. });
  718.  
  719. $("#batchFollow").bind("click", async function() {
  720.  
  721. var thisUPName = $("#h-name").text();
  722.  
  723.  
  724. let html = '';
  725. html += '<div class="javaex-panel-box" style="width: 600px;">';
  726. html += ' <div class="javaex-unit clear">';
  727. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  728. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  729. html +=
  730. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  731. html += ' </div>';
  732. html += ' </div>';
  733. html += ' <div class="javaex-unit clear tc" >';
  734. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  735. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取全部关注" />';
  736. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  737. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  738. html += ' </div>';
  739. html += '</div>';
  740.  
  741. javaex.panel(this, {
  742. position: "right",
  743. content: html
  744. });
  745.  
  746. $('#batchFollow_uidList').bind('input propertychange', function() {
  747.  
  748. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  749.  
  750. });
  751.  
  752. $("#disFollow_thisUp").bind("click", async function() {
  753.  
  754. HNAPI.batchModify(BiliData.this_uid, 5);
  755.  
  756. });
  757.  
  758. $("#Follow_thisUp").bind("click", async function() {
  759.  
  760. HNAPI.batchModify(BiliData.this_uid);
  761.  
  762. });
  763.  
  764. $("#batchFollow_beg").bind("click", async function() {
  765.  
  766. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  767. mid_list = mid_str.split(",");
  768.  
  769. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  770. for (const mids of mid_Lists) {
  771.  
  772. HNAPI.batchModify(mids.toString());
  773. await HNTOOL.Sleep(8000);
  774. }
  775.  
  776. alert("关注完成!")
  777.  
  778. });
  779.  
  780. $("#crawler_follow").bind("click", async function() {
  781.  
  782. //x/space/myinfo
  783. let myinfoData = await HNAPI.getMyinfo();
  784. await HNAPI.getUpCard(myinfoData.mid);
  785. await HNTOOL.Sleep(1000);
  786. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  787. let followData = [];
  788.  
  789. for (let i = 0; i < len; i++) {
  790. if (BiliData.upCard.code != 0) {
  791. javaex.tip({
  792. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  793. type: "error"
  794. });
  795. break;
  796. }
  797.  
  798. javaex.tip({
  799. content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
  800. type: "success"
  801. });
  802.  
  803. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  804. if (followList != null) {
  805. for (const fl of followList.list) {
  806.  
  807. /* if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  808. continue;
  809. } */
  810.  
  811. followData.push(fl.mid);
  812.  
  813. }
  814. }
  815.  
  816.  
  817. await HNTOOL.Sleep(3000);
  818. }
  819.  
  820. document.getElementById("batchFollow_uidList").value = followData.toString();
  821.  
  822. });
  823.  
  824.  
  825. });
  826.  
  827. $("#batchTargetMedal").bind("click", async function() {
  828.  
  829.  
  830. let html = '';
  831. html += '<div class="javaex-panel-box" style="width: 600px;">';
  832. html += ' <div class="javaex-unit clear">';
  833. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  834. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  835. html +=
  836. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  837. html += ' </div>';
  838. html += ' </div>';
  839. html += ' <div class="javaex-unit clear tc" >';
  840. html += ' <input type="button" id="batchTargetMedal_beg" class="javaex-btn yes" value="开始" />';
  841. html += ' </div>';
  842. html += '</div>';
  843.  
  844. javaex.panel(this, {
  845. position: "right",
  846. content: html
  847. });
  848.  
  849. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  850.  
  851. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  852.  
  853. });
  854.  
  855. $("#batchTargetMedal_beg").bind("click", async function() {
  856.  
  857. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  858. let room_list = room_str.split(",");
  859.  
  860.  
  861. for (const room of room_list) {
  862.  
  863. let uid = await HNAPI.getRoomMsg(room);
  864. await HNTOOL.Sleep(500);
  865.  
  866. if (uid == false) {
  867.  
  868. javaex.tip({
  869. content: room + "获取勋章失败!",
  870. type: "error"
  871. });
  872.  
  873. continue;
  874. }
  875.  
  876. let result = await HNAPI.getFansMedalInfo(uid, room);
  877.  
  878. if (result) {
  879. javaex.tip({
  880. content: room + "勋章已经存在!",
  881. type: "success"
  882. });
  883. continue;
  884. }
  885. //获取包裹列表
  886. let giftRes = await HNAPI.getGiftList(room);
  887.  
  888. if (giftRes == false) {
  889.  
  890. continue;
  891. }
  892.  
  893. let bag_id = null;
  894.  
  895. for (let gr of giftRes) {
  896.  
  897. if (gr.gift_id == 3) {
  898.  
  899. bag_id = gr.bag_id;
  900. break;
  901. }
  902.  
  903. }
  904. if (bag_id != null) {
  905.  
  906. await HNAPI.bagSendGift(uid, room, bag_id);
  907. }
  908.  
  909.  
  910.  
  911. await HNTOOL.Sleep(5000);
  912. }
  913.  
  914. alert("批量送b克拉完毕!")
  915.  
  916.  
  917. });
  918.  
  919.  
  920. });
  921.  
  922.  
  923. $("#HNSetup").bind("click", async function() {
  924.  
  925. var CONFIG = HNTOOL.getConfig();
  926.  
  927.  
  928. let html = '';
  929.  
  930. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  931. html += '<form id="HNGG_SETUP">'
  932. html += ' <div class="javaex-unit clear">'
  933. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  934. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  935. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  936. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  937. html += ' </div>'
  938. html += ' <div class="javaex-unit-left mr-10">'
  939. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  940. html += ' </div>'
  941. html += ' </div>'
  942. html += '</form>';
  943. html += '<div class="javaex-unit clear tc">';
  944. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  945. html += '</div>';
  946. html += '<hr class="javaex-divider"></hr>';
  947. html += '</div>';
  948.  
  949. javaex.panel(this, {
  950. position: "right",
  951. content: html
  952. });
  953.  
  954.  
  955. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  956.  
  957. $("#switch-qsmg").bind("click", function() {
  958.  
  959. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  960.  
  961. })
  962.  
  963.  
  964. $("#HNSetup_save").bind("click", async function() {
  965.  
  966.  
  967. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  968.  
  969. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  970.  
  971. javaex.tip({
  972. content: "设置成功!",
  973. type: "success"
  974. });
  975.  
  976. });
  977.  
  978. });
  979.  
  980. //
  981. $("#getUpMassage").bind("click", async function() {
  982.  
  983.  
  984. let html = '';
  985.  
  986. html += '<div style="padding: 10px 10px 10px 0px;">'
  987. html += '<form id="getUpMassage_form">'
  988. html += ' <div class="javaex-unit clear">'
  989. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  990. html += ' <div class="javaex-unit-left mr-10">'
  991. html +=
  992. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  993. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  994. html += ' </div>'
  995. html += ' <div class="javaex-unit-right mr-10">'
  996. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  997. html += ' </div>'
  998. html += ' </div>'
  999. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  1000. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  1001. html += ' <thead>'
  1002. html += ' <tr><th>内容</th><th>详情</th></tr>'
  1003. html += ' </thead>'
  1004. html += ' <tbody id="upMsgTbody">'
  1005.  
  1006. html += ' </tbody>'
  1007. html += '</table> '
  1008. html += '</div>'
  1009. html += '</form>';
  1010. html += '<hr class="javaex-divider"></hr>';
  1011. html += '</div>';
  1012.  
  1013.  
  1014. javaex.panel(this, {
  1015. position: "right",
  1016. content: html
  1017. });
  1018.  
  1019. javaex.table({
  1020. id: "upMsgTable",
  1021. isDragColWidth: true, // 是否允许拖动改变列宽
  1022. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1023. leftFixedColNum: 2, // 左侧固定列数
  1024. rightFixedColNum: 1, // 右侧固定列数
  1025. sort: {
  1026. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1027. "2": "update_time"
  1028. },
  1029. sortCallback: function(rtn) {
  1030. //console.log(rtn.sortArr);
  1031. }
  1032. });
  1033.  
  1034. //
  1035. $("#getUpMsg").click(async function() {
  1036.  
  1037. let thismid = javaex.getSelectVal("#up_uid");
  1038. await HNAPI.userInfo(thismid)
  1039.  
  1040. let temp = await HNAPI.getUpCard(thismid);
  1041.  
  1042.  
  1043. await HNTOOL.Sleep(500);
  1044.  
  1045.  
  1046. if (temp != false) {
  1047. let data = BiliData.upCard.data;
  1048.  
  1049. let html = ``;
  1050. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1051. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1052. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1053. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1054. html +=
  1055. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1056. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1057. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1058. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1059. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1060. html +=
  1061. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1062. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1063. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1064.  
  1065.  
  1066. $("#upMsgTbody").empty();
  1067. $("#upMsgTbody").append(html);
  1068. }
  1069.  
  1070.  
  1071. });
  1072. //点击放大
  1073. /* $("img").click(function() {
  1074. javaex.dialog({
  1075. type : "image", // 弹出层类型
  1076. url : $(this).attr("src") // 图片地址
  1077. });
  1078. });*/
  1079.  
  1080. });
  1081.  
  1082.  
  1083. $("#everyDayTask").bind("click", async function() {
  1084.  
  1085. let videoAid = 758643487;
  1086. let videoCid = 357521682;
  1087. let videoBvid = "BV1V64y1d7ed";
  1088. let videoMid = 99439379;
  1089.  
  1090. await HNAPI.clickNow();
  1091. await HNTOOL.Sleep(3000);
  1092.  
  1093. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  1094. await HNAPI.DoSign();
  1095. await HNTOOL.Sleep(3000);
  1096.  
  1097.  
  1098. //2.每日观看视频 获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1099. let archivesList = await HNAPI.getDynamicRegion();
  1100. await HNTOOL.Sleep(2000);
  1101. //2.每日观看视频 获取分区最新专栏列表
  1102. let articleData = await HNAPI.getArticleRecommends();
  1103. await HNTOOL.Sleep(2000);
  1104.  
  1105. let num = HNTOOL.random(0, archivesList.length - 1);
  1106. let article = articleData[HNTOOL.random(0, 18)];
  1107.  
  1108. if (archivesList != false && num != 2) {
  1109.  
  1110. videoAid = archivesList[num].aid;
  1111. videoBvid = archivesList[num].bvid;
  1112. videoCid = archivesList[num].cid;
  1113. videoMid = archivesList[num].owner.mid;
  1114. }
  1115.  
  1116. await HNAPI.playOneVideo(videoBvid, videoMid);
  1117. await HNTOOL.Sleep(2000);
  1118. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1119.  
  1120. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1121. await HNTOOL.Sleep(2000);
  1122.  
  1123.  
  1124. await HNAPI.addShare(videoAid);
  1125.  
  1126.  
  1127.  
  1128.  
  1129.  
  1130. });
  1131.  
  1132.  
  1133. $("#dynamicActivity").bind("click", async function() {
  1134.  
  1135. javaex.tip({
  1136. content: "动态转发开始!",
  1137. type: "success"
  1138. });
  1139.  
  1140. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1141. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1142. await HNTOOL.Sleep(2000);
  1143.  
  1144. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1145.  
  1146. let value = dynamic_id_list[index];
  1147.  
  1148. let dynamic_data = await HNAPI.getdynamicData(value);
  1149.  
  1150. if (dynamic_data.hasOwnProperty('card') == false) {
  1151. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1152. continue;
  1153. }
  1154. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1155. let dynamic_type = 17;
  1156. await HNTOOL.Sleep(2000);
  1157.  
  1158. if (dynamic_data.card.desc.is_liked == 1) {
  1159. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1160. continue;
  1161. }
  1162. //判断是否过期
  1163. if (dynamic_data.card.desc.type == 2) {
  1164. dynamic_type = 11;
  1165. dynamic_id = dynamic_data.card.desc.rid;
  1166. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1167. await HNTOOL.Sleep(2000);
  1168.  
  1169. if (lNoticeData.lottery_time * 1000 <= (new Date()).getTime()) {
  1170.  
  1171.  
  1172. console.log(
  1173. "【" + index + "已过开奖时间】\n" +
  1174. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1175. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n"
  1176. );
  1177. continue;
  1178. }
  1179.  
  1180. }
  1181. //0.判断是否关注
  1182. /* if (dynamic_data.attentions.uids.indexOf(dynamic_data.card.desc.uid) == -1) {
  1183.  
  1184. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1185. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "无需关注!!!");
  1186. await HNTOOL.Sleep(1000);
  1187. } */
  1188. HNAPI.batchModify(dynamic_data.card.desc.uid);
  1189. console.log("【" + index + "】" + dynamic_data.card.desc.uid + "已关注!!!");
  1190. await HNTOOL.Sleep(1000);
  1191.  
  1192. //1.评论
  1193. await HNAPI.addReply(dynamic_id, dynamic_type);
  1194. console.log("【" + index + "】" + dynamic_id + "评论成功!!!");
  1195. await HNTOOL.Sleep(1000);
  1196. //3.点赞
  1197. await HNAPI.likeDynamic(value);
  1198. await HNTOOL.Sleep(1000);
  1199. //2.转发
  1200. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1201. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1202. if (repostCard["user"]["uname"] != undefined && dynamic_data.card.desc.type == 1) {
  1203. repostStr = HNTOOL.getRandomWordOfList(replyList) + "//@" + repostCard.user.uname + " :" + repostCard.item.content;
  1204. }
  1205. await HNAPI.repostDynamic(value, repostStr);
  1206. await HNTOOL.Sleep(1000);
  1207. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1208.  
  1209. javaex.tip({
  1210. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1211. type: "success"
  1212. });
  1213.  
  1214. //存储标记
  1215. //await HNAPI.setNotice(value);
  1216.  
  1217. //随机延迟120 -240秒
  1218. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1219. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1220. javaex.tip({
  1221. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1222. type: "success"
  1223. });
  1224. await HNTOOL.Sleep(sleeptime);
  1225. }
  1226.  
  1227. alert("今日动态抽奖完成!!!");
  1228.  
  1229. });
  1230.  
  1231. $("#batchFollowOfbastard").bind("click", async function() {
  1232.  
  1233. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证(官方&&个人)的关注! \n 不确定使用请取消!")) {
  1234.  
  1235. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1236.  
  1237. if (fansNum != null && fansNum != "") {
  1238. //fansNum
  1239.  
  1240. let followList = await HNAPI.getAllFollow();
  1241. console.log(followList);
  1242. await HNTOOL.Sleep(2000);
  1243.  
  1244. for (let fl of followList) {
  1245.  
  1246. if (fl == 99439379) {
  1247. continue;
  1248. }
  1249. let user = await HNAPI.getCardByUID(fl);
  1250. await HNTOOL.Sleep(1000);
  1251. if (user.fans < parseInt(fansNum) && user.official_verify.type == -1) {
  1252.  
  1253. await HNAPI.cancelAtt(fl, 2);
  1254.  
  1255. javaex.tip({
  1256. content: "uid:" + user.mid + "-" + user.name + "---符合条件 取关成功!!!",
  1257. type: "success"
  1258. });
  1259. console.log("uid:" + user.mid + "-" + user.name + "--符合条件 取关成功!!!");
  1260.  
  1261. } else {
  1262. javaex.tip({
  1263. content: "uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!",
  1264. type: "success"
  1265. });
  1266. console.log("uid:" + user.mid + "-" + user.name + "---不符合条件 取消!!!");
  1267. }
  1268. }
  1269. }
  1270.  
  1271. }
  1272.  
  1273. });
  1274.  
  1275.  
  1276. $("#reserveActivity").bind("click", async function() {
  1277.  
  1278.  
  1279. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1280. let myjson = await HNAPI.getMyJson(url);
  1281.  
  1282. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1283. if (typeof(lastSid) == "undefined") {
  1284. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1285. }
  1286. lastSid = lastSid.split("&")[1];
  1287.  
  1288.  
  1289.  
  1290. for (const sid in myjson) {
  1291.  
  1292. if (lastSid >= sid) {
  1293.  
  1294. continue;
  1295. }
  1296.  
  1297. let siddata = myjson[sid];
  1298. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1299. //await HNTOOL.Sleep(2000);
  1300.  
  1301. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1302. await HNAPI.reserveActivity(sid);
  1303. await HNTOOL.Sleep(2000);
  1304.  
  1305. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') +
  1306. //"\n --预约SID:" + siddata.sid +
  1307. //"\n --预约UID:" + siddata.upmid +
  1308. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1309. "\n --预约人数:" + siddata.total + "人" +
  1310. "\n --预约奖品:" + siddata.prizeInfo.text;
  1311.  
  1312. console.log(tiplog);
  1313.  
  1314. javaex.tip({
  1315. content: tiplog,
  1316. type: "success"
  1317. });
  1318.  
  1319. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1320.  
  1321. HNTOOL.saveConfig();
  1322.  
  1323. }
  1324.  
  1325.  
  1326. alert("预约抽奖结束");
  1327. });
  1328.  
  1329. $("#plateActivity").bind("click", async function() {
  1330.  
  1331. //获取轮盘数据
  1332.  
  1333. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1334. let myjson = await HNAPI.getMyJson(url);
  1335. let lmt = 0;
  1336. let k = 20; //重试次数 防止卡主
  1337. let giftArr = [];
  1338. let endAtion = [];
  1339.  
  1340. javaex.tip({
  1341. content: "开始参加轮盘!!!",
  1342. type: "success"
  1343. });
  1344.  
  1345. await HNAPI.getUserNav();
  1346. await HNTOOL.Sleep(1500);
  1347.  
  1348.  
  1349. for (const json of myjson) {
  1350. //let x = json.name;
  1351. for (let i = 0; i < 20; i++) {
  1352. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1353. let resout = await HNAPI.addLotteryTimes(json.sid);
  1354.  
  1355. await HNTOOL.Sleep(200);
  1356. if (resout == 1) {
  1357.  
  1358. endAtion.push(json.name + ":活动已结束!");
  1359. javaex.tip({
  1360. content: json.name + "活动已结束!",
  1361. type: "success"
  1362. });
  1363.  
  1364. break;
  1365. }
  1366. if (resout != 0 && resout != 1) {
  1367.  
  1368. javaex.tip({
  1369. content: json.name + resout,
  1370. type: "error"
  1371. });
  1372.  
  1373. break;
  1374. }
  1375.  
  1376. if (resout == 0) {
  1377.  
  1378. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1379. continue;
  1380. }
  1381.  
  1382. }
  1383.  
  1384. javaex.tip({
  1385. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1386. type: "success"
  1387. });
  1388.  
  1389. await HNTOOL.Sleep(1500);
  1390.  
  1391. for (let i = 0; i < lmt; i++) {
  1392.  
  1393. let gift = await HNAPI.lotteryDo(json.sid);
  1394.  
  1395.  
  1396. if (gift == true) {
  1397.  
  1398. javaex.tip({
  1399. content: "点击过快,9秒后自动重试!!!",
  1400. type: "error"
  1401. });
  1402.  
  1403. i--;
  1404. k--;
  1405. }
  1406.  
  1407. if (gift == false || k == 0) {
  1408. break;
  1409. }
  1410.  
  1411. if (gift != "未中奖0" && gift != true) {
  1412. giftArr.push(json.name + "奖品为:" + gift);
  1413. break;
  1414. } else {
  1415. javaex.tip({
  1416. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1417. type: "success"
  1418. });
  1419. }
  1420. await HNTOOL.Sleep(9000);
  1421.  
  1422. }
  1423.  
  1424.  
  1425. }
  1426.  
  1427.  
  1428. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1429. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1430.  
  1431. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1432. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1433.  
  1434.  
  1435. });
  1436.  
  1437. $("#addPlay").bind("click", async function() {
  1438.  
  1439.  
  1440. let html = '';
  1441.  
  1442. html += '<div style="padding: 10px 10px 10px 0px;">'
  1443. html += '<form id="getUpMassage_form">'
  1444.  
  1445. html += ' <div class="javaex-unit clear">'
  1446. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1447. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1448. html +=
  1449. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1450. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1451. html += ' </div>'
  1452. html += ' </div>'
  1453. html += ' <div class="javaex-unit clear">'
  1454. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1455. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1456. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1457. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1458. html += ' </div>'
  1459. html += ' </div>'
  1460. html += '</form>';
  1461. html += ' <div class="javaex-unit clear tc">'
  1462. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1463. html += ' </div>'
  1464. html += '<hr class="javaex-divider"></hr>';
  1465. html += '</div>';
  1466.  
  1467.  
  1468. javaex.panel(this, {
  1469. position: "right",
  1470. content: html
  1471. });
  1472.  
  1473. $("#addPlay_bgn").click(async function() {
  1474.  
  1475. let MID = javaex.getSelectVal("#addPlay_uid")
  1476. let BV = javaex.getSelectVal("#addPlay_bv");
  1477. let bvArr = [];
  1478. let bvArr2 = [];
  1479.  
  1480. MID = javaex.ifnull(MID, BiliData.author_uid);
  1481.  
  1482.  
  1483. if (BV == "0") {
  1484.  
  1485. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1486. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1487. await HNTOOL.Sleep(500);
  1488. bvArr2 = BiliData.BVList;
  1489.  
  1490. for (let i = 1; i > 0; i++) {
  1491.  
  1492. HNAPI.getUpAllBV(MID, i);
  1493.  
  1494. await HNTOOL.Sleep(500);
  1495.  
  1496. if (BiliData.BVList.length == 0) {
  1497. if (bvArr.length == 0) {
  1498. javaex.tip({
  1499. content: "该用户无投稿视频,请确认是否有误!",
  1500. type: "success"
  1501. });
  1502. await HNTOOL.Sleep(2000);
  1503. }
  1504. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1505. bvArr = bvArr.concat(bvArr2);
  1506. break;
  1507. }
  1508.  
  1509. bvArr = bvArr.concat(BiliData.BVList);
  1510. }
  1511.  
  1512.  
  1513. if (bvArr.length != 0) {
  1514.  
  1515. for (const emt of bvArr) {
  1516.  
  1517. HNAPI.playOneVideo(emt.bvid, MID);
  1518.  
  1519. await HNTOOL.Sleep(2000);
  1520.  
  1521. }
  1522.  
  1523. alert("播放完成!!!");
  1524.  
  1525. }
  1526.  
  1527.  
  1528. } else {
  1529. //1.调用点击播放接口
  1530. //2.发送心跳
  1531.  
  1532. await HNTOOL.Sleep(500);
  1533.  
  1534. HNAPI.playOneVideo(BV);
  1535. }
  1536.  
  1537.  
  1538. });
  1539.  
  1540.  
  1541. });
  1542.  
  1543. }
  1544.  
  1545.  
  1546. let addSetPage = async function() {
  1547.  
  1548. HNTOOL.Sleep(1000);
  1549.  
  1550. $('body').append('' +
  1551. '<div id="left_navbar">' +
  1552. '<div class="javaex-menu-container"> ' +
  1553. ' <div id="menu" class="javaex-menu"> ' +
  1554. ' <ul> ' +
  1555. ' <li class="javaex-menu-item alone hover" > ' +
  1556. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1557. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1558. ' </li> ' +
  1559. ' </ul> ' +
  1560. ' <ul> ' +
  1561. ' <li class="javaex-menu-item"> ' +
  1562. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1563. ' <ul> ' +
  1564. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1565. ' </ul> ' +
  1566. ' </li> ' +
  1567. ' <li id="chackList" class="javaex-menu-item"> ' +
  1568. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1569. ' <ul> ' +
  1570. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1571. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1572. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1573. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1574. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1575. ' </ul> ' +
  1576. ' </li> ' +
  1577. ' <li class="javaex-menu-item"> ' +
  1578. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1579. ' <ul> ' +
  1580. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1581. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1582. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1583. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  1584. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1585. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1586. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1587. ' </ul> ' +
  1588. ' </li> ' +
  1589. ' <li class="javaex-menu-item"> ' +
  1590. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1591. ' <ul> ' +
  1592. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  1593. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1594. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1595. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1596. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1597. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1598. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  1599. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1600. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1601. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1602. ' </ul> ' +
  1603. ' </li> ' +
  1604. ' <li class="javaex-menu-item"> ' +
  1605. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1606. ' <ul> ' +
  1607. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  1608. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1609. ' </ul> ' +
  1610. ' </li> ' +
  1611.  
  1612. ' </ul> ' +
  1613. ' </div> ' +
  1614. '</div>' +
  1615. '</div>');
  1616. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1617.  
  1618. javaex.menu({
  1619. id: "menu",
  1620. isShowAll: false
  1621. });
  1622.  
  1623. }
  1624.  
  1625.  
  1626.  
  1627.  
  1628. let showUnreadMsg = function() {
  1629.  
  1630. var html = '';
  1631. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1632. html += ' <ul>';
  1633. html += ` <p style="color: #FFF;">用户消息</p>`;
  1634. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1635. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1636. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1637. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1638. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1639. html += ' <hr class="javaex-divider"></hr>';
  1640. html += ' </ul>';
  1641. html += '</div>';
  1642.  
  1643.  
  1644. javaex.panel(document.getElementById("getUnread"), {
  1645. position: "right",
  1646. content: html
  1647. });
  1648.  
  1649. javaex.tip({
  1650. content: "查询用户通知成功!",
  1651. type: "success"
  1652. });
  1653.  
  1654. }
  1655.  
  1656. /**
  1657. * 检查 艾特信息
  1658. * @returns {Promise<void>}
  1659. */
  1660. let chackAtMsg = async function(items) {
  1661.  
  1662. await HNTOOL.Sleep(500);
  1663.  
  1664. if (items != false && typeof(items) != "undefined") {
  1665.  
  1666.  
  1667. var html = '';
  1668. html += '<div class="javaex-panel-box" style="width: auto;">';
  1669. html += ' <ul>';
  1670. html += ` <p style="color: #FFF;">@信息</p>`;
  1671. items.forEach(function(item) {
  1672.  
  1673. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1674. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1675. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1676.  
  1677. html +=
  1678. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1679. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1680. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1681. html += ' <hr class="javaex-divider"></hr>';
  1682. });
  1683. html += ' </ul>';
  1684. html += '</div>';
  1685.  
  1686.  
  1687. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1688. javaex.panel(document.getElementById("getAtMsg"), {
  1689. position: "right",
  1690. content: html
  1691. });
  1692. } else {
  1693. javaex.panel(document.getElementById("chackList"), {
  1694. position: "right",
  1695. content: html
  1696. });
  1697. }
  1698.  
  1699.  
  1700. }
  1701.  
  1702. }
  1703.  
  1704.  
  1705. let addStyle = function() {
  1706. const animate = GM_getResourceText('animate');
  1707. const common = GM_getResourceText('common');
  1708. const defaultCss = GM_getResourceText('defaultCss');
  1709. //const icomoonex = GM_getResourceText('icomoonex');
  1710. //const AllCss = animate + common + defaultCss + icomoonex;
  1711. const AllCss = animate + common + defaultCss;
  1712. const style = document.createElement('style');
  1713. style.innerHTML = AllCss;
  1714. return document.getElementsByTagName('head')[0].appendChild(style);
  1715. }
  1716.  
  1717. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1718.  
  1719.  
  1720. /*-----------------------------------------------常用API--------------------------------------------------*/
  1721.  
  1722. let HNAPI = {
  1723.  
  1724.  
  1725. getLotteryNotice: async function(dynamic_id) {
  1726. return new Promise((resolve) => {
  1727. Ajax.get({
  1728. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  1729. queryStringsObj: {
  1730. "dynamic_id": dynamic_id
  1731. },
  1732. hasCookies: true,
  1733. success: responseText => {
  1734. let res = HNTOOL.strToJson(responseText);
  1735. if (res.code === 0) {
  1736.  
  1737. resolve(res.data);
  1738.  
  1739. } else {
  1740. console.log("获取开奖信息失败:" + res.message);
  1741. resolve(false);
  1742. }
  1743. }
  1744. })
  1745. });
  1746. },
  1747.  
  1748.  
  1749. likeDynamic: async function(dynamic_id) {
  1750.  
  1751. return new Promise((resolve) => {
  1752. Ajax.post({
  1753. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  1754. hasCookies: true,
  1755. dataType: 'application/x-www-form-urlencoded',
  1756. data: {
  1757. uid: Live_info.uid,
  1758. dynamic_id: dynamic_id,
  1759. up: 1,
  1760. csrf: Live_info.csrf_token
  1761. },
  1762. success: responseText => {
  1763. let res = HNTOOL.strToJson(responseText);
  1764. if (res.code === 0) {
  1765.  
  1766. javaex.tip({
  1767. content: "动态点赞成功!",
  1768. type: "success"
  1769. });
  1770.  
  1771. resolve(true);
  1772. } else {
  1773.  
  1774. console.log("动态点赞发生错误!" + res.message);
  1775.  
  1776. javaex.tip({
  1777. content: "动态点赞发生错误!" + res.message,
  1778. type: "error"
  1779. });
  1780.  
  1781. resolve(false);
  1782. }
  1783. }
  1784. })
  1785. });
  1786. },
  1787.  
  1788. repostDynamic: async function(dynamic_id, content) {
  1789.  
  1790. return new Promise((resolve) => {
  1791. Ajax.post({
  1792. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  1793. dataType: 'application/x-www-form-urlencoded',
  1794. hasCookies: true,
  1795. data: {
  1796. uid: Live_info.uid,
  1797. dynamic_id: dynamic_id,
  1798. content: content,
  1799. csrf: Live_info.csrf_token
  1800. },
  1801. success: responseText => {
  1802. let res = HNTOOL.strToJson(responseText);
  1803. if (res.code === 0) {
  1804.  
  1805. javaex.tip({
  1806. content: "动态转发成功!",
  1807. type: "success"
  1808. });
  1809.  
  1810. resolve(true);
  1811. } else {
  1812.  
  1813. console.log("动态转发发生错误!" + res.message);
  1814.  
  1815. javaex.tip({
  1816. content: "动态转发发生错误!" + res.message,
  1817. type: "error"
  1818. });
  1819.  
  1820. resolve(false);
  1821. }
  1822. }
  1823. })
  1824. });
  1825. },
  1826.  
  1827. addReply: async function(oid, type) {
  1828.  
  1829. return new Promise((resolve) => {
  1830. Ajax.post({
  1831. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  1832. dataType: 'application/x-www-form-urlencoded',
  1833. hasCookies: true,
  1834. data: {
  1835. "oid": oid,
  1836. "type": type, //11官方 17 加码
  1837. "ordering": 'heat',
  1838. "message": HNTOOL.getRandomWordOfList(replyList),
  1839. "jsonp": 'jsonp',
  1840. "csrf": Live_info.csrf_token
  1841. },
  1842. success: responseText => {
  1843. let res = HNTOOL.strToJson(responseText);
  1844. if (res.code === 0) {
  1845. javaex.tip({
  1846. content: "'自动评论成功'!",
  1847. type: "success"
  1848. });
  1849. resolve(0);
  1850. } else if (res.code === -404) {
  1851. console.log('自动评论原动态已删除');
  1852. resolve(0);
  1853. } else if (res.code === 12002) {
  1854. console.log('自动评论评论区已关闭');
  1855. resolve(0);
  1856. } else if (res.code === 12015) {
  1857. console.log('自动评论需要输入验证码');
  1858. resolve(1);
  1859. } else {
  1860. console.log('自动评论', `评论失败\n${responseText}`);
  1861. resolve(0);
  1862. }
  1863. }
  1864. })
  1865. });
  1866. },
  1867.  
  1868.  
  1869. setNotice: async function(notice) {
  1870.  
  1871. return new Promise((resolve) => {
  1872. Ajax.post({
  1873. url: BILIBLI_PATH.api + '/x/space/notice/set',
  1874. hasCookies: true,
  1875. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1876. data: {
  1877. notice: notice,
  1878. jsonp: 'jsonp',
  1879. csrf: Live_info.csrf_token
  1880. },
  1881. success: responseText => {
  1882. let res = HNTOOL.strToJson(responseText);
  1883. if (res.code === 0) {
  1884.  
  1885. javaex.tip({
  1886. content: "动态标记保存到个人公告成功!",
  1887. type: "success"
  1888. });
  1889.  
  1890. resolve(true);
  1891. } else {
  1892.  
  1893. javaex.tip({
  1894. content: res.message,
  1895. type: "error"
  1896. });
  1897.  
  1898. resolve(false);
  1899. }
  1900. }
  1901. })
  1902. });
  1903. },
  1904.  
  1905. getSpaceNotice: async function() {
  1906. return new Promise((resolve) => {
  1907. Ajax.get({
  1908. url: BILIBLI_PATH.api + '/x/space/notice',
  1909. queryStringsObj: {
  1910. "mid": Live_info.uid
  1911. },
  1912. hasCookies: true,
  1913. success: responseText => {
  1914. let res = HNTOOL.strToJson(responseText);
  1915. if (res.code === 0) {
  1916.  
  1917. resolve(res.data);
  1918.  
  1919. } else {
  1920. console.log("获取公告信息失败:" + res.message);
  1921. resolve(false);
  1922. }
  1923. }
  1924. })
  1925. });
  1926. },
  1927.  
  1928. getdynamicData: async function(dynamic_id_str) {
  1929. return new Promise((resolve) => {
  1930. Ajax.get({
  1931.  
  1932. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  1933. queryStringsObj: {
  1934. "dynamic_id": dynamic_id_str
  1935. },
  1936. hasCookies: true,
  1937. success: responseText => {
  1938. let res = HNTOOL.strToJson(responseText);
  1939. if (res.code === 0) {
  1940.  
  1941. resolve(res.data);
  1942.  
  1943. } else {
  1944. console.log("获取动态信息失败:" + res.message);
  1945. resolve(false);
  1946. }
  1947. }
  1948. })
  1949. });
  1950. },
  1951.  
  1952. getAllFollow: async function() {
  1953. return new Promise((resolve) => {
  1954. Ajax.get({
  1955.  
  1956. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  1957. queryStringsObj: {
  1958. "uid": Live_info.uid
  1959. },
  1960. hasCookies: true,
  1961. success: responseText => {
  1962. let res = HNTOOL.strToJson(responseText);
  1963. if (res.code === 0) {
  1964.  
  1965. resolve(res.data.list);
  1966.  
  1967. } else {
  1968. console.log("查询失败!" + res.message);
  1969. resolve(false);
  1970. }
  1971. }
  1972. })
  1973. });
  1974. },
  1975.  
  1976. getCardByUID: async function(UID) {
  1977. return new Promise((resolve) => {
  1978. Ajax.get({
  1979.  
  1980. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1981. queryStringsObj: {
  1982. "mid": UID
  1983. },
  1984. hasCookies: true,
  1985. success: responseText => {
  1986. let res = HNTOOL.strToJson(responseText);
  1987. if (res.code === 0) {
  1988.  
  1989. resolve(res.data.card);
  1990.  
  1991. } else {
  1992. console.log("查询失败!" + res.message);
  1993. resolve(false);
  1994. }
  1995. }
  1996. })
  1997. });
  1998. },
  1999.  
  2000.  
  2001. /**
  2002. *
  2003. *
  2004. */
  2005.  
  2006. getTodayDynamicList: async function(mid, indexStr) {
  2007. return new Promise((resolve) => {
  2008. Ajax.get({
  2009.  
  2010. url: BILIBLI_PATH.api + '/x/space/article',
  2011. queryStringsObj: {
  2012. "mid": mid,
  2013. "pn": 1,
  2014. "ps": 12,
  2015. "sort": 'publish_time'
  2016. },
  2017. hasCookies: true,
  2018. success: responseText => {
  2019. let res = HNTOOL.strToJson(responseText);
  2020. if (res.code === 0) {
  2021. let artlist = false;
  2022.  
  2023. for (let art of res.data.articles) {
  2024.  
  2025. //if (art.title.indexOf("抽奖合集") > -1) {
  2026. if (art.title.indexOf(indexStr) > -1) {
  2027. artlist = art;
  2028. break;
  2029. }
  2030. }
  2031. resolve(artlist);
  2032. } else {
  2033.  
  2034.  
  2035. console.log("查询失败!" + res.message);
  2036. resolve(false);
  2037. }
  2038. }
  2039. })
  2040. });
  2041. },
  2042.  
  2043. getDataByLiveSid: async function(ids) {
  2044. return new Promise((resolve) => {
  2045. Ajax.get({
  2046.  
  2047. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  2048. queryStringsObj: {
  2049. "ids": ids
  2050. },
  2051. hasCookies: true,
  2052. success: responseText => {
  2053. let res = HNTOOL.strToJson(responseText);
  2054. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  2055.  
  2056. resolve(res.data.list);
  2057. } else {
  2058.  
  2059. /* javaex.tip({
  2060. content: "查询失败!" + res.message,
  2061. type: "error"
  2062. }); */
  2063. console.log("查询失败!" + res.message);
  2064.  
  2065. resolve(false);
  2066. }
  2067. }
  2068. })
  2069. });
  2070. },
  2071.  
  2072. /**
  2073. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  2074. */
  2075. clickNow: async function() {
  2076. return new Promise((resolve) => {
  2077. Ajax.get({
  2078.  
  2079. url: BILIBLI_PATH.api + '/x/report/click/now',
  2080. queryStringsObj: {
  2081. jsonp: "jsonp"
  2082. },
  2083. hasCookies: true,
  2084. success: responseText => {
  2085. let res = HNTOOL.strToJson(responseText);
  2086. if (res.code === 0) {
  2087.  
  2088. javaex.tip({
  2089. content: "每日登录" + res.data.text,
  2090. type: "success"
  2091. });
  2092. resolve(true);
  2093.  
  2094. } else {
  2095.  
  2096. javaex.tip({
  2097. content: res.message,
  2098. type: "error"
  2099. });
  2100.  
  2101. resolve(false);
  2102. }
  2103. }
  2104. })
  2105. });
  2106. },
  2107.  
  2108. /**
  2109. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  2110. * @param {number} videoAid
  2111. */
  2112. addShare: async function(videoAid) {
  2113. return new Promise((resolve) => {
  2114. Ajax.post({
  2115. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  2116. hasCookies: true,
  2117. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2118. data: {
  2119. aid: videoAid,
  2120. csrf: Live_info.csrf_token
  2121. },
  2122. success: responseText => {
  2123. let res = HNTOOL.strToJson(responseText);
  2124. if (res.code === 0) {
  2125.  
  2126. javaex.tip({
  2127. content: "每日分享视频成功",
  2128. type: "success"
  2129. });
  2130.  
  2131. resolve(true);
  2132. } else {
  2133.  
  2134. javaex.tip({
  2135. content: res.message,
  2136. type: "error"
  2137. });
  2138.  
  2139. resolve(false);
  2140. }
  2141. }
  2142. })
  2143. });
  2144. },
  2145.  
  2146.  
  2147.  
  2148. /**
  2149. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2150. * @param {number} videoAid
  2151. */
  2152. addArticleCoin: async function(cvID, mid) {
  2153. return new Promise((resolve) => {
  2154. Ajax.post({
  2155. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2156. hasCookies: true,
  2157. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2158. data: {
  2159. aid: cvID,
  2160. upid: mid,
  2161. multiply: 2,
  2162. avtype: 2,
  2163. csrf: Live_info.csrf_token
  2164. },
  2165. success: responseText => {
  2166. let res = HNTOOL.strToJson(responseText);
  2167. if (res.code === 0) {
  2168.  
  2169. javaex.tip({
  2170. content: '专栏:' + cvID + "投币成功",
  2171. type: "success"
  2172. });
  2173.  
  2174. resolve(true);
  2175. } else {
  2176.  
  2177. javaex.tip({
  2178. content: res.message,
  2179. type: "error"
  2180. });
  2181.  
  2182. console.log('专栏投币失败:' + cvID + res.message);
  2183.  
  2184. resolve(false);
  2185. }
  2186. }
  2187. })
  2188. });
  2189. },
  2190.  
  2191. /**
  2192. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  2193. * @param {number} videoAid
  2194. */
  2195. addVideoCoin: async function(videoAid) {
  2196. return new Promise((resolve) => {
  2197. Ajax.post({
  2198. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  2199. hasCookies: true,
  2200. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2201. data: {
  2202. aid: videoAid,
  2203. multiply: 2,
  2204. select_like: 0,
  2205. cross_domain: true,
  2206. csrf: Live_info.csrf_token
  2207. },
  2208. success: responseText => {
  2209. let res = HNTOOL.strToJson(responseText);
  2210. if (res.code === 0) {
  2211.  
  2212. javaex.tip({
  2213. content: "投币成功",
  2214. type: "success"
  2215. });
  2216.  
  2217. resolve(true);
  2218. } else {
  2219.  
  2220. javaex.tip({
  2221. content: res.message,
  2222. type: "error"
  2223. });
  2224.  
  2225. resolve(false);
  2226. }
  2227. }
  2228. })
  2229. });
  2230. },
  2231.  
  2232.  
  2233. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  2234.  
  2235. DoSign: async function() {
  2236. return new Promise((resolve) => {
  2237. Ajax.get({
  2238.  
  2239. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  2240. queryStringsObj: {
  2241.  
  2242. },
  2243. hasCookies: true,
  2244. success: responseText => {
  2245. let res = HNTOOL.strToJson(responseText);
  2246. if (res.code === 0) {
  2247.  
  2248. javaex.tip({
  2249. content: "签到成功:" + res.data.text,
  2250. type: "success"
  2251. });
  2252. resolve(true);
  2253.  
  2254. } else if (res.code === 1011040) {
  2255.  
  2256. javaex.tip({
  2257. content: res.message,
  2258. type: "success"
  2259. });
  2260.  
  2261. resolve(true);
  2262. } else {
  2263.  
  2264. javaex.tip({
  2265. content: res.message,
  2266. type: "error"
  2267. });
  2268.  
  2269. resolve(false);
  2270. }
  2271. }
  2272. })
  2273. });
  2274. },
  2275.  
  2276.  
  2277. /**
  2278. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  2279. */
  2280. getArticleRecommends: async function() {
  2281. return new Promise((resolve) => {
  2282. Ajax.get({
  2283.  
  2284. url: BILIBLI_PATH.api + '/x/article/recommends',
  2285. queryStringsObj: {
  2286. "cid": 0,
  2287. "pn": 1
  2288. },
  2289. hasCookies: true,
  2290. success: responseText => {
  2291. let res = HNTOOL.strToJson(responseText);
  2292. if (res.code === 0) {
  2293.  
  2294. javaex.tip({
  2295. content: "获取最新专栏成功!",
  2296. type: "success"
  2297. });
  2298. resolve(res.data);
  2299.  
  2300. } else {
  2301.  
  2302. javaex.tip({
  2303. content: "获取最新专栏失败!" + res.message,
  2304. type: "error"
  2305. });
  2306.  
  2307. console.log(res.message);
  2308.  
  2309. resolve(false);
  2310. }
  2311. }
  2312. })
  2313. });
  2314. },
  2315. /**
  2316. * // 获取分区最新视频列表
  2317. */
  2318. getDynamicRegion: async function() {
  2319. return new Promise((resolve) => {
  2320. Ajax.get({
  2321.  
  2322. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  2323. queryStringsObj: {
  2324. "pn": 1,
  2325. "ps": 20,
  2326. "rid": 21
  2327. },
  2328. hasCookies: true,
  2329. success: responseText => {
  2330. let res = HNTOOL.strToJson(responseText);
  2331. if (res.code === 0) {
  2332.  
  2333. javaex.tip({
  2334. content: "获取分区最新视频成功",
  2335. type: "success"
  2336. });
  2337. resolve(res.data.archives);
  2338.  
  2339. } else {
  2340.  
  2341. javaex.tip({
  2342. content: "获取分区最新视频失败" + res.message,
  2343. type: "error"
  2344. });
  2345.  
  2346. resolve(false);
  2347. }
  2348. }
  2349. })
  2350. });
  2351. },
  2352.  
  2353. /*
  2354. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  2355. * @param {Object} sid
  2356. */
  2357. reserveActivity: async function(sid) {
  2358. return new Promise((resolve) => {
  2359. Ajax.post({
  2360. url: BILIBLI_PATH.api + '/x/space/reserve',
  2361. hasCookies: true,
  2362. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2363. data: {
  2364. sid: sid, //当前用户
  2365. jsonp: "jsonp",
  2366. csrf: Live_info.csrf_token
  2367. },
  2368. success: responseText => {
  2369. let res = HNTOOL.strToJson(responseText);
  2370. if (res.code === 0) {
  2371.  
  2372. resolve(true);
  2373. } else {
  2374. javaex.tip({
  2375. content: res.message,
  2376. type: "error"
  2377. });
  2378. resolve(false);
  2379. }
  2380. }
  2381. })
  2382. });
  2383. },
  2384. /**
  2385. reserveActivity: async function(sid, reserve_total) {
  2386. return new Promise((resolve) => {
  2387. Ajax.post({
  2388. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  2389. hasCookies: true,
  2390. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2391. data: {
  2392. reserve_id: sid,
  2393. cur_btn_status: 1,
  2394. reserve_total: reserve_total,
  2395. csrf: Live_info.csrf_token
  2396. },
  2397. success: responseText => {
  2398. let res = HNTOOL.strToJson(responseText);
  2399. if (res.code === 0) {
  2400.  
  2401. resolve(res.data);
  2402. } else {
  2403.  
  2404. javaex.tip({
  2405. content: res.message,
  2406. type: "error"
  2407. });
  2408.  
  2409. resolve(false);
  2410. }
  2411. }
  2412. })
  2413. });
  2414. }, */
  2415.  
  2416. getGiftList: async function(room) {
  2417. return new Promise((resolve) => {
  2418. Ajax.get({
  2419.  
  2420. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  2421. queryStringsObj: {
  2422. "room_id": room
  2423. },
  2424. hasCookies: true,
  2425. success: responseText => {
  2426. let res = HNTOOL.strToJson(responseText);
  2427. if (res.code === 0) {
  2428.  
  2429. resolve(res.data.list);
  2430. } else {
  2431.  
  2432. javaex.tip({
  2433. content: "查询包裹失败!" + res.message,
  2434. type: "error"
  2435. });
  2436.  
  2437. resolve(false)
  2438. }
  2439. }
  2440. })
  2441. });
  2442. },
  2443.  
  2444. /**
  2445. * 送银B克拉
  2446. * @param {Object} ruid
  2447. * @param {Object} roomid
  2448. */
  2449. bagSendGift: async function(ruid, roomid, bag_id) {
  2450. return new Promise((resolve) => {
  2451. Ajax.post({
  2452. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  2453. hasCookies: true,
  2454. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2455. data: {
  2456. uid: Live_info.uid, //当前用户
  2457. gift_id: 3,
  2458. ruid: ruid,
  2459. send_ruid: 0,
  2460. gift_num: 1,
  2461. bag_id: bag_id,
  2462. //rnd: Math.round(new Date() / 1000); //时间戳,
  2463. platform: 'pc',
  2464. biz_code: 'Live',
  2465. biz_id: roomid,
  2466. storm_beat_id: 0,
  2467. price: 0,
  2468. csrf_token: Live_info.csrf_token,
  2469. csrf: Live_info.csrf_token
  2470.  
  2471. },
  2472. success: responseText => {
  2473. let res = HNTOOL.strToJson(responseText);
  2474. if (res.code === 0) {
  2475.  
  2476. javaex.tip({
  2477. content: roomid + "赠送b克拉成功!" + res.message,
  2478. type: "success"
  2479. });
  2480.  
  2481. resolve(true);
  2482. } else {
  2483.  
  2484. javaex.tip({
  2485. content: res.message,
  2486. type: "error"
  2487. });
  2488.  
  2489. resolve(false);
  2490. }
  2491. }
  2492. })
  2493. });
  2494. },
  2495.  
  2496.  
  2497. /**
  2498. * 判断是否有勋章
  2499. * @param {Object} uid
  2500. * @param {Object} room
  2501. */
  2502.  
  2503. getFansMedalInfo: async function(uid, room) {
  2504. return new Promise((resolve) => {
  2505. Ajax.get({
  2506.  
  2507. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  2508. queryStringsObj: {
  2509. "target_id": uid,
  2510. "room_id": room
  2511. },
  2512. //dataType:'application/json, text/plain, */*',
  2513. hasCookies: true,
  2514. success: responseText => {
  2515. let res = HNTOOL.strToJson(responseText);
  2516. if (res.code === 0) {
  2517.  
  2518. if (res.data.my_fans_medal.level == 0) {
  2519. resolve(false)
  2520. } else {
  2521. resolve(true)
  2522. }
  2523.  
  2524. } else {
  2525.  
  2526. javaex.tip({
  2527. content: "查询勋章失败!" + res.message,
  2528. type: "error"
  2529. });
  2530.  
  2531. resolve(false)
  2532. }
  2533. }
  2534. })
  2535. });
  2536. },
  2537.  
  2538.  
  2539.  
  2540.  
  2541. getDisuidList: async function(re_version, pn) {
  2542. return new Promise((resolve) => {
  2543. Ajax.get({
  2544.  
  2545. url: BILIBLI_PATH.api + '/x/relation/blacks',
  2546. queryStringsObj: {
  2547. "re_version": re_version,
  2548. "pn": pn
  2549. },
  2550. hasCookies: true,
  2551. success: responseText => {
  2552. let res = HNTOOL.strToJson(responseText);
  2553. if (res.code === 0) {
  2554. resolve(res.data.list)
  2555. } else {
  2556.  
  2557. javaex.tip({
  2558. content: "查询黑名单失败!" + res.message,
  2559. type: "error"
  2560. });
  2561.  
  2562. resolve(null)
  2563. }
  2564. }
  2565. })
  2566. });
  2567. },
  2568.  
  2569. /**
  2570. * @param {Object} uid
  2571. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  2572. */
  2573. cancelAtt: async function(uid, act, re_src) {
  2574. return new Promise((resolve) => {
  2575. Ajax.post({
  2576. url: BILIBLI_PATH.api + '/x/relation/modify',
  2577. hasCookies: true,
  2578. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2579. data: {
  2580. fid: uid,
  2581. act: act,
  2582. re_src: re_src == undefined ? 11 : 116,
  2583. jsonp: "jsonp",
  2584. csrf: Live_info.csrf_token,
  2585. },
  2586. success: responseText => {
  2587. let res = HNTOOL.strToJson(responseText);
  2588. if (res.code === 0) {
  2589.  
  2590. //HNAPI.cancelAtt(uid, 6);
  2591.  
  2592. javaex.tip({
  2593. content: "取关成功!" + res.message,
  2594. type: "success"
  2595. });
  2596.  
  2597. resolve(true);
  2598. } else if (res.code === 22003) {
  2599.  
  2600. HNAPI.cancelAtt(uid, 6);
  2601.  
  2602. javaex.tip({
  2603. content: "取消拉黑" + res.message,
  2604. type: "success"
  2605. });
  2606. resolve(true);
  2607. } else {
  2608.  
  2609. javaex.tip({
  2610. content: res.message,
  2611. type: "error"
  2612. });
  2613.  
  2614. resolve(false);
  2615. }
  2616. }
  2617. })
  2618. });
  2619. },
  2620.  
  2621. getRoomMsg: async function(roomid) {
  2622. return new Promise((resolve) => {
  2623. Ajax.get({
  2624.  
  2625. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  2626. queryStringsObj: {
  2627. "roomid": roomid
  2628. },
  2629. hasCookies: true,
  2630. success: responseText => {
  2631. let res = HNTOOL.strToJson(responseText);
  2632. if (res.code === 0) {
  2633. resolve(res.data.info.uid)
  2634. } else {
  2635. resolve(false)
  2636. }
  2637. }
  2638. })
  2639. });
  2640. },
  2641.  
  2642. /**
  2643. *
  2644. * @param sid
  2645. * @returns {Promise<unknown>}
  2646. */
  2647. lotteryDo: async function(sid) {
  2648. return new Promise((resolve) => {
  2649. Ajax.post({
  2650. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  2651. hasCookies: true,
  2652. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2653. data: {
  2654.  
  2655. sid: sid,
  2656. type: 1,
  2657. csrf: Live_info.csrf_token,
  2658. },
  2659. success: responseText => {
  2660. let res = HNTOOL.strToJson(responseText);
  2661. if (res.code === 0) {
  2662. resolve((res.data)[0].gift_name);
  2663.  
  2664. } else if (res.code === 75400) {
  2665.  
  2666. resolve(true);
  2667. } else {
  2668. javaex.tip({
  2669. content: "本次抽奖失败!" + res.message,
  2670. type: "error"
  2671. });
  2672. resolve(false);
  2673. }
  2674. }
  2675. })
  2676. });
  2677. },
  2678.  
  2679.  
  2680. getLotteryMytimes: async function(sid) {
  2681. return new Promise((resolve) => {
  2682. Ajax.get({
  2683. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  2684. queryStringsObj: {
  2685. sid: sid
  2686. },
  2687. hasCookies: true,
  2688. success: responseText => {
  2689. let res = HNTOOL.strToJson(responseText);
  2690. if (res.code === 0) {
  2691. resolve(res.data.times)
  2692. } else {
  2693. resolve(0)
  2694. }
  2695. }
  2696. })
  2697. });
  2698. },
  2699.  
  2700. /**
  2701. * 增加抽奖次数一般是分享
  2702. * @param sid 活动sid
  2703. * @returns {Promise<unknown>} 0 成功 1:活动结束
  2704. */
  2705. addLotteryTimes: async function(sid) {
  2706. return new Promise((resolve) => {
  2707. Ajax.post({
  2708. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  2709. hasCookies: true,
  2710. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2711. data: {
  2712.  
  2713. sid: sid,
  2714. action_type: 3,
  2715. csrf: Live_info.csrf_token,
  2716. },
  2717. success: responseText => {
  2718. let res = HNTOOL.strToJson(responseText);
  2719. if (res.code === 0) {
  2720.  
  2721. resolve(0)
  2722. } else if (res.code === 75003) {
  2723.  
  2724. resolve(1)
  2725.  
  2726. } else {
  2727.  
  2728. resolve(res.message);
  2729. }
  2730. }
  2731. })
  2732. });
  2733. },
  2734. /**
  2735. * 查询用户关注 默认一次查询50
  2736. * @param vmid 用户uid
  2737. * @param pn 页码
  2738. * @returns {Promise<unknown>}
  2739. */
  2740. getMyFollow: async function(vmid, pn) {
  2741. return new Promise((resolve) => {
  2742. Ajax.get({
  2743. url: BILIBLI_PATH.api + '/x/relation/followings',
  2744. queryStringsObj: {
  2745. vmid: vmid,
  2746. pn: pn
  2747. },
  2748. hasCookies: true,
  2749. success: responseText => {
  2750. let res = HNTOOL.strToJson(responseText);
  2751. if (res.code === 0) {
  2752. resolve(res.data)
  2753. } else {
  2754. resolve(null)
  2755. }
  2756. }
  2757. })
  2758. });
  2759. },
  2760.  
  2761.  
  2762. getMyinfo: function() {
  2763. return new Promise((resolve) => {
  2764. Ajax.get({
  2765. url: BILIBLI_PATH.api + '/x/space/myinfo',
  2766. queryStringsObj: {},
  2767. hasCookies: true,
  2768. success: responseText => {
  2769. let res = HNTOOL.strToJson(responseText);
  2770. if (res.code === 0) {
  2771. resolve(res.data)
  2772. } else {
  2773. resolve(null)
  2774. }
  2775. }
  2776. })
  2777. });
  2778. },
  2779.  
  2780. getMyJson: function(url) {
  2781. return new Promise((resolve) => {
  2782. GM_xmlhttpRequest({
  2783. method: "GET",
  2784. url: url,
  2785. onload: function(response) {
  2786. const res = HNTOOL.strToJson((response || {}).responseText)
  2787. resolve(res);
  2788. }
  2789. });
  2790. })
  2791. },
  2792.  
  2793.  
  2794. userInfo: function(mid) {
  2795.  
  2796. Ajax.get({
  2797. url: BILIBLI_PATH.api + '/x/space/acc/info',
  2798. queryStringsObj: {
  2799. mid: mid
  2800. },
  2801. hasCookies: true,
  2802. success: responseText => {
  2803.  
  2804. var json = JSON.parse(responseText);
  2805.  
  2806. if (json.code != 0) {
  2807.  
  2808.  
  2809. }
  2810. }
  2811. });
  2812.  
  2813. },
  2814.  
  2815. sendQmsg: async function(key, msg) {
  2816.  
  2817. $.ajax({
  2818. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  2819.  
  2820. success: function(result) {
  2821.  
  2822. }
  2823. });
  2824.  
  2825.  
  2826. /*GM_xmlhttpRequest({
  2827. method: "GET",
  2828. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  2829. onload: function (response) {
  2830.  
  2831. let json = JSON.parse(response.response);
  2832. if (json.code == 0) {
  2833.  
  2834. javaex.tip({
  2835. content: "自动动态中奖提醒成功!" + json.reason,
  2836. type: "success"
  2837. });
  2838. } else {
  2839. console.log("自动动态中奖提醒失败!" + json.reason);
  2840. javaex.tip({
  2841. content: "自动动态中奖提醒失败!" + json.reason,
  2842. type: "error"
  2843. });
  2844. }
  2845.  
  2846. }
  2847. });*/
  2848.  
  2849. },
  2850.  
  2851. /**
  2852. * 批量关注和拉黑 batchModify
  2853. *
  2854. * https://api.bilibili.com/x/relation/batch/modify
  2855. * @param uid
  2856. */
  2857.  
  2858. batchModify: function(uids, act) {
  2859.  
  2860.  
  2861. Ajax.post({
  2862. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2863. hasCookies: true,
  2864. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2865. data: {
  2866.  
  2867. "fids": uids,
  2868. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2869. "re_src": 151,
  2870. csrf: Live_info.csrf_token,
  2871. },
  2872. success: responseText => {
  2873.  
  2874. let json = JSON.parse(responseText);
  2875.  
  2876. if (/^{"code":0/.test(responseText)) {
  2877.  
  2878. javaex.tip({
  2879. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  2880. type: "success"
  2881. });
  2882.  
  2883. } else {
  2884. javaex.tip({
  2885. content: "关注失败!" + json.message,
  2886. type: "error"
  2887. });
  2888. }
  2889. }
  2890. })
  2891. },
  2892.  
  2893.  
  2894. /**
  2895. * //https://api.bilibili.com/x/relation/modify
  2896. *
  2897. * @param UID
  2898. */
  2899. disUserByUid: function(vmid) {
  2900.  
  2901. Ajax.post({
  2902. url: BILIBLI_PATH.api + '/x/relation/modify',
  2903. data: {
  2904. fid: parseInt(vmid),
  2905. re_src: 11,
  2906. act: 5,
  2907. jsonp: "jsonp",
  2908. csrf: Live_info.csrf_token,
  2909. },
  2910. hasCookies: true,
  2911. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2912. success: responseText => {
  2913.  
  2914. var json = JSON.parse(responseText);
  2915.  
  2916. if (json.code != 0) {
  2917.  
  2918. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2919. javaex.tip({
  2920. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2921. type: "error"
  2922. });
  2923.  
  2924. } else {
  2925. console.log("拉黑用户成功 uid:" + vmid);
  2926. javaex.tip({
  2927. content: "拉黑用户成功 uid:" + vmid,
  2928. type: "success"
  2929. });
  2930. }
  2931. }
  2932. });
  2933.  
  2934. },
  2935. /**
  2936. * http://api.bilibili.com/x/web-interface/view
  2937. * @param BV
  2938. * 心跳间隔15秒
  2939. */
  2940. playOneVideo: function(BV, MID) {
  2941.  
  2942. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2943. Ajax.post({
  2944. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2945. hasCookies: true,
  2946. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2947. data: {
  2948.  
  2949. "bvid": BV,
  2950. "part": 1,
  2951. "mid": Live_info.uid,
  2952. "lv": 2,
  2953. "jsonp": "jsonp",
  2954. "type": 3,
  2955. "sub_type": 0
  2956. },
  2957. success: responseText => {
  2958.  
  2959. let json = JSON.parse(responseText);
  2960.  
  2961. if (/^{"code":0/.test(responseText)) {
  2962. //发送一次心跳
  2963. HNAPI.sendHeartbeat(BV, MID);
  2964.  
  2965. } else {
  2966. javaex.tip({
  2967. content: "视频" + data.bvid + "播放失败!" + json.message,
  2968. type: "error"
  2969. });
  2970. }
  2971. }
  2972. })
  2973.  
  2974.  
  2975. },
  2976.  
  2977. //上报视频播放心跳(web端)
  2978. /**
  2979. * http://api.bilibili.com/x/click-interface/web/heartbeat
  2980. * @param json
  2981. */
  2982. sendHeartbeat: function(bvid, MID) {
  2983.  
  2984. Ajax.post({
  2985. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  2986. hasCookies: true,
  2987. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2988. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  2989. data: {
  2990. "bvid": bvid,
  2991. "type": 3,
  2992. "dt": 2,
  2993. "played_time": HNTOOL.random(12, 40),
  2994. "realtime": HNTOOL.random(12, 40),
  2995. "play_type": 0
  2996. },
  2997. success: responseText => {
  2998.  
  2999. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  3000.  
  3001. javaex.tip({
  3002. content: "视频BV" + bvid + "播放一次!",
  3003. type: "success"
  3004. });
  3005. }
  3006. }
  3007. })
  3008.  
  3009. },
  3010.  
  3011. //获取up所有投稿视频
  3012. /**
  3013. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  3014. * @param mid
  3015. */
  3016. getUpAllBV: function(mid, pn, ps) {
  3017. ps = (ps === undefined ? 30 : ps); // a默认值为1
  3018. Ajax.get({
  3019. url: BILIBLI_PATH.api + '/x/space/arc/search',
  3020. queryStringsObj: {
  3021. mid: mid,
  3022. tid: 0,
  3023. order: 'pubdate',
  3024. jsonp: 'jsonp',
  3025. pn: pn,
  3026. ps: ps
  3027. },
  3028. hasCookies: true,
  3029. success: responseText => {
  3030.  
  3031. var json = JSON.parse(responseText);
  3032.  
  3033. if (json.code != 0) {
  3034.  
  3035. javaex.tip({
  3036. content: "获取up所有投稿视频失败!" + json.message,
  3037. type: "success"
  3038. });
  3039.  
  3040. } else {
  3041. BiliData.BVList = json.data.list.vlist;
  3042.  
  3043. }
  3044. }
  3045. });
  3046.  
  3047. },
  3048.  
  3049.  
  3050. /**
  3051. *
  3052. * @param path
  3053. * @param data
  3054. * @param saveObj
  3055. * @param Func
  3056. */
  3057. publicGet: function(path, queryStringsObj) {
  3058.  
  3059. if (typeof(queryStringsObj) != "undefined") {
  3060. queryStringsObj = {};
  3061. }
  3062. Ajax.get({
  3063. url: BILIBLI_PATH.api + path,
  3064. queryStringsObj: queryStringsObj,
  3065. hasCookies: true,
  3066. success: responseText => {
  3067.  
  3068. let json = JSON.parse(responseText);
  3069. if (chackCode(json.code) && json.code == 0) {
  3070.  
  3071. return json.data;
  3072. }
  3073.  
  3074. return false;
  3075.  
  3076. }
  3077. })
  3078.  
  3079. },
  3080.  
  3081. /**
  3082. * 导航栏用户信息
  3083. */
  3084. getUserNav: async function() {
  3085.  
  3086. GM_xmlhttpRequest({
  3087. method: "GET",
  3088. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  3089. //timeout:3000,
  3090. onload: function(response) {
  3091.  
  3092. let json = JSON.parse(response.response);
  3093. console.log(json);
  3094. BiliData.login_code = json.code;
  3095. BiliData.login_message = json.message;
  3096. BiliData.LoginData = json.data;
  3097.  
  3098. }
  3099. });
  3100.  
  3101. },
  3102.  
  3103. /**
  3104. * 获取某up详细信息
  3105. * http://api.bilibili.com/x/web-interface/card
  3106. */
  3107. getUpCard: function(mid) {
  3108.  
  3109. Ajax.get({
  3110. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3111. queryStringsObj: {
  3112. mid: mid,
  3113. photo: false
  3114. },
  3115. hasCookies: true,
  3116. success: responseText => {
  3117.  
  3118. var json = JSON.parse(responseText);
  3119.  
  3120. if (json.code != 0) {
  3121.  
  3122. javaex.tip({
  3123. content: "查询失败!" + json.message,
  3124. type: "success"
  3125. });
  3126. return false;
  3127. } else {
  3128. BiliData.upCard = json;
  3129.  
  3130. }
  3131.  
  3132.  
  3133. }
  3134. })
  3135.  
  3136. },
  3137.  
  3138. /**
  3139. *
  3140. * @param uid 用户uid
  3141. * @param ps 每页视频个数 默认30个
  3142. * @param pn 第几页
  3143. */
  3144. getUpAllVideo: function(uid, ps, pn) {
  3145.  
  3146. },
  3147. getChallenge: async function() {
  3148.  
  3149.  
  3150. },
  3151. /**
  3152. * 硬币记录
  3153. * @returns {Promise<void>}
  3154. */
  3155. getCoinLog: async function() {
  3156.  
  3157. GM_xmlhttpRequest({
  3158. method: "GET",
  3159. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  3160. //url: "http://api.bilibili.com/x/member/web/coin/log",
  3161. onload: function(response) {
  3162.  
  3163. let json = JSON.parse(response.response);
  3164. if (json.code == 0) {
  3165.  
  3166. console.log("硬币记录" + json);
  3167. BiliData.CoinLog = json.data;
  3168.  
  3169. return true;
  3170. }
  3171.  
  3172. }
  3173. });
  3174. },
  3175. /**
  3176. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  3177. * @returns {Promise<void>}
  3178. */
  3179. getUnread: async function() {
  3180.  
  3181. Ajax.get({
  3182. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3183. hasCookies: true,
  3184. success: responseText => {
  3185.  
  3186. let json = JSON.parse(responseText);
  3187. if (chackCode(json.code) && json.code == 0) {
  3188.  
  3189. BiliData.Unread = json.data;
  3190. showUnreadMsg();
  3191. }
  3192.  
  3193. return false;
  3194.  
  3195. }
  3196. })
  3197.  
  3198. /* GM_xmlhttpRequest({
  3199. method: "GET",
  3200. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  3201. onload: function (response) {
  3202.  
  3203. let json = JSON.parse(response.response);
  3204.  
  3205. if (chackCode(json.code) && json.code == 0) {
  3206.  
  3207. BiliData.Unread = json.code;
  3208. showUnreadMsg();
  3209.  
  3210. }
  3211.  
  3212. }
  3213. });*/
  3214. },
  3215. /**
  3216. *
  3217. * @param type reply:回复我的 at @我的
  3218. */
  3219. getMsgfeed: function(type) {
  3220. Ajax.get({
  3221. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  3222. queryStringsObj: {
  3223. build: 0,
  3224. mobi_app: 'web'
  3225. },
  3226. hasCookies: true,
  3227. success: responseText => {
  3228.  
  3229. var json = JSON.parse(responseText);
  3230.  
  3231. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  3232. return false;
  3233. } else {
  3234. chackAtMsg(json.data.items);
  3235.  
  3236. return true;
  3237. }
  3238.  
  3239.  
  3240. }
  3241. })
  3242.  
  3243. },
  3244.  
  3245. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  3246. * @returns {Promise<void>}
  3247. */
  3248. getUnrewad: async function() {
  3249.  
  3250. GM_xmlhttpRequest({
  3251. method: "GET",
  3252. data: {
  3253. "mid": 99439379,
  3254. "pn": 1,
  3255. "ps": 5,
  3256. },
  3257. url: BILIBLI_PATH.api + "/x/space/arc/search",
  3258. onload: function(response) {
  3259.  
  3260. let json = JSON.parse(response.response);
  3261. if (json.code == 0) {
  3262.  
  3263. BiliData.Video = json.data;
  3264. console.log("未读消息数" + json);
  3265. }
  3266.  
  3267. }
  3268. });
  3269. },
  3270.  
  3271. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  3272. * @param {number} oid
  3273. * @param {nbumber} rpid
  3274. * @param {number} action
  3275. * @returns {Promise<void>}
  3276. * type: 11
  3277. * ordering: heat
  3278. * jsonp: jsonp
  3279. * csrf: 54a******* CSRF Token(位于cookie)
  3280. */
  3281.  
  3282. likeInDynamicComments: async function(latestDynamic) {
  3283.  
  3284.  
  3285. Ajax.post({
  3286. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  3287. hasCookies: true,
  3288. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3289. data: {
  3290. "oid": oid,
  3291. "type": 11,
  3292. "rpid": rpid,
  3293. "action": action,
  3294. "ordering": "heat",
  3295. "jsonp": "jsonp",
  3296. "csrf": Live_info.csrf_token,
  3297. },
  3298. success: responseText => {
  3299.  
  3300. if (/^{"code":0/.test(responseText)) {
  3301.  
  3302. BiliData.replyAction = JSON.parse(responseText);
  3303. console.log("点赞成功!" + responseText);
  3304. }
  3305. }
  3306. })
  3307.  
  3308. }
  3309.  
  3310.  
  3311. }
  3312.  
  3313. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  3314. var http_request = null;
  3315.  
  3316. function send_request(url, method) {}
  3317.  
  3318. let HNTOOL = {
  3319.  
  3320. getLatestDynamic: async function() {
  3321.  
  3322. let date = new Date();
  3323. let thisMonth = date.getMonth() + 1;
  3324. let thisday = date.getDate();
  3325. let thisdate = thisMonth + "月" + thisday < 10 ? '0' + thisday : thisday + "日";
  3326. let thisdate2 = (thisMonth < 10 ? '0' + thisMonth : thisMonth) + '-' + (thisday < 10 ? '0' + thisday : thisday);
  3327. let thisdate2_1 = (thisMonth < 10 ? '0' + thisMonth : thisMonth) + '-' + (thisday < 10 ? '0' + (thisday-1) : thisday-1);
  3328. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, thisdate);
  3329. let latestDynamic2 = await HNAPI.getTodayDynamicList(226257459, "抽奖合集");
  3330. let latestDynamic3 = await HNAPI.getTodayDynamicList(2295698, thisdate2);
  3331. if(latestDynamic3 == false){
  3332. latestDynamic3 = await HNAPI.getTodayDynamicList(2295698, thisdate2_1);
  3333. }
  3334.  
  3335.  
  3336. let ld1 = await HNTOOL.getDynamicIdList(latestDynamic);
  3337. await HNTOOL.Sleep(1000);
  3338. let ld2 = await HNTOOL.getDynamicIdList(latestDynamic2);
  3339. await HNTOOL.Sleep(1000);
  3340. let ld3 = await HNTOOL.getDynamicIdList(latestDynamic3);
  3341. await HNTOOL.Sleep(1000);
  3342. return HNTOOL.arrUnique(ld1.concat(ld2.concat(ld3)), false);
  3343.  
  3344.  
  3345. },
  3346.  
  3347. getDynamicIdList: async function(latestDynamic) {
  3348.  
  3349.  
  3350. let returnlist = [];
  3351. return new Promise((resolve) => {
  3352. Ajax.get({
  3353. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3354. queryStringsObj: {},
  3355. dataType: "html",
  3356. hasCookies: false,
  3357. success: responseText => {
  3358. let datalist = HNTOOL.httpString(responseText);
  3359. let dls;
  3360. for (let dl of datalist) {
  3361.  
  3362. let len = dl.indexOf("?");
  3363. if (len == -1) {
  3364. dl += "?tab=2";
  3365. }
  3366. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  3367. if (returnlist.indexOf(dls) > -1 || dls == null || dl.indexOf("read") > -1 || dl.indexOf("html") > -1) {
  3368. continue;
  3369. }
  3370. /* let len = dl.indexOf("?");
  3371. if (len > -1) {
  3372. dls = dl.substring(len - 18, len);
  3373. }
  3374.  
  3375. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3376. continue;
  3377. } */
  3378. returnlist.push(dls);
  3379.  
  3380. }
  3381. resolve(HNTOOL.arrUnique(returnlist, false));
  3382.  
  3383. if (datalist.length == 0) {
  3384. resolve(false);
  3385. }
  3386. }
  3387. })
  3388. });
  3389. },
  3390.  
  3391.  
  3392. /* getDynamicIdList: async function() {
  3393.  
  3394.  
  3395. let latestDynamic = await HNAPI.getTodayDynamicList();
  3396. let returnlist = [];
  3397. $.ajax({
  3398. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  3399. dataType: "html",
  3400. success: function(data) {
  3401. let datalist = HNTOOL.httpString(data);
  3402.  
  3403. let dls;
  3404. for (let dl of datalist) {
  3405. let len = dl.indexOf("?");
  3406. if (len > -1) {
  3407. dls = dl.substring(len - 18, len);
  3408. }
  3409.  
  3410. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3411. continue;
  3412. }
  3413. //https://t.bilibili.com/552091391342505523?tab=22
  3414. returnlist.push(dls);
  3415.  
  3416. }
  3417.  
  3418. return returnlist;
  3419. }
  3420. });
  3421.  
  3422. }, */
  3423.  
  3424.  
  3425.  
  3426. httpString: function(s) {
  3427. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  3428. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  3429. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3430. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3431. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  3432. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  3433. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  3434. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  3435. s = s.match(reg);
  3436. console.log(s)
  3437. return (s)
  3438. },
  3439.  
  3440. saveConfig: function() {
  3441.  
  3442. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  3443. /* javaex.tip({
  3444. content: "配置保存成功!",
  3445. type: "success"
  3446. }); */
  3447.  
  3448. },
  3449.  
  3450. copyText: function(domId) {
  3451. let btn = document.getElementById(domId);
  3452. btn.select();
  3453. if (document.execCommand('copy')) {
  3454. document.execCommand('copy');
  3455. javaex.tip({
  3456. content: "复制成功!",
  3457. type: "success"
  3458. });
  3459. }
  3460.  
  3461. },
  3462. /**
  3463. * s数组去重并排序
  3464. */
  3465.  
  3466. arrUnique: function(ary, isSort) {
  3467.  
  3468. if (isSort == undefined) {
  3469. isSort = true
  3470. }
  3471. let obj = {};
  3472. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  3473. let item = ary[i]
  3474. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  3475. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  3476. // 如果没有 将这个元素添加到对象中
  3477. if (isSort) {
  3478. ary.sort((a, b) => {
  3479. return a - b
  3480. }) // 数组去重后 按升序排列
  3481. }
  3482.  
  3483. obj = null;
  3484.  
  3485. javaex.tip({
  3486. content: "已去重!",
  3487. type: "success"
  3488. });
  3489. return ary;
  3490.  
  3491. },
  3492.  
  3493. split_array: function(arr, len) {
  3494.  
  3495. let arr_length = arr.length;
  3496. let newArr = [];
  3497. for (let i = 0; i < arr_length; i += len) {
  3498. newArr.push(arr.slice(i, i + len));
  3499. }
  3500. return newArr;
  3501. },
  3502. strToJson: function(params) {
  3503. const isJSON = (str => {
  3504. if (typeof str === 'string') {
  3505. try {
  3506. const obj = JSON.parse(str);
  3507. return typeof obj === 'object' ? obj : false
  3508. } catch (_) {
  3509. console.log(str);
  3510. return false;
  3511. }
  3512. } else {
  3513. console.log(`${str}\nIt is not a string!`);
  3514. return false;
  3515. }
  3516. })(params);
  3517. return isJSON ? isJSON : {}
  3518. },
  3519.  
  3520. chackAtMsg: function() {
  3521.  
  3522. let config = HNTOOL.getConfig();
  3523. if (config.qmsg_checked == true && config.qmsg_key) {
  3524.  
  3525. document.getElementById("getAtMsg").click();
  3526.  
  3527. }
  3528.  
  3529. },
  3530.  
  3531. cssChecked: function(id, dom) {
  3532.  
  3533. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  3534.  
  3535.  
  3536. },
  3537. getConfig: function() {
  3538.  
  3539. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  3540.  
  3541. if (CONFIG == null) {
  3542. CONFIG = HN_SETUP_CONFIG;
  3543. }
  3544.  
  3545. return CONFIG;
  3546. },
  3547.  
  3548. /**
  3549. * 获取cookie 中某个键对应的值
  3550. * @param name
  3551. */
  3552.  
  3553. getCookie: function(name) {
  3554. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  3555. if (arr != null) return escape(arr[2]);
  3556. return false;
  3557. },
  3558. /**
  3559. * 得到一个字符串数组的中随机一个
  3560. * @param {List} list
  3561. */
  3562.  
  3563.  
  3564. getRandomWordOfList: function(list) {
  3565. var L = list.length;
  3566. var i = Math.ceil(Math.random() * L);
  3567.  
  3568. return list[i];
  3569. },
  3570. random: function(min, max) {
  3571.  
  3572. return Math.floor(Math.random() * (max - min)) + min;
  3573. },
  3574.  
  3575. Sleep: function(ms) {
  3576. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  3577. }
  3578.  
  3579. }
  3580.  
  3581. let errorMsg = {
  3582. "-1": "应用程序不存在或已被封禁!",
  3583. "-2": "Access Key错误!",
  3584. "-3": "API校验密匙错误!",
  3585. "-4": "调用方对该Method没有权限!",
  3586. "-101": "账号未登录!",
  3587. "-102": "账号被封停!",
  3588. "-103": "积分不足!",
  3589. "-104": "硬币不足!",
  3590. "-105": "验证码错误!",
  3591. "-106": "账号非正式会员或在适应期!",
  3592. "-107": "应用不存在或者被封禁!",
  3593. "-108": "未绑定手机!",
  3594. "-109": "未知!",
  3595. "-110": "未绑定手机!",
  3596. "-111": "csrf 校验失败!",
  3597. "-112": "系统升级中!",
  3598. "-113": "账号尚未实名认证!",
  3599. "-114": "请先绑定手机!",
  3600. "-115": "请先完成实名认证!",
  3601. "-304": "木有改动!",
  3602. "-307": "撞车跳转!",
  3603. "-400": "请求错误!",
  3604. "-401": "未认证!",
  3605. "-403": "访问权限不足!",
  3606. "-404": "啥都木有!",
  3607. }
  3608.  
  3609. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  3610. /**
  3611. *
  3612. * @param code
  3613. * @constructor
  3614. */
  3615. let chackCode = function(code) {
  3616.  
  3617. let emsg = errorMsg[code + ""];
  3618. if (emsg != null) {
  3619. javaex.tip({
  3620. content: emsg,
  3621. type: "error"
  3622. });
  3623.  
  3624. return false;
  3625. }
  3626.  
  3627. return true;
  3628. }
  3629.  
  3630.  
  3631. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  3632. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  3633.  
  3634. /*window.onbeforeunload = function() {
  3635. if (!canLeavePage()) {
  3636. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  3637. }
  3638. };*/
  3639.  
  3640.  
  3641. /**
  3642. * Ajax请求对象
  3643. */
  3644. const Ajax = (() => {
  3645. /**
  3646. * 检查options是否符合要求
  3647. * @param {object} options
  3648. * @returns {boolean}
  3649. */
  3650. function checkOptions(options) {
  3651. let result = false;
  3652. if (typeof options !== 'object') {
  3653. console.warn('类型错误: typeof Options !== Object');
  3654. return result;
  3655. } else {
  3656. if (typeof options.url !== 'string') {
  3657. console.warn('类型错误: typeof Link !== Strings');
  3658. return result;
  3659. } else {
  3660. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  3661. if (!reg.test(options.url)) {
  3662. console.warn('url字符串须为完整http链接');
  3663. return result;
  3664. }
  3665. result = true;
  3666. }
  3667. }
  3668. return result;
  3669. }
  3670.  
  3671. /**
  3672. * 对象转URL编码
  3673. * @param {object} data
  3674. */
  3675. function objToURLCode(data) {
  3676. var _result = [];
  3677. for (var key in data) {
  3678. var value = data[key];
  3679. if (value instanceof Array) {
  3680. value.forEach(function(_value) {
  3681. _result.push(key + "=" + _value);
  3682. });
  3683. } else {
  3684. _result.push(key + '=' + value);
  3685. }
  3686. }
  3687. return _result.join('&');
  3688. }
  3689.  
  3690. /**
  3691. * 请求
  3692. * @param {string} method
  3693. * @param {object} options
  3694. */
  3695. function request(method, options) {
  3696. if (checkOptions(options)) {
  3697. let xhr = new XMLHttpRequest();
  3698. const {
  3699. url: _url,
  3700. queryStringsObj,
  3701. data,
  3702. dataType,
  3703. hasCookies
  3704. } = options, url = typeof queryStringsObj === 'object' ?
  3705. _url + '?' + objToURLCode(queryStringsObj) : _url;
  3706. switch (method) {
  3707. case 'GET':
  3708. xhr.open("GET", url);
  3709. break;
  3710. case 'POST':
  3711. xhr.open("POST", url);
  3712. xhr.setRequestHeader('Content-Type', dataType);
  3713. break;
  3714. default:
  3715. break;
  3716. }
  3717. if (hasCookies) xhr.withCredentials = true;
  3718. xhr.timeout = 3000;
  3719. xhr.addEventListener('load', () => {
  3720. if (xhr.status === 200) {
  3721. options.success(xhr.responseText)
  3722. } else {
  3723. console.error(`status:${xhr.status}`);
  3724. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  3725. }
  3726. })
  3727. xhr.addEventListener('error', () => {
  3728. console.error('ajax请求出错')
  3729. options.success('{"code":-1,"msg":"ajax请求出错"}');
  3730. })
  3731. xhr.addEventListener('timeout', () => {
  3732. console.error('请求超时')
  3733. options.success('{"code":-1,"msg":"请求超时"}');
  3734. })
  3735. switch (method) {
  3736. case 'GET':
  3737. xhr.send()
  3738. break;
  3739. case 'POST':
  3740. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  3741. break;
  3742. default:
  3743. break;
  3744. }
  3745. }
  3746. }
  3747.  
  3748. return {
  3749. /**
  3750. * 发送Get请求
  3751. * @param {Object} options
  3752. */
  3753. get(options) {
  3754. request("GET", options);
  3755. },
  3756. /**
  3757. * 发送Post请求
  3758. * @param {object} options
  3759. */
  3760. post(options) {
  3761. request("POST", options);
  3762. }
  3763. }
  3764. })()