-哔哩猫-(试用版)

练手

当前为 2021-12-07 提交的版本,查看 最新版本

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/995728/-%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 练手
  4. // @namespace http://tampermonkey.net/
  5. // @version 2.5.20
  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. // @match *://www.bilibili.com/v/newbie/*
  10. // @match *://www.bilibili.com/judgement/*
  11. // @require https://cdn.bootcss.com/jquery/3.4.1/jquery.min.js
  12. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex.min.js
  13. // @require https://cdn.jsdelivr.net/gh/java-xiaoyi/HNGG-RES@ea375a9d65253039a2ef8cde53b6a3cf421a022c/javaex/pc/js/javaex-formVerify.js
  14. // @resource animate http://cdn.javaex.cn/javaex/pc/css/animate.css
  15. // @resource common http://cdn.javaex.cn/javaex/pc/css/common.css
  16. // @resource defaultCss http://cdn.javaex.cn/javaex/pc/css/skin/default.css
  17. // @grant unsafeWindow
  18. // @grant GM_getValue
  19. // @grant GM_setValue
  20. // @grant GM_xmlhttpRequest
  21. // @grant GM_getResourceText
  22. // @grant GM_setClipboard
  23. // @grant GM_openInTab
  24. // @grant GM_addStyle
  25. // @run-at document-idle
  26. // @license MIT License
  27. // @connect github.com
  28. // @connect gitee.com
  29. // @connect api.bilibili.com
  30. // @connect qmsg.zendee.cn
  31. // @connect biliapi.net
  32. // @connect qcloud-sdkact-api.biligame.com
  33. // @connect passport.bilibili.com
  34. // @connect api.live.bilibili.com
  35. // @connect mcloc.cn
  36. // @namespace http://tampermonkey.net/
  37. // ==/UserScript==
  38.  
  39.  
  40.  
  41.  
  42. GM_addStyle(
  43. `
  44. #switch-qsmg:before {
  45. content: "开关";
  46. letter-spacing: 16px;
  47. top: 4px;
  48. left: 10px;
  49. }
  50. #left_navbar{
  51. z-index: 1000;
  52. position: absolute;
  53. top: 100px;
  54. left: 5px;
  55. }
  56. button[hnBtn="btn_open"] {
  57. z-index: 1001;
  58. z-index: 1000px;
  59. position: absolute;
  60. top: 58px;
  61. left: 220px;
  62. }
  63. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  64. top: 60px;
  65. }
  66. .javaex-menu-container {
  67. border: 1px solid #eee;
  68. }
  69. .javaex-panel-box p {
  70. text-align: center;
  71. background: #fb7299;
  72. }
  73. .fontbold{
  74. color: #00a1d6;
  75. font-weight: bold;
  76. cursor: pointer;
  77. }
  78. .hideLogo {
  79. position: absolute;
  80. top: 88px;
  81. left: 10px;
  82. width: 50px;
  83. height: 57px;
  84. z-index: 9999;
  85. cursor: pointer;
  86. }
  87. #auto_check_question {
  88. position: absolute;
  89. border-radius: 20%;
  90. font-size: 24px;
  91. text-align: center;
  92. border: 2px solid red;
  93. top: 91%;
  94. right: 44%;
  95. width: 81px;
  96. color: #fff;
  97. cursor: pointer;
  98. z-index: 999;
  99. }
  100. `
  101. );
  102.  
  103.  
  104. let HN_SETUP_CONFIG = {
  105.  
  106. qmsg_key: null, //后期改为kull 存储到本地
  107. qmsg_checked: false,
  108. Booking_last_sid: null,
  109. }
  110.  
  111. let replyList = ["哇⊙ω⊙", "仙女震惊", "都关注这么久了给个吧", "大佬,看下孩子吧,这次一定", "会有我吗?黑幕一手",
  112. "酋长在线拉低中奖率", "好耶(✪▽✪)", "好运", "希望欧一次", "永不缺席", " 永不中奖", " 永不放弃!", "万一呢", "在", "冲吖~", "来了",
  113. "芜湖,都想要,抽中那个都不亏阿", "从未中,从未停", "来力", "秋", "懂我意思吧", "今天去吃面", "从不缺席",
  114. "站友保佑抽到", "可以", "恰", "不会吧", "233", "好耶", "rush", "来了!!!", "来来", "ok", "冲", "凑热闹", "我要我要", "我还能中!", "让我中!!!",
  115. "是我的", "我是天选之子?", "给我中一次吧!", "坚持不懈,迎难而上", "开拓创新!", "我来抽个奖", "中中中中中", "我我我", "搞笑 这不得转", "我下手了",
  116. "看这里就想中一次", "不可能", "我不挑,都可以", "俺要当分母", "万一呢"
  117. ];
  118.  
  119. let HN_YUN_URL = {
  120. "tx_room": "https://gitee.com/java_cn/BILIBLI_RES/raw/master/TX/tx_room.json",
  121. "notice": "https://gitee.com/shanmite/lottery-notice/raw/master/notice.json",
  122. }
  123.  
  124. let NAME;
  125. let Live_info = {
  126. room_id: undefined,
  127. uid: undefined,
  128. blocked: undefined,
  129. csrf_token: undefined,
  130. SESSDATA: undefined,
  131. visit_id: undefined,
  132. rnd: undefined,
  133. ruid: undefined,
  134. uname: undefined,
  135. user_level: undefined,
  136. ruid: undefined,
  137. };
  138.  
  139. let BILIBLI_PATH = {
  140.  
  141. "live": "https://api.live.bilibili.com",
  142. "vcapi": "https://api.vc.bilibili.com",
  143. "passport": "https://passport.bilibili.com",
  144. "api": "https://api.bilibili.com",
  145. "video": "https://www.bilibili.com/video/",
  146. "single_unread": "http://api.vc.bilibili.com/",
  147.  
  148. }
  149.  
  150. let BILIBILI_URL = {
  151. // 导航栏用户信息
  152. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  153. }
  154.  
  155. let BiliData = {
  156.  
  157. this_uid: window.location.href.split("/")[3], //当前页面uid
  158. author_uid: 99439379,
  159. login_code: null,
  160. login_message: "",
  161. LoginData: {},
  162. CoinLog: {},
  163. Unread: null,
  164. Video: {},
  165. replyAction: {},
  166. upCard: {},
  167. BVList: [],
  168. }
  169.  
  170. window.onload = function() {
  171.  
  172.  
  173. //界面显示
  174. init();
  175.  
  176.  
  177.  
  178. addHideLogo();
  179.  
  180.  
  181. /* var myVar = setInterval(function() {
  182. console.log("yunxing");
  183. AA ();
  184. }, 1000);
  185. function AA (){
  186. if ((new Date()).getMinutes() == 47) {
  187. console.log("stop");
  188. clearInterval(myVar);
  189. }
  190. } */
  191.  
  192.  
  193. }
  194.  
  195. function addHideLogo() {
  196.  
  197. let isHide = true;
  198.  
  199. $("#left_navbar").after(
  200. '<div id="hideLogo" class="hideLogo"> <img src="https://gitee.com/java_cn/BILIBLI_RES/raw/master/PIC/PC_1606377718.gif" alt="点击显示隐藏" width="100%" height="100%"></div>'
  201. );
  202. if (isHide) {
  203. $("#left_navbar").hide();
  204. isHide = false;
  205. } else {
  206. isHide = true;
  207. }
  208. $("#hideLogo").bind("click", async function() {
  209.  
  210. if (isHide) {
  211. $("#left_navbar").hide();
  212. isHide = false;
  213. } else {
  214. $("#left_navbar").show();
  215. isHide = true;
  216. }
  217. });
  218.  
  219. let newbie = window.location.href.indexOf("newbie") > -1;
  220. if (newbie) {
  221. $("#hideLogo").hide();
  222. //document.querySelector(".tv-type-text").innerHTML += '<span id="auto_check_question">答题</span>';
  223. $("#basic-1").after('<span id="auto_check_question">答题</span>');
  224. $("#basic-2").after('<span id="auto_check_question">答题</span>');
  225.  
  226. $("#optional-qa").after('<span id="auto_check_question">答题</span>');
  227.  
  228. }
  229.  
  230. /**
  231. * 一键答题
  232. */
  233.  
  234. $("#auto_check_question").bind("click", async function() {
  235.  
  236. for (let i = 0; i < 60; i++) {
  237.  
  238. //1.查询状态
  239. let status = await HNAPI.answer_status();
  240. await HNTOOL.Sleep(1000);
  241.  
  242. if (status.progress == 100) {
  243.  
  244. let submitData = {
  245. "re_src": 0,
  246. "csrf": Live_info.csrf_token,
  247. }
  248.  
  249.  
  250. let submitReul = await HNAPI.basePost("https://api.bilibili.com/x/answer/v4/submit",
  251. submitData);
  252. window.location.reload();
  253. }
  254.  
  255. if (status.status != 3 && status.result == "failed") {
  256. // 基础题
  257. if (status.stage == "base") {
  258. //拉取题目
  259. let base = await HNAPI.pull_answer("base");
  260. if (base == 1) {
  261. continue;
  262. }
  263. if (base == false) {
  264. alert("基础题答题错误:答题过快或错误太多||用户答题记录不存在");
  265. break;
  266. }
  267. let question = base.question;
  268. for (let j = 0, len = question.options.length; j < len; j++) {
  269.  
  270. //1.答题
  271. let check = await HNAPI.answer_check(question.id, question.options[j].hash, "base");
  272. if (check == 1) {
  273. continue;
  274. }
  275. await HNTOOL.Sleep(1000);
  276. if (check.passed == true) {
  277. console.log("开始基础题第" + question.number + "题!---当前得分:" + status.score);
  278. javaex.tip({
  279. content: "开始基础题第" + question.number + "题!---当前得分:" + status.score,
  280. type: "success"
  281. });
  282. break;
  283. }
  284. }
  285.  
  286.  
  287. //附加题
  288. } else if (status.stage == "extra") {
  289.  
  290. //拉取题目
  291. let extra = await HNAPI.pull_answer("extra");
  292. if (extra == 1) {
  293. continue;
  294. }
  295. if (extra == false) {
  296. alert("违规发言题答题错误:答题过快或错误太多||用户答题记录不存在");
  297. break;
  298. }
  299. let question = extra.question;
  300. let check = await HNAPI.answer_check(question.id, question.options[0].hash, "extra");
  301. await HNTOOL.Sleep(1000);
  302. if (check == 1) {
  303. continue;
  304. }
  305. if (check.passed == true) {
  306. console.log("开始违规发言题第" + question.number + "题!---当前得分:" + status.score);
  307. javaex.tip({
  308. content: "开始违规发言题第" + question.number + "题!---当前得分:" + status.score,
  309. type: "success"
  310. });
  311. if (question.number == 50) {
  312. window.location.reload();
  313. }
  314. }
  315.  
  316. } else if (status.stage == "pro") {
  317.  
  318. //拉取题目
  319. let pro = await HNAPI.pull_answer("pro");
  320. if (pro == 1) {
  321. continue;
  322. }
  323. if (pro == false) {
  324. alert("自选题答题错误:答题过快或错误太多||用户答题记录不存在");
  325. break;
  326. }
  327. let question = pro.question;
  328. let num = HNTOOL.random(0, question.options.length);
  329. let check = await HNAPI.answer_check(question.id, question.options[num].hash, "pro");
  330. await HNTOOL.Sleep(1000);
  331. if (check == 1) {
  332. continue;
  333. }
  334. if (check.passed == true) {
  335. console.log("开始自选题第" + question.number + "题!---当前得分:" + status.score);
  336. javaex.tip({
  337. content: "开始自选题第" + question.number + "题!---当前得分:" + status.score,
  338. type: "success"
  339. });
  340.  
  341. }
  342.  
  343. } else {
  344. break;
  345. }
  346.  
  347. }
  348.  
  349. }
  350.  
  351. });
  352.  
  353.  
  354. }
  355.  
  356.  
  357. function init() {
  358.  
  359. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  360. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  361. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  362. NAME = Live_info.uid;
  363.  
  364. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&54988";
  365.  
  366.  
  367. addStyle();
  368. addSetPage();
  369.  
  370. HNTOOL.chackAtMsg();
  371.  
  372. $("#getCoinLog").bind("click", async function() {
  373.  
  374.  
  375. if (HNAPI.getCoinLog()) {
  376.  
  377. await HNTOOL.Sleep(500);
  378. let html = '';
  379. html += '<div class="javaex-panel-box" style="width: 250px;">';
  380. html += ' <ul>';
  381. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  382.  
  383. BiliData.CoinLog.list.forEach(function(item) {
  384.  
  385. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  386. if (BV.indexOf("BV") != -1) {
  387. html +=
  388. `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  389. }
  390. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  391.  
  392.  
  393. });
  394. html += ' <hr class="javaex-divider"></hr>';
  395. html += ' </ul>';
  396. html += '</div>';
  397.  
  398. javaex.panel(this, {
  399. position: "right",
  400. //offsetTop: "104",
  401. content: html
  402. });
  403. javaex.tip({
  404. content: "获取用户成功!",
  405. type: "success"
  406. });
  407.  
  408. } else {
  409. javaex.tip({
  410. content: "获取硬币记录失败,请稍后重试!",
  411. type: "error"
  412. });
  413. }
  414.  
  415.  
  416. });
  417.  
  418. $("#getUnread").bind("click", async function() {
  419.  
  420. javaex.tip({
  421. content: "获取中,请稍候...",
  422. type: "submit"
  423. });
  424. HNAPI.getUnread();
  425.  
  426.  
  427. });
  428.  
  429.  
  430. $("#likeInDynamicComments").bind("click", async function() {
  431.  
  432. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get(
  433. "likeInDynamic_PRID");
  434. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get(
  435. "likeInDynamic_OID");
  436.  
  437. let html = '';
  438.  
  439. html += '<div style="padding: 10px 10px 10px 0px;">'
  440. html += '<form id="likeInDynamic_form">'
  441. html += ' <div class="javaex-unit clear">'
  442. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  443. html += ' <div class="javaex-unit-right">'
  444. html +=
  445. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  446. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  447. html += ' </div>'
  448. html += ' </div>'
  449. html += ' <div class="javaex-unit clear">'
  450. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  451. html += ' <div class="javaex-unit-right">'
  452. html +=
  453. ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  454. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  455. html += ' </div>'
  456. html += ' </div>'
  457. html += ' <div class="javaex-unit clear tc">'
  458. html +=
  459. ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  460. html +=
  461. ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  462. html += ' </div>'
  463. html += '</form>';
  464. html += '<hr class="javaex-divider"></hr>';
  465. html += '</div>';
  466.  
  467.  
  468. javaex.panel(this, {
  469. position: "right",
  470. content: html
  471. });
  472.  
  473.  
  474. // 监听点击保存按钮事件
  475. $("#likeInDynamic_yes").click(async function() {
  476. // 表单验证函数
  477. if (javaexVerify()) {
  478.  
  479. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex
  480. .getSelectVal(
  481. "#likeInDynamic_PRID"), 1);
  482. await HNTOOL.Sleep(1000);
  483.  
  484. if (BiliData.replyAction.code == 0) {
  485.  
  486. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal(
  487. "#likeInDynamic_PRID"));
  488. LocalData.set("likeInDynamic_OID", javaex.getSelectVal(
  489. "#likeInDynamic_OID"));
  490.  
  491. javaex.tip({
  492. content: "评论区点赞成功!",
  493. type: "success"
  494. });
  495. } else {
  496. javaex.tip({
  497. content: "评论区点赞失败!",
  498. type: "error"
  499. });
  500. }
  501. if (BiliData.replyAction.code == 65006) {
  502. javaex.tip({
  503. content: "请勿重复点赞!",
  504. type: "error"
  505. });
  506. }
  507. }
  508. });
  509.  
  510. // 监听点击返回按钮事件
  511. $("#likeInDynamic_no").click(async function() {
  512.  
  513. if (javaexVerify()) {
  514.  
  515. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +
  516. javaex.getLocalStorage(
  517. "#likeInDynamic_PRID"), 0);
  518. await HNTOOL.Sleep(500);
  519.  
  520. if (BiliData.replyAction.code == 0) {
  521.  
  522. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal(
  523. "#likeInDynamic_PRID"));
  524. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal(
  525. "#likeInDynamic_OID"));
  526.  
  527. javaex.tip({
  528. content: "评论区取消点赞成功!",
  529. type: "success"
  530. });
  531. } else {
  532. javaex.tip({
  533. content: "评论区取消点赞失败!",
  534. type: "error"
  535. });
  536. }
  537. if (BiliData.replyAction.code == 65006) {
  538. javaex.tip({
  539. content: "请勿重复取消点赞!",
  540. type: "error"
  541. });
  542. }
  543. }
  544. });
  545.  
  546. });
  547.  
  548. $("#biliUserMsg").bind("click", async function() {
  549.  
  550.  
  551. //刷新信息
  552. HNAPI.getUserNav();
  553. await HNTOOL.Sleep(500);
  554.  
  555. let isLogin = "未登录";
  556. let vipType = "无";
  557. //判断是否成功
  558. if (BiliData.login_code == 0) {
  559.  
  560.  
  561. if (BiliData.LoginData.isLogin) {
  562. isLogin = "已登录";
  563. }
  564.  
  565. if (BiliData.LoginData.vipType == 1) {
  566. vipType = "月度大会员";
  567. } else if (BiliData.LoginData.vipType == 2) {
  568. vipType = "年度大会员";
  569. }
  570.  
  571. let html = '';
  572. html += '<div class="javaex-panel-box" style="width: 250px;">';
  573. html += ' <ul>';
  574. html += ` <p style="color: #FFF;">用户信息</p>`;
  575. html +=
  576. ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  577. html += ` <li>用户状态:${isLogin} </li> `;
  578. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  579. html +=
  580. ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  581. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  582. html +=
  583. ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  584. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  585. html += ` <li>会员:${vipType} </li> `;
  586. html += ' <hr class="javaex-divider"></hr>';
  587. html += ' </ul>';
  588. html += '</div>';
  589.  
  590.  
  591. javaex.panel(this, {
  592. position: "right",
  593. content: html
  594. });
  595.  
  596. javaex.tip({
  597. content: "获取用户成功!",
  598. type: "success"
  599. });
  600.  
  601. } else {
  602. javaex.tip({
  603. content: "获取用户信息失败!",
  604. type: "error"
  605. });
  606. }
  607.  
  608.  
  609. });
  610.  
  611. $("#getAtMsg").bind("click", async function() {
  612.  
  613. if (HNAPI.getMsgfeed("at") && typeof(HNAPI.getMsgfeed("at")) != "undefined") {
  614.  
  615. javaex.tip({
  616. content: "可能中奖了!!!",
  617. type: "success"
  618. });
  619. }
  620. });
  621.  
  622.  
  623. $("#disUser").bind("click", async function() {
  624.  
  625. let html = '';
  626. html += '<div class="javaex-panel-box" style="width: 500px;">';
  627. html += ' <div class="javaex-unit clear">';
  628. html += ' <div class="javaex-unit-left ml-10 mt-10">*UID列表</div>';
  629. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  630. html +=
  631. ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  632. html += ' </div>';
  633. html += ' </div>';
  634. html += ' <div class="javaex-unit clear tc">';
  635. html += ' <input type="button" id="disUser_block" class="javaex-btn yes" value="拉黑" />';
  636. html +=
  637. ' <input type="button" id="disUser_cancelAtt_uid" class="javaex-btn yes" value="UID取关" />';
  638. html +=
  639. ' <input type="button" id="disUser_cancelAtt_room" class="javaex-btn yes" value="房间号取关" />';
  640. html += ' </div>';
  641. html += '</div>';
  642.  
  643. javaex.panel(this, {
  644. position: "right",
  645. content: html
  646. });
  647.  
  648. let disUser_str;
  649. //拉黑
  650. $("#disUser_block").bind("click", async function() {
  651.  
  652. disUser_str = javaex.getSelectVal("#disUser_uidList");
  653. let disUser_uidList = disUser_str.split(",");
  654. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  655.  
  656. for (const vmid of disUserStr) {
  657.  
  658. HNAPI.batchModify(vmid.toString(), 5);
  659. await HNTOOL.Sleep(2000);
  660. }
  661. });
  662. //取关uid
  663. $("#disUser_cancelAtt_uid").bind("click", async function() {
  664. disUser_str = javaex.getSelectVal("#disUser_uidList");
  665. let disUser_uidList = disUser_str.split(",");
  666.  
  667. javaex.tip({
  668. content: "根据uid批量取关开始!!!",
  669. type: "success"
  670. });
  671.  
  672. /*
  673. let disuidList = [];
  674. let PN = 100;
  675. PN = disUser_uidList.length == 1 ? 0 : PN;
  676. for (var i = 0; i < PN; i++) {
  677. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  678. javaex.tip({
  679. content: "获取第" + i + "页黑名单成功!",
  680. type: "success"
  681. });
  682. await HNTOOL.Sleep(1000);
  683. if (uidList.length == 0) {
  684. break;
  685. }
  686. if (uidList == null) {
  687. continue;
  688. }
  689. for (let disuid of uidList) {
  690. if (disuidList.indexOf(disuid.mid) == -1) {
  691. disuidList.push(disuid.mid + "");
  692. }
  693. }
  694. } */
  695. let J = 1;
  696.  
  697. for (let uid of disUser_uidList) {
  698.  
  699. /* let uidType = "未在黑名单";
  700. if (disuidList.indexOf(uid) == -1) {
  701. await HNAPI.cancelAtt(uid, 2);
  702. } else {
  703. await HNAPI.cancelAtt(uid, 6, 116);
  704. uidType = "黑名单用户";
  705. } */
  706. await HNAPI.cancelAtt(uid, 2);
  707.  
  708. javaex.tip({
  709. content: "【UID:" + uid + "】" + "取关成功!(" + (J++) + "/" +
  710. disUser_uidList.length + ")",
  711. type: "success"
  712. });
  713. await HNTOOL.Sleep(1000);
  714. }
  715.  
  716.  
  717. alert("根据uid批量取关完成!");
  718.  
  719. /* javaex.alert({
  720. content: "根据uid批量取关完成!",
  721. confirm: function() {
  722. //return false;
  723. }
  724. }); */
  725.  
  726. });
  727. //取关room
  728. $("#disUser_cancelAtt_room").bind("click", async function() {
  729.  
  730. javaex.tip({
  731. content: "根据房间号批量取关开始!!!",
  732. type: "success"
  733. });
  734.  
  735. disUser_str = javaex.getSelectVal("#disUser_uidList");
  736. let disUser_roomList = disUser_str.split(",");
  737. /* let disuidList = [];
  738. let PN = 100;
  739. PN = disUser_roomList.length == 1 ? 0 : PN;
  740. for (var i = 0; i < PN; i++) {
  741. let uidList = await HNAPI.getDisuidList(HNTOOL.getCookie("DedeUserID"), i);
  742. javaex.tip({
  743. content: "获取第" + i + "页黑名单成功!",
  744. type: "success"
  745. });
  746. await HNTOOL.Sleep(1000);
  747. if (uidList.length == 0) {
  748. break;
  749. }
  750. if (uidList == null) {
  751. continue;
  752. }
  753. for (let disuid of uidList) {
  754. if (disuidList.indexOf(disuid.mid) == -1) {
  755. disuidList.push(disuid.mid);
  756. }
  757. }
  758. } */
  759. let J = 1;
  760. for (let room of disUser_roomList) {
  761.  
  762. let uid = await HNAPI.getRoomMsg(room);
  763.  
  764. await HNTOOL.Sleep(1000);
  765.  
  766. if (uid == false) {
  767. javaex.tip({
  768. content: "uid查询失败跳过!",
  769. type: "error"
  770. });
  771. continue;
  772. }
  773. /* let uidType = "未在黑名单";
  774. if (disuidList.indexOf(uid) == -1) {
  775. await HNAPI.cancelAtt(uid, 2);
  776. } else {
  777. await HNAPI.cancelAtt(uid, 6, 116);
  778. uidType = "黑名单用户";
  779. } */
  780. await HNAPI.cancelAtt(uid, 2);
  781.  
  782. javaex.tip({
  783. content: "Room:" + room + "-【UID:" + uid + "】" + "取关成功!(" + (J++) +
  784. "/" + disUser_roomList.length +
  785. ")",
  786. type: "success"
  787. });
  788. await HNTOOL.Sleep(1000);
  789.  
  790.  
  791. }
  792. alert("根据房间号批量取关完成!");
  793. /* javaex.alert({
  794. content: ,
  795. confirm: function() {
  796. return false;
  797. }
  798. }); */
  799.  
  800. });
  801.  
  802. });
  803.  
  804. $("#getNeetCookie").bind("click", async function() {
  805.  
  806. let html = '';
  807. html += '<div class="javaex-panel-box" style="width: 750px;">';
  808. html += ' <div class="javaex-unit clear">';
  809. html += ' <div class="javaex-unit-left ml-10 mt-10">*cookie</div>';
  810. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  811. html +=
  812. ' <textarea id="neetCookie" class="javaex-desc" placeholder="获取需要的cookie,注意需要取消掉application->cookie>SESSDATA httpOnly 的对钩"></textarea>';
  813. html += ' </div>';
  814. html += ' </div>';
  815. html += ' <div class="javaex-unit clear tc">';
  816. html += ' <input type="button" id="getCookie_type1" class="javaex-btn yes" value="方式一" />';
  817. html += ' <input type="button" id="getCookie_type2" class="javaex-btn yes" value="方式二" />';
  818. html += ' <input type="button" id="getCookie_type3" class="javaex-btn yes" value="方式三" />';
  819. html += ' <input type="button" id="getCookie_copy" class="javaex-btn yes" value="复制" />';
  820. html += ' </div>';
  821. html += '</div>';
  822.  
  823. javaex.panel(this, {
  824. position: "right",
  825. content: html
  826. });
  827.  
  828. $('#getCookie_copy').bind('click', function() {
  829.  
  830. HNTOOL.copyText("neetCookie");
  831.  
  832. });
  833.  
  834. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  835. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  836. Live_info.SESSDATA = HNTOOL.getCookie("SESSDATA");
  837.  
  838.  
  839. $("#getCookie_type1").bind("click", async function() {
  840.  
  841. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  842. .replace(/%25/g, "%") +
  843. "; bili_jct=" + Live_info.csrf_token +
  844. "; "
  845. document.getElementById("neetCookie").value = cookie01;
  846.  
  847. });
  848. $("#getCookie_type3").bind("click", async function() {
  849.  
  850. var cookie01 = "DedeUserID=" + Live_info.uid + "; SESSDATA=" + Live_info.SESSDATA
  851. .replace(/%25/g, "%%") +
  852. "; bili_jct=" + Live_info.csrf_token +
  853. "; "
  854. document.getElementById("neetCookie").value = cookie01;
  855.  
  856. });
  857.  
  858. $("#getCookie_type2").bind("click", async function() {
  859.  
  860. var cookie02 = Live_info.uid + "\n" + Live_info.SESSDATA.replace(/%25/g, "%") +
  861. "\n" + Live_info.csrf_token;
  862. document.getElementById("neetCookie").value = cookie02;
  863. });
  864.  
  865. });
  866.  
  867. $("#arrUnique").bind("click", async function() {
  868.  
  869. let html = '';
  870. html += '<div class="javaex-panel-box" style="width: 500px;">';
  871. html += ' <div class="javaex-unit clear">';
  872. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  873. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  874. html +=
  875. ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  876. html += ' </div>';
  877. html += ' </div>';
  878. html += ' <div class="javaex-unit clear tc">';
  879. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="去重" />';
  880. //html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="粘贴" />';
  881. html += ' <input type="button" id="arrUnique_copy" class="javaex-btn yes" value="复制" />';
  882. html += ' </div>';
  883. html += '</div>';
  884.  
  885. javaex.panel(this, {
  886. position: "right",
  887. content: html
  888. });
  889.  
  890. $('#arrUnique_str').bind('input propertychange', function() {
  891.  
  892. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  893.  
  894. });
  895. $('#arrUnique_copy').bind('click', function() {
  896.  
  897. HNTOOL.copyText("arrUnique_str");
  898.  
  899. });
  900.  
  901.  
  902.  
  903.  
  904. $("#arrUnique_beg").bind("click", async function() {
  905.  
  906. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  907. let arrUnique_uidList = arrUnique_str.split(",");
  908.  
  909. let new_arr = HNTOOL.arrUnique(arrUnique_uidList);
  910.  
  911. document.getElementById("arrUnique_str").value = new_arr.toString();
  912.  
  913. $('#arrNub').text("*数组" + new_arr.length);
  914.  
  915. });
  916.  
  917. });
  918.  
  919. $("#yunBatchFollow").bind("click", async function() {
  920.  
  921.  
  922. let tx_room = await HNAPI.getMyJson(HN_YUN_URL.tx_room);
  923. let notice = await HNAPI.getMyJson(HN_YUN_URL.notice);
  924. let blacklist = notice.config.blacklist.split(",");
  925. let num1 = 0;
  926. let num2 = 0;
  927. //获取关注
  928. let followList = await HNAPI.getAllFollow();
  929. await HNTOOL.Sleep(1000);
  930. let intersection = followList.filter(function (val) { return (blacklist.map(Number)).indexOf(val) > -1 });//交集
  931.  
  932. for (let room of tx_room) {
  933. let uid = await HNAPI.getRoomMsg(room);
  934. if (followList.indexOf(uid) > -1) {
  935. await HNAPI.cancelAtt(uid, 2);
  936. HNTOOL.console("取关 \n 天选相关:" + uid + "\n room:" + room, "FF0000");
  937. num1++;
  938. } else {
  939. HNTOOL.console("未关注:" + uid + "---room:" + room);
  940. }
  941. await HNTOOL.Sleep(1000);
  942. }
  943. for (let uid2 of intersection) {
  944. await HNAPI.cancelAtt(uid2, 2);
  945. HNTOOL.console("取关 \n 动态相关:" + uid2, "FF0000");
  946. }
  947.  
  948. /* for (let uid2 of blacklist) {
  949. if (followList.indexOf(uid2) > -1 && uid2 != BiliData.author_uid) {
  950. await HNAPI.cancelAtt(uid2, 2);
  951. HNTOOL.console("取关 \n 动态相关:" + uid2, "FF0000");
  952. num2++;
  953. } else {
  954. HNTOOL.console("未关注:" + uid2);
  955. }
  956. await HNTOOL.Sleep(1000);
  957. } */
  958.  
  959. alert("取关完成: \n 【天选相关-" + num1 + "】\n【动态相关-" + intersection.length + "】");
  960.  
  961.  
  962. });
  963.  
  964. $("#batchFollow").bind("click", async function() {
  965.  
  966. var thisUPName = $("#h-name").text();
  967.  
  968.  
  969. let html = '';
  970. html += '<div class="javaex-panel-box" style="width: 600px;">';
  971. html += ' <div class="javaex-unit clear">';
  972. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  973. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  974. html +=
  975. ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  976. html += ' </div>';
  977. html += ' </div>';
  978. html += ' <div class="javaex-unit clear tc" >';
  979. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  980. //html += ' <input type="button" id="check_follow" class="javaex-btn yes tc" value="筛选关注" />';
  981. html +=
  982. ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="获取全部关注" />';
  983. html += ' </div>';
  984. html += '</div>';
  985.  
  986. javaex.panel(this, {
  987. position: "right",
  988. content: html
  989. });
  990.  
  991. $('#batchFollow_uidList').bind('input propertychange', function() {
  992.  
  993. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  994.  
  995. });
  996.  
  997. $("#disFollow_thisUp").bind("click", async function() {
  998.  
  999. HNAPI.batchModify(BiliData.this_uid, 5);
  1000.  
  1001. });
  1002.  
  1003. $("#Follow_thisUp").bind("click", async function() {
  1004.  
  1005. HNAPI.batchModify(BiliData.this_uid);
  1006.  
  1007. });
  1008.  
  1009. $("#batchFollow_beg").bind("click", async function() {
  1010.  
  1011. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  1012. let mid_list = mid_str.split(",");
  1013.  
  1014. let all_ollow = await HNAPI.getAllFollow();
  1015. await HNTOOL.Sleep(1000);
  1016. //删除已关注的数据
  1017. for (let i in mid_list) {
  1018.  
  1019. if (all_ollow.indexOf(parseInt(mid_list[i])) != -1) {
  1020. mid_list.splice(i, 1);
  1021. }
  1022.  
  1023. }
  1024.  
  1025. document.getElementById("batchFollow_uidList").value = mid_list.toString();
  1026. $('#followNub').text("*关注列表" + mid_list.length);
  1027.  
  1028. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  1029. for (const mids of mid_Lists) {
  1030.  
  1031. HNAPI.batchModify(mids.toString());
  1032. await HNTOOL.Sleep(8000);
  1033. }
  1034.  
  1035. alert("关注完成!")
  1036.  
  1037. });
  1038.  
  1039. $("#crawler_follow").bind("click", async function() {
  1040.  
  1041. let followList = await HNAPI.getAllFollow();
  1042. document.getElementById("batchFollow_uidList").value = followList.toString();
  1043.  
  1044. });
  1045.  
  1046. $("#check_follow").bind("click", async function() {
  1047.  
  1048. let followList = await HNAPI.getAllFollow();
  1049. await HNTOOL.Sleep(1000);
  1050. let fList = [];
  1051. let fansmin = prompt("请输入最小粉丝数量", "5000");
  1052. let fansmax = prompt("请输入最大粉丝数量", "-1");
  1053. let fansrole = window.confirm('是否认证?');
  1054. //let fansmassage = window.confirm('是否有过私信?');
  1055. let fansfollow = window.confirm('是否执行取消关注?');
  1056.  
  1057. for (const mid of followList) {
  1058.  
  1059. if (fansmin == null || fansmax == null) {
  1060. break;
  1061. }
  1062.  
  1063.  
  1064. let midCard = await HNAPI.getInterfaceCard(mid);
  1065. await HNTOOL.Sleep(1000);
  1066. fansmax = fansmax == -1 ? Infinity : fansmax;
  1067. if (midCard.fans > fansmax || midCard.fans < fansmin) {
  1068. continue;
  1069. }
  1070.  
  1071. if ((midCard.official_verify.type != -1) == fansrole) {
  1072. fList.push(mid);
  1073. } else {
  1074. fList.push(mid);
  1075. }
  1076.  
  1077.  
  1078.  
  1079. if (fansfollow) {
  1080.  
  1081. await HNAPI.cancelAtt(mid, 2);
  1082. console.log(mid + "---" + midCard.name + "取消关注!!!")
  1083. await HNTOOL.Sleep(1000);
  1084. }
  1085. document.getElementById("batchFollow_uidList").value = fList.toString();
  1086.  
  1087. }
  1088.  
  1089.  
  1090.  
  1091. });
  1092.  
  1093.  
  1094. });
  1095.  
  1096. $("#batchTargetMedal").bind("click", async function() {
  1097.  
  1098.  
  1099. let html = '';
  1100. html += '<div class="javaex-panel-box" style="width: 600px;">';
  1101. html += ' <div class="javaex-unit clear">';
  1102. html += ' <div id="targetNub" class="javaex-unit-left ml-10 mt-10">*房间列表0</div>';
  1103. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  1104. html +=
  1105. ' <textarea id="batchTargetMedal_roomlist" class="javaex-desc" placeholder="特别注意:请填写用户真实房间号,多个用英文逗号,隔开!!"></textarea>';
  1106. html += ' </div>';
  1107. html += ' </div>';
  1108. html += ' <div class="javaex-unit clear tc" >';
  1109. html +=' <input type="button" id="batchTargetMedal_ym" class="javaex-btn yes" value="一毛勋章" />';
  1110. html +=' <input type="button" id="batchTargetMedal_ykl" class="javaex-btn yes" value="银克拉" />';
  1111. html += ' </div>';
  1112. html += '</div>';
  1113.  
  1114. javaex.panel(this, {
  1115. position: "right",
  1116. content: html
  1117. });
  1118.  
  1119. $('#batchTargetMedal_roomlist').bind('input propertychange', function() {
  1120.  
  1121. $('#targetNub').text("*房间列表" + $(this).val().split(",").length);
  1122.  
  1123. });
  1124.  
  1125. $("#batchTargetMedal_ym").bind("click", async function() {
  1126.  
  1127. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  1128. let room_list = room_str.split(",");
  1129.  
  1130.  
  1131. for (const room of room_list) {
  1132.  
  1133. let uid = await HNAPI.getRoomMsg(room);
  1134. await HNTOOL.Sleep(500);
  1135.  
  1136. if (uid == false) {
  1137.  
  1138. javaex.tip({
  1139. content: room + "获取勋章失败!",
  1140. type: "error"
  1141. });
  1142.  
  1143. continue;
  1144. }
  1145.  
  1146. let result = await HNAPI.getFansMedalInfo(uid, room);
  1147.  
  1148. if (result) {
  1149. javaex.tip({
  1150. content: room + "勋章已经存在!",
  1151. type: "success"
  1152. });
  1153. HNTOOL.console(room + "勋章已经存在!");
  1154. continue;
  1155. }
  1156.  
  1157. let sendGold_data = {
  1158. 'uid': Live_info.uid,
  1159. 'gift_id': 31164,
  1160. 'ruid': uid,
  1161. 'send_ruid': 0,
  1162. 'gift_num': 1,
  1163. 'coin_type': 'gold',
  1164. 'bag_id': 0,
  1165. 'platform': 'pc',
  1166. 'biz_code': 'Live',
  1167. 'biz_id': room,
  1168. 'platform': 'pc',
  1169. 'storm_beat_id': 0,
  1170. 'metadata': '',
  1171. 'price': 100,
  1172. 'csrf_token': Live_info.csrf_token,
  1173. 'csrf': Live_info.csrf_token,
  1174. 'visit_id': HNTOOL.getvisit_id()
  1175. };
  1176.  
  1177. let sendGold_rul = await HNAPI.basePost(
  1178. "https://api.live.bilibili.com/xlive/revenue/v1/gift/sendGold",
  1179. sendGold_data);
  1180. let tiplog = "";
  1181.  
  1182. if (sendGold_rul.code === 0) {
  1183. tiplog = "粉丝团灯牌" + room + "投喂成功!";
  1184.  
  1185. } else if (( sendGold_rul.err != undefined || sendGold_rul.code == 200013)) {
  1186. HNTOOL.console(sendGold_rul.message);
  1187. alert(sendGold_rul.message);
  1188. break;
  1189. } else {
  1190. tiplog = "粉丝团灯牌投喂失败" + sendGold_rul.message;
  1191. }
  1192.  
  1193. javaex.tip({
  1194. content: tiplog,
  1195. type: "success"
  1196. });
  1197. HNTOOL.console(tiplog);
  1198. await HNTOOL.Sleep(3000);
  1199. }
  1200.  
  1201. alert("批量送b克拉完毕!")
  1202.  
  1203.  
  1204. });
  1205.  
  1206. $("#batchTargetMedal_ykl").bind("click", async function() {
  1207.  
  1208. let room_str = javaex.getSelectVal("#batchTargetMedal_roomlist");
  1209. let room_list = room_str.split(",");
  1210.  
  1211.  
  1212. for (const room of room_list) {
  1213.  
  1214. let uid = await HNAPI.getRoomMsg(room);
  1215. await HNTOOL.Sleep(500);
  1216.  
  1217. if (uid == false) {
  1218.  
  1219. javaex.tip({
  1220. content: room + "获取勋章失败!",
  1221. type: "error"
  1222. });
  1223.  
  1224. continue;
  1225. }
  1226.  
  1227. let result = await HNAPI.getFansMedalInfo(uid, room);
  1228.  
  1229. if (result) {
  1230. javaex.tip({
  1231. content: room + "勋章已经存在!",
  1232. type: "success"
  1233. });
  1234. continue;
  1235. }
  1236. //获取包裹列表
  1237. let giftRes = await HNAPI.getGiftList(room);
  1238.  
  1239. if (giftRes == false) {
  1240.  
  1241. continue;
  1242. }
  1243.  
  1244. let bag_id = null;
  1245.  
  1246. for (let gr of giftRes) {
  1247.  
  1248. if (gr.gift_id == 3) {
  1249.  
  1250. bag_id = gr.bag_id;
  1251. break;
  1252. }
  1253.  
  1254. }
  1255. if (bag_id != null) {
  1256.  
  1257. await HNAPI.bagSendGift(uid, room, bag_id);
  1258. }
  1259.  
  1260.  
  1261.  
  1262. await HNTOOL.Sleep(3000);
  1263. }
  1264.  
  1265. alert("批量送b克拉完毕!")
  1266.  
  1267.  
  1268. });
  1269.  
  1270.  
  1271. });
  1272.  
  1273.  
  1274. $("#HNSetup").bind("click", async function() {
  1275.  
  1276. var CONFIG = HNTOOL.getConfig();
  1277.  
  1278.  
  1279. let html = '';
  1280.  
  1281. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  1282. html += '<form id="HNGG_SETUP">'
  1283. html += ' <div class="javaex-unit clear">'
  1284. html +=
  1285. ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  1286. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  1287. html +=
  1288. ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  1289. html +=
  1290. ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  1291. html += ' </div>'
  1292. html += ' <div class="javaex-unit-left mr-10">'
  1293. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  1294. html += ' </div>'
  1295. html += ' </div>'
  1296. html += '</form>';
  1297. html += '<div class="javaex-unit clear tc">';
  1298. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  1299. html += '</div>';
  1300. html += '<hr class="javaex-divider"></hr>';
  1301. html += '</div>';
  1302.  
  1303. javaex.panel(this, {
  1304. position: "right",
  1305. content: html
  1306. });
  1307.  
  1308.  
  1309. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  1310.  
  1311. $("#switch-qsmg").bind("click", function() {
  1312.  
  1313. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  1314.  
  1315. })
  1316.  
  1317.  
  1318. $("#HNSetup_save").bind("click", async function() {
  1319.  
  1320.  
  1321. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  1322.  
  1323. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1324.  
  1325. javaex.tip({
  1326. content: "设置成功!",
  1327. type: "success"
  1328. });
  1329.  
  1330. });
  1331.  
  1332. });
  1333.  
  1334. //
  1335. $("#getUpMassage").bind("click", async function() {
  1336.  
  1337.  
  1338. let html = '';
  1339.  
  1340. html += '<div style="padding: 10px 10px 10px 0px;">'
  1341. html += '<form id="getUpMassage_form">'
  1342. html += ' <div class="javaex-unit clear">'
  1343. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  1344. html += ' <div class="javaex-unit-left mr-10">'
  1345. html +=
  1346. ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  1347. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  1348. html += ' </div>'
  1349. html += ' <div class="javaex-unit-right mr-10">'
  1350. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  1351. html += ' </div>'
  1352. html += ' </div>'
  1353. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  1354. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  1355. html += ' <thead>'
  1356. html += ' <tr><th>内容</th><th>详情</th></tr>'
  1357. html += ' </thead>'
  1358. html += ' <tbody id="upMsgTbody">'
  1359.  
  1360. html += ' </tbody>'
  1361. html += '</table> '
  1362. html += '</div>'
  1363. html += '</form>';
  1364. html += '<hr class="javaex-divider"></hr>';
  1365. html += '</div>';
  1366.  
  1367.  
  1368. javaex.panel(this, {
  1369. position: "right",
  1370. content: html
  1371. });
  1372.  
  1373. javaex.table({
  1374. id: "upMsgTable",
  1375. isDragColWidth: true, // 是否允许拖动改变列宽
  1376. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  1377. leftFixedColNum: 2, // 左侧固定列数
  1378. rightFixedColNum: 1, // 右侧固定列数
  1379. sort: {
  1380. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  1381. "2": "update_time"
  1382. },
  1383. sortCallback: function(rtn) {
  1384. //console.log(rtn.sortArr);
  1385. }
  1386. });
  1387.  
  1388. //
  1389. $("#getUpMsg").click(async function() {
  1390.  
  1391. let thismid = javaex.getSelectVal("#up_uid");
  1392. await HNAPI.userInfo(thismid)
  1393.  
  1394. let temp = await HNAPI.getUpCard(thismid);
  1395.  
  1396.  
  1397. await HNTOOL.Sleep(500);
  1398.  
  1399.  
  1400. if (temp != false) {
  1401. let data = BiliData.upCard.data;
  1402.  
  1403. let html = ``;
  1404. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  1405. html +=
  1406. `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  1407. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  1408. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  1409. html +=
  1410. `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  1411. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  1412. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  1413. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  1414. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  1415. html +=
  1416. `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  1417. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  1418. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  1419.  
  1420.  
  1421. $("#upMsgTbody").empty();
  1422. $("#upMsgTbody").append(html);
  1423. }
  1424.  
  1425.  
  1426. });
  1427. //点击放大
  1428. /* $("img").click(function() {
  1429. javaex.dialog({
  1430. type : "image", // 弹出层类型
  1431. url : $(this).attr("src") // 图片地址
  1432. });
  1433. });*/
  1434.  
  1435. });
  1436.  
  1437.  
  1438. $("#everyDayTask").bind("click", async function() {
  1439.  
  1440. let videoAid = 758643487;
  1441. let videoCid = 357521682;
  1442. let videoBvid = "BV1V64y1d7ed";
  1443. let videoMid = 99439379;
  1444.  
  1445. //查询每日奖励状态
  1446. let rewardData = await HNAPI.get_exp_reward();
  1447. await HNTOOL.Sleep(2000);
  1448.  
  1449. //1.每日登录
  1450. if (rewardData.login == false) {
  1451.  
  1452. await HNAPI.clickNow();
  1453. await HNTOOL.Sleep(3000);
  1454. }
  1455.  
  1456. //2.直播签到
  1457. await HNAPI.DoSign();
  1458. await HNTOOL.Sleep(3000);
  1459.  
  1460. //3.专栏投币
  1461. let accountData = await HNAPI.get_account_exp();
  1462. await HNTOOL.Sleep(2000);
  1463. if (rewardData.coins < 40) {
  1464. //2. 获取分区最新专栏列表
  1465. let articleData = await HNAPI.getArticleRecommends();
  1466. await HNTOOL.Sleep(2000);
  1467. let article = articleData[HNTOOL.random(0, 9)];
  1468. let article2 = articleData[HNTOOL.random(9, 18)];
  1469.  
  1470. //await HNAPI.addVideoCoin(videoAid);//视频投币
  1471. await HNAPI.addArticleCoin(article.id, article.author.mid); //专栏投币
  1472. await HNTOOL.Sleep(2000);
  1473. if (accountData / 20 == 1) {
  1474. await HNAPI.addArticleCoin(article2.id, article2.author.mid); //专栏投币
  1475. }
  1476. }
  1477.  
  1478. //获取分区最新视频列表 http://api.bilibili.com/x/web-interface/dynamic/region pn=1 ps=20 rid=21
  1479. let archivesList = await HNAPI.getDynamicRegion();
  1480. await HNTOOL.Sleep(2000);
  1481. let num = HNTOOL.random(0, archivesList.length - 1);
  1482.  
  1483. if (archivesList != false && num != 2) {
  1484. videoAid = archivesList[num].aid;
  1485. videoBvid = archivesList[num].bvid;
  1486. videoCid = archivesList[num].cid;
  1487. videoMid = archivesList[num].owner.mid;
  1488. }
  1489. //4.每日观看视频
  1490. if (rewardData.watch == false) {
  1491. await HNAPI.watchOneVideo(videoBvid, videoMid);
  1492. await HNTOOL.Sleep(2000);
  1493. }
  1494. //5.每日分享视频
  1495. if (rewardData.share == false) {
  1496.  
  1497. await HNAPI.addShare(videoAid);
  1498. await HNTOOL.Sleep(2000);
  1499. }
  1500.  
  1501. //6.日常随机转发一个视频
  1502.  
  1503. await HNAPI.shareOneVideo(videoAid, videoMid, "分享视频");
  1504. if (num == 3 || num == 16) {
  1505. let randomStr = await HNTOOL.getRandomString();
  1506. await HNAPI.shareOneVideo("975082514", "397516636", randomStr);
  1507. }
  1508.  
  1509.  
  1510.  
  1511.  
  1512.  
  1513. });
  1514.  
  1515.  
  1516. $("#batch_dynamic_like").bind("click", async function() {
  1517.  
  1518. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1519. let jsons = await HNAPI.getMyJson(url);
  1520. let myjson = jsons.batch_dynamic_like;
  1521.  
  1522. for (let value of myjson) {
  1523.  
  1524. await HNAPI.likeDynamic(value.dynamic_id);
  1525. console.log("点赞成功:https://t.bilibili.com/" + value.dynamic_id + "?tab=2")
  1526. await HNTOOL.Sleep(2000);
  1527. }
  1528.  
  1529. });
  1530.  
  1531.  
  1532. $("#dynamicActivity").bind("click", async function() {
  1533.  
  1534. javaex.tip({
  1535. content: "动态转发开始!",
  1536. type: "success"
  1537. });
  1538.  
  1539. let dynamic_id_list = await HNTOOL.getLatestDynamic();
  1540. console.log("共" + dynamic_id_list.length + "条动态")
  1541. let allFollow = await HNAPI.getAllFollow();
  1542. //let save_dynamic_id = await HNAPI.getSpaceNotice();
  1543. await HNTOOL.Sleep(2000);
  1544. console.log("随机延迟30-40分钟发布一个随机动态");
  1545. await HNTOOL.doOneDynamic(HNTOOL.random(30, 40) * 60 * 1000);
  1546.  
  1547. for (let index = 0, len = dynamic_id_list.length; index < len; index++) {
  1548.  
  1549. let value = dynamic_id_list[index];
  1550.  
  1551. let dynamic_data = await HNAPI.getdynamicData(value);
  1552.  
  1553. if (dynamic_data.hasOwnProperty('card') == false) {
  1554. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 失效!!!");
  1555. continue;
  1556. }
  1557. let dynamic_id = dynamic_data.card.desc.dynamic_id_str;
  1558. let dynamic_type = 17;
  1559. await HNTOOL.Sleep(2000);
  1560.  
  1561. if (dynamic_data.card.desc.is_liked == 1) {
  1562. console.log("【" + index + "】https://t.bilibili.com/" + value + "?tab=2 已转发,舍弃!!!");
  1563.  
  1564. //if (dynamic_data.card.desc.type == 2 || dynamic_data.card.desc.type == 4) {
  1565. if (dynamic_data.card["extension"] != undefined) {
  1566. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1567. await HNTOOL.Sleep(2000);
  1568.  
  1569. if (lNoticeData["lottery_result"] != undefined) {
  1570.  
  1571. console.log(
  1572. "【" + index + "已过开奖时间】\n" +
  1573. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1574. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1575. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1576. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1577. );
  1578. }
  1579.  
  1580. }
  1581. continue;
  1582. }
  1583. //判断是否过期
  1584. if (dynamic_data.card["extension"] != undefined) {
  1585. dynamic_type = 11;
  1586. dynamic_id = dynamic_data.card.desc.rid;
  1587. let lNoticeData = await HNAPI.getLotteryNotice(value);
  1588. await HNTOOL.Sleep(2000);
  1589.  
  1590. if (lNoticeData["lottery_result"] != undefined) {
  1591.  
  1592.  
  1593. console.log(
  1594. "【" + index + "已过开奖时间】\n" +
  1595. "用户:" + dynamic_data.card.desc.user_profile.info.uname + "\n" +
  1596. "奖品:" + lNoticeData.first_prize_cmt + "\n" +
  1597. "地址:https://t.bilibili.com/" + value + "?tab=2" + "\n" +
  1598. "名单:" + JSON.stringify(lNoticeData.lottery_result)
  1599. );
  1600. continue;
  1601. }
  1602.  
  1603. }
  1604.  
  1605. if (allFollow.indexOf(dynamic_data.card.desc.uid) == -1) {
  1606.  
  1607. let res = await HNAPI.batchModify(dynamic_data.card.desc.uid);
  1608. if (dynamic_data.card.desc.type == 2 && res == false) {
  1609. console.log("【" + index + "】关注官方动态up失败,检查账号是否异常,风控等!!!https://t.bilibili.com/" + value +
  1610. "?tab=2");
  1611. continue;
  1612. }
  1613. console.log("【" + index + "】关注" + dynamic_data.card.desc.uid + "成功!!!");
  1614. }
  1615.  
  1616. await HNTOOL.Sleep(1000);
  1617.  
  1618. //1.评论
  1619. await HNAPI.addReply(dynamic_id, dynamic_type);
  1620. console.log("【" + index + "】" + dynamic_id + "评论成功!!!");
  1621. await HNTOOL.Sleep(1000);
  1622. //3.点赞
  1623. await HNAPI.likeDynamic(value);
  1624. await HNTOOL.Sleep(1000);
  1625. //2.转发
  1626. let repostCard = HNTOOL.strToJson(dynamic_data.card.card);
  1627. let repostStr = HNTOOL.getRandomWordOfList(replyList);
  1628. let repostCtrl = "转发动态";
  1629. let relay_chat = null;
  1630. if (repostCard["user"]["uname"] != undefined && dynamic_data.card["extension"] == undefined) {
  1631.  
  1632. //转发内容 = 评论+'//'+'@'+用户名+':'+源内容
  1633. relay_chat = repostStr + "//@" + repostCard.user.uname + ":" + repostCard.item.content;
  1634. repostCtrl = repostCard.item.ctrl;
  1635.  
  1636. }
  1637. await HNAPI.repostDynamic(value, repostStr, repostCtrl);
  1638. await HNTOOL.Sleep(1000);
  1639. console.log("【" + index + "】动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!");
  1640.  
  1641. javaex.tip({
  1642. content: "动态:https://t.bilibili.com/" + value + "?tab=2 转发完成!",
  1643. type: "success"
  1644. });
  1645.  
  1646. //存储标记
  1647. //await HNAPI.setNotice(value);
  1648.  
  1649. //随机延迟120 -240秒
  1650. let sleeptime = HNTOOL.random(12, 24) * 10 * 1000;
  1651. console.log("转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!")
  1652. javaex.tip({
  1653. content: "转发完成等待" + sleeptime / 1000 + "S后转发下一条动态!",
  1654. type: "success"
  1655. });
  1656. await HNTOOL.Sleep(sleeptime);
  1657. }
  1658.  
  1659. alert("今日动态抽奖完成!!!");
  1660.  
  1661. });
  1662.  
  1663. $("#batchFollowOfbastard").bind("click", async function() {
  1664.  
  1665. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证和个人认证的的关注! \n 不确定使用请取消!")) {
  1666.  
  1667. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1668.  
  1669. if (fansNum != null && fansNum != "") {
  1670. //fansNum
  1671.  
  1672. let followList = await HNAPI.getAllFollow();
  1673. console.log(followList);
  1674. await HNTOOL.Sleep(2000);
  1675.  
  1676. for (let fl of followList) {
  1677.  
  1678. if (fl == 99439379) {
  1679. await HNAPI.cancelAtt(fl, 1);
  1680. continue;
  1681. }
  1682. if (!followList.indexOf(99439379)) {
  1683.  
  1684. await HNAPI.cancelAtt(99439379, 1);
  1685. }
  1686.  
  1687. let user = await HNAPI.getCardByUID(fl);
  1688. await HNTOOL.Sleep(1000);
  1689. //0签约主播 1机构认证
  1690.  
  1691. if (user.fans < parseInt(fansNum) && /0|2|7/.test(user.Official.role)) {
  1692. await HNAPI.cancelAtt(fl, 2);
  1693.  
  1694. javaex.tip({
  1695. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1696. "---符合条件 取关成功!!!",
  1697. type: "success"
  1698. });
  1699. console.log("---uid:" + user.mid + "\n---" + user.name + "\n---粉丝量-" + user.fans +
  1700. "\n---符合条件 取关成功!!!");
  1701.  
  1702. } else {
  1703. javaex.tip({
  1704. content: "uid:" + user.mid + "-" + user.name + "--粉丝量-" + user.fans +
  1705. "---不符合条件 取消!!!",
  1706. type: "success"
  1707. });
  1708. console.log("uid:" + user.mid + "-" + user.name + "---粉丝量-" + user.fans +
  1709. "---不符合条件 取消!!!");
  1710. }
  1711. }
  1712. }
  1713.  
  1714. }
  1715.  
  1716. });
  1717.  
  1718.  
  1719. $("#reserveActivity").bind("click", async function() {
  1720.  
  1721.  
  1722. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSids.json";
  1723. let myjson = await HNAPI.getMyJson(url);
  1724.  
  1725. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1726. if (typeof(lastSid) == "undefined") {
  1727. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1728. }
  1729. lastSid = lastSid.split("&")[1];
  1730.  
  1731.  
  1732.  
  1733. for (const sid in myjson) {
  1734.  
  1735. if (parseInt(lastSid) >= parseInt(sid)) {
  1736.  
  1737. continue;
  1738. }
  1739.  
  1740. let siddata = myjson[sid];
  1741. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1742. //await HNTOOL.Sleep(2000);
  1743.  
  1744. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1745. await HNAPI.reserveActivity(sid);
  1746. await HNTOOL.Sleep(2000);
  1747.  
  1748. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime,
  1749. 'yyyy-MM-dd HH:mm:ss') +
  1750. //"\n --预约SID:" + siddata.sid +
  1751. //"\n --预约UID:" + siddata.upmid +
  1752. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1753. "\n --预约人数:" + siddata.total + "人" +
  1754. "\n --预约奖品:" + siddata.prizeInfo.text;
  1755.  
  1756. console.log(tiplog);
  1757.  
  1758. javaex.tip({
  1759. content: tiplog,
  1760. type: "success"
  1761. });
  1762.  
  1763. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1764.  
  1765. HNTOOL.saveConfig();
  1766.  
  1767. }
  1768.  
  1769.  
  1770. alert("预约抽奖结束");
  1771. });
  1772.  
  1773. $("#liveActivity").bind("click", async function() {
  1774.  
  1775. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1776. let myjson = await HNAPI.getMyJson(url);
  1777.  
  1778. });
  1779.  
  1780.  
  1781. $("#linshiActivity3").bind("click", async function() {
  1782.  
  1783. let open_capsule_by_id = {
  1784. 'activity_id': '5709481937914112'
  1785. };
  1786.  
  1787. let share = await HNAPI.basePost(
  1788. "https://qcloud-sdkact-api.biligame.com/yuanshen/lottery/share?t=" + Math.round(
  1789. new Date()) + "&activity_id=5709481937914112",
  1790. open_capsule_by_id);
  1791. await HNTOOL.Sleep(1000);
  1792. if (share.success) {
  1793.  
  1794.  
  1795. let open_capsule_by_id2 = {
  1796. 'activity_id': '5709481937914112',
  1797. 'platform': 'web',
  1798. 'user_agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/96.0.4664.45 Safari/537.36'
  1799. };
  1800.  
  1801. let draw = await HNAPI.basePost(
  1802. "https://qcloud-sdkact-api.biligame.com/yuanshen/lottery/draw?t=" + Math.round(
  1803. new Date()) +
  1804. "&activity_id=5709481937914112&platform=web&user_agent=Mozilla%2F5.0+(Windows+NT+10.0%3B+Win64%3B+x64)+AppleWebKit%2F537.36+(KHTML,+like+Gecko)+Chrome%2F96.0.4664.45+Safari%2F537.36",
  1805. open_capsule_by_id2);
  1806.  
  1807. await HNTOOL.Sleep(2000);
  1808. alert(draw.data.name);
  1809. } else {
  1810. alert("无次数!!!");
  1811. }
  1812.  
  1813.  
  1814.  
  1815. });
  1816.  
  1817. $("#linshiActivity2").bind("click", async function() {
  1818.  
  1819. let open_capsule_by_id = {
  1820. 'areaids': 1,
  1821. 'csrf_token': Live_info.csrf_token,
  1822. 'csrf': Live_info.csrf_token,
  1823. 'visit_id': ''
  1824. };
  1825.  
  1826. await HNAPI.basePost(
  1827. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubArea",
  1828. open_capsule_by_id);
  1829.  
  1830. await HNAPI.basePost(
  1831. "https://api.live.bilibili.com/xlive/activity-interface/v2/spec-act/bls21-area/BlsLifeSubList", {}
  1832. );
  1833. await HNTOOL.Sleep(5000);
  1834.  
  1835. let open_capsule_by_id2 = {
  1836. 'id': 313,
  1837. 'count': 1,
  1838. 'platform': 'web',
  1839. 'csrf_token': Live_info.csrf_token,
  1840. 'csrf': Live_info.csrf_token,
  1841. 'visit_id': '',
  1842. '_': Math.round(new Date()),
  1843. };
  1844.  
  1845. let open_capsule = await HNAPI.basePost(
  1846. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1847. open_capsule_by_id2);
  1848.  
  1849. if (open_capsule.err) {
  1850. alert(open_capsule.err);
  1851. }
  1852.  
  1853. let awards = (open_capsule.data.awards)[0];
  1854. alert(awards.gift_value + awards.text);
  1855.  
  1856.  
  1857.  
  1858. });
  1859.  
  1860. $("#linshiActivity").bind("click", async function() {
  1861.  
  1862. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/bilicat_config.json";
  1863. let myjson = await HNAPI.getMyJson(url);
  1864.  
  1865. let uids = myjson.config_linshi;
  1866.  
  1867. for (let uid of uids) {
  1868. await HNAPI.cancelAtt(uid, 2);
  1869. await HNTOOL.Sleep(1000);
  1870. }
  1871.  
  1872. await HNAPI.batchModify(uids.toString(), 1);
  1873. await HNTOOL.Sleep(5000);
  1874.  
  1875. await HNAPI.baseGet(
  1876. " https://api.live.bilibili.com/xlive/activity-interface/v2/userTask/GetNewUserTaskInfo", {
  1877. "task_id": 351
  1878. });
  1879.  
  1880. await HNTOOL.Sleep(1000);
  1881. let open_capsule_by_id = {
  1882. 'id': 308,
  1883. 'count': 1,
  1884. 'platform': 'web',
  1885. 'csrf_token': Live_info.csrf_token,
  1886. 'csrf': Live_info.csrf_token,
  1887. 'visit_id': '',
  1888. '_': Math.round(new Date()),
  1889. };
  1890.  
  1891. let open_capsule = await HNAPI.basePost(
  1892. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  1893. open_capsule_by_id);
  1894. await HNTOOL.Sleep(1000);
  1895.  
  1896. if (open_capsule.err) {
  1897. alert(open_capsule.err);
  1898. }
  1899.  
  1900. GM_setClipboard(((open_capsule.data.awards)[0]).gift_value);
  1901.  
  1902. alert("已复制到剪切板:" + ((open_capsule.data.awards)[0]).gift_value);
  1903. });
  1904.  
  1905.  
  1906. $("#jury_case").bind("click", async function() {
  1907.  
  1908. let bln = window.confirm('是否立即执行?【确定:只会执行一次】;【取消:0:10(5H)】;');
  1909.  
  1910. if (bln) {
  1911. HNTOOL.console("风纪开始!")
  1912. HNTOOL.jury_case();
  1913. } else {
  1914. for (var i = 0; i < 1; i--) {
  1915.  
  1916. let now = new Date();
  1917. let hour = now.getHours();
  1918. let minu = now.getMinutes();
  1919. HNTOOL.console("风纪运行中……");
  1920.  
  1921. if ((hour == 0 || HNTOOL.isInteger(hour / 6)) && minu == 10) {
  1922. HNTOOL.console("风纪开始到达预定时间开始执行!")
  1923. HNTOOL.jury_case();
  1924. }
  1925.  
  1926. await HNTOOL.Sleep(50000);
  1927. }
  1928. }
  1929.  
  1930. });
  1931.  
  1932. $("#plateActivity").bind("click", async function() {
  1933.  
  1934. //获取轮盘数据
  1935.  
  1936. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1937. let myjson = await HNAPI.getMyJson(url);
  1938. let lmt = 0;
  1939. let k = 20; //重试次数 防止卡主
  1940. let giftArr = [];
  1941. let endAtion = [];
  1942.  
  1943. javaex.tip({
  1944. content: "开始参加轮盘!!!",
  1945. type: "success"
  1946. });
  1947.  
  1948. await HNAPI.getUserNav();
  1949. await HNTOOL.Sleep(1500);
  1950.  
  1951.  
  1952. for (const json of myjson.acriviries_type1) {
  1953. //let x = json.name;
  1954. for (let i = 0; i < 10; i++) {
  1955. //1.结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1956. let resout = await HNAPI.addLotteryTimes(json.sid);
  1957.  
  1958. await HNTOOL.Sleep(200);
  1959. if (resout == 1) {
  1960.  
  1961. endAtion.push(json.name + ":活动已结束!");
  1962. javaex.tip({
  1963. content: json.name + "活动已结束!",
  1964. type: "success"
  1965. });
  1966.  
  1967. break;
  1968. }
  1969. if (resout != 0 && resout != 1) {
  1970.  
  1971. javaex.tip({
  1972. content: json.name + resout,
  1973. type: "error"
  1974. });
  1975.  
  1976. break;
  1977. }
  1978.  
  1979. if (resout == 0) {
  1980. //2.查询次数
  1981. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1982. continue;
  1983. }
  1984.  
  1985. }
  1986.  
  1987. javaex.tip({
  1988. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1989. type: "success"
  1990. });
  1991.  
  1992. await HNTOOL.Sleep(1000);
  1993.  
  1994. for (let i = 0; i < lmt; i++) {
  1995. //3、执行抽奖
  1996. let gift = await HNAPI.lotteryDo(json.sid, json.name);
  1997.  
  1998. if (gift == true) {
  1999. javaex.tip({
  2000. content: "点击过快,9秒后自动重试!!!",
  2001. type: "error"
  2002. });
  2003. i--;
  2004. k--;
  2005. }
  2006.  
  2007. if (gift == false || k == 0) {
  2008. break;
  2009. }
  2010.  
  2011. if (gift != "未中奖0" && gift != true) {
  2012. giftArr.push(json.name + "奖品为:" + gift + "\n");
  2013.  
  2014. break;
  2015. } else {
  2016. javaex.tip({
  2017. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  2018. type: "success"
  2019. });
  2020. }
  2021. await HNTOOL.Sleep(6000);
  2022.  
  2023. }
  2024.  
  2025.  
  2026. }
  2027.  
  2028. for (const json2 of myjson.acriviries_type2) {
  2029.  
  2030. let submitData1 = {
  2031. "act_id": json2.act_id,
  2032. "share_type": 1,
  2033. "visit_id": "",
  2034. "csrf_token": Live_info.csrf_token,
  2035. "csrf": Live_info.csrf_token,
  2036. }
  2037.  
  2038. let submitReul1 = await HNAPI.basePost(
  2039. "https://api.live.bilibili.com/xlive/activity-interface/v1/task/UserShare", submitData1);
  2040. await HNTOOL.Sleep(1000);
  2041.  
  2042. let submitData2 = {
  2043. "act_id": json2.act_id
  2044. }
  2045. let submitReul2 = await HNAPI.baseGet(
  2046. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  2047. submitData2);
  2048. await HNTOOL.Sleep(1000);
  2049.  
  2050. let task = submitReul2.data.task_list[0];
  2051. if (task) {
  2052. let submitData3 = {
  2053. "act_id": json2.act_id,
  2054. "task_id": task.task_id,
  2055. "cycle_id": task.task_cycle_id,
  2056. "level_id": 1,
  2057. "visit_id": "",
  2058. "csrf_token": Live_info.csrf_token,
  2059. "csrf": Live_info.csrf_token,
  2060. }
  2061.  
  2062. await HNAPI.basePost(
  2063. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/getaward",
  2064. submitData3);
  2065. await HNTOOL.Sleep(3000);
  2066.  
  2067. await HNAPI.baseGet(
  2068. "https://api.live.bilibili.com/xlive/activity-interface/v1/activitytask/user_acttask/info",
  2069. submitData2);
  2070. await HNTOOL.Sleep(1000);
  2071.  
  2072. let submitData4 = {
  2073. "id": json2.id,
  2074. "count": 1,
  2075. "platform": "web",
  2076. "_": Math.round(new Date()),
  2077. "visit_id": "",
  2078. "csrf_token": Live_info.csrf_token,
  2079. "csrf": Live_info.csrf_token,
  2080. }
  2081.  
  2082. let submitReul4 = await HNAPI.basePost(
  2083. "https://api.live.bilibili.com/xlive/web-ucenter/v1/capsule/open_capsule_by_id",
  2084. submitData4);
  2085. await HNTOOL.Sleep(1000);
  2086. if (submitReul4 == false) {
  2087. HNTOOL.console(json2.act_id + ":失败!");
  2088. continue;
  2089. }
  2090. if(submitReul4.err != undefined){
  2091. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.err);
  2092. continue;
  2093. }
  2094. HNTOOL.console("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0]);
  2095.  
  2096. giftArr.push("直播转盘:" + json2.act_id + ":" + submitReul4.data.text[0] + "\n");
  2097. }
  2098.  
  2099.  
  2100. }
  2101.  
  2102.  
  2103. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:\n` + (
  2104. giftArr.length == 0 ? "未中奖" : giftArr.toString()));
  2105.  
  2106. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `\n 中奖详情:` + (giftArr.length == 0 ? "未中奖" : giftArr
  2107. .toString()));
  2108.  
  2109.  
  2110. });
  2111.  
  2112. $("#addPlay").bind("click", async function() {
  2113.  
  2114.  
  2115. let html = '';
  2116.  
  2117. html += '<div style="padding: 10px 10px 10px 0px;">'
  2118. html += '<form id="getUpMassage_form">'
  2119.  
  2120. html += ' <div class="javaex-unit clear">'
  2121. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  2122. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  2123. html +=
  2124. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  2125. html +=
  2126. ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  2127. html += ' </div>'
  2128. html += ' </div>'
  2129. html += ' <div class="javaex-unit clear">'
  2130. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  2131. html +=
  2132. ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  2133. html +=
  2134. ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  2135. html +=
  2136. ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  2137. html += ' </div>'
  2138. html += ' </div>'
  2139. html += '</form>';
  2140. html += ' <div class="javaex-unit clear tc">'
  2141. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  2142. html += ' </div>'
  2143. html += '<hr class="javaex-divider"></hr>';
  2144. html += '</div>';
  2145.  
  2146.  
  2147. javaex.panel(this, {
  2148. position: "right",
  2149. content: html
  2150. });
  2151.  
  2152. $("#addPlay_bgn").click(async function() {
  2153.  
  2154. let MID = javaex.getSelectVal("#addPlay_uid")
  2155. let BV = javaex.getSelectVal("#addPlay_bv");
  2156. let bvArr = [];
  2157. let bvArr2 = [];
  2158.  
  2159. MID = javaex.ifnull(MID, BiliData.author_uid);
  2160.  
  2161.  
  2162. if (BV == "0") {
  2163.  
  2164. //1.查询up所有视频BV号 2.发送心跳间隔2s
  2165. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  2166. await HNTOOL.Sleep(500);
  2167. bvArr2 = BiliData.BVList;
  2168.  
  2169. for (let i = 1; i > 0; i++) {
  2170.  
  2171. HNAPI.getUpAllBV(MID, i);
  2172.  
  2173. await HNTOOL.Sleep(500);
  2174.  
  2175. if (BiliData.BVList.length == 0) {
  2176. if (bvArr.length == 0) {
  2177. javaex.tip({
  2178. content: "该用户无投稿视频,请确认是否有误!",
  2179. type: "success"
  2180. });
  2181. await HNTOOL.Sleep(2000);
  2182. }
  2183. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  2184. bvArr = bvArr.concat(bvArr2);
  2185. break;
  2186. }
  2187.  
  2188. bvArr = bvArr.concat(BiliData.BVList);
  2189. }
  2190.  
  2191.  
  2192. if (bvArr.length != 0) {
  2193.  
  2194. for (const emt of bvArr) {
  2195.  
  2196. HNAPI.playOneVideo(emt.bvid, MID);
  2197.  
  2198. await HNTOOL.Sleep(2000);
  2199.  
  2200. }
  2201.  
  2202. alert("播放完成!!!");
  2203.  
  2204. }
  2205.  
  2206.  
  2207. } else {
  2208. //1.调用点击播放接口
  2209. //2.发送心跳
  2210.  
  2211. await HNTOOL.Sleep(500);
  2212.  
  2213. HNAPI.playOneVideo(BV);
  2214. }
  2215.  
  2216.  
  2217. });
  2218.  
  2219.  
  2220. });
  2221.  
  2222. }
  2223.  
  2224.  
  2225.  
  2226.  
  2227. let addSetPage = async function() {
  2228.  
  2229. HNTOOL.Sleep(1000);
  2230.  
  2231. $('body').append('' +
  2232. '<div id="left_navbar">' +
  2233. '<div class="javaex-menu-container"> ' +
  2234. ' <div id="menu" class="javaex-menu"> ' +
  2235. ' <ul> ' +
  2236. ' <li class="javaex-menu-item alone hover" > ' +
  2237. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  2238. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  2239. ' </li> ' +
  2240. ' </ul> ' +
  2241. ' <ul> ' +
  2242. ' <li class="javaex-menu-item"> ' +
  2243. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  2244. ' <ul> ' +
  2245. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  2246. ' </ul> ' +
  2247. ' </li> ' +
  2248. ' <li id="chackList" class="javaex-menu-item"> ' +
  2249. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  2250. ' <ul> ' +
  2251. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  2252. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  2253. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  2254. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  2255. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  2256. ' </ul> ' +
  2257. ' </li> ' +
  2258. ' <li class="javaex-menu-item"> ' +
  2259. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  2260. ' <ul> ' +
  2261. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  2262. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  2263. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  2264. ' <li id="yunBatchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >取关云数据</a></li> ' +
  2265. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  2266. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  2267. ' <li id="batch_dynamic_like" class="javaex-hover-pulse"><a href="javaScript:;" >批量动态点赞</a></li> ' +
  2268. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  2269. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  2270. ' </ul> ' +
  2271. ' </li> ' +
  2272. ' <li class="javaex-menu-item"> ' +
  2273. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  2274. ' <ul> ' +
  2275. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  2276. ' <li id="jury_case" class="javaex-hover-pulse"><a href="javaScript:;" >一键风纪任务【0:10(5H)】</a></li> ' +
  2277. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  2278. ' <li id="linshiActivity" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘-和平</a></li> ' +
  2279. ' <li id="linshiActivity2" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘-整活</a></li> ' +
  2280. ' <li id="linshiActivity3" class="javaex-hover-pulse"><a href="javaScript:;" >临时转盘-原神</a></li> ' +
  2281. //' <li id="liveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >直播转盘</a></li> ' +
  2282. //' <li id="likeInDynamicComments" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  2283. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  2284. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  2285. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  2286. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  2287. ' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  2288. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  2289. //' <li id="auto_check_question" class="javaex-hover-pulse"><a href="javaScript:;">一键答题</a></li> ' +
  2290. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  2291. ' </ul> ' +
  2292. ' </li> ' +
  2293. ' <li class="javaex-menu-item"> ' +
  2294. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  2295. ' <ul> ' +
  2296. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  2297. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  2298. ' </ul> ' +
  2299. ' </li> ' +
  2300.  
  2301. ' </ul> ' +
  2302. ' </div> ' +
  2303. '</div>' +
  2304. '</div>');
  2305. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  2306.  
  2307. javaex.menu({
  2308. id: "menu",
  2309. isShowAll: false
  2310. });
  2311.  
  2312. }
  2313.  
  2314.  
  2315.  
  2316.  
  2317. let showUnreadMsg = function() {
  2318.  
  2319. var html = '';
  2320. html += '<div class="javaex-panel-box" style="width: 250px;">';
  2321. html += ' <ul>';
  2322. html += ` <p style="color: #FFF;">用户消息</p>`;
  2323. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  2324. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  2325. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  2326. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  2327. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  2328. html += ' <hr class="javaex-divider"></hr>';
  2329. html += ' </ul>';
  2330. html += '</div>';
  2331.  
  2332.  
  2333. javaex.panel(document.getElementById("getUnread"), {
  2334. position: "right",
  2335. content: html
  2336. });
  2337.  
  2338. javaex.tip({
  2339. content: "查询用户通知成功!",
  2340. type: "success"
  2341. });
  2342.  
  2343. }
  2344.  
  2345. /**
  2346. * 检查 艾特信息
  2347. * @returns {Promise<void>}
  2348. */
  2349. let chackAtMsg = async function(items) {
  2350.  
  2351. await HNTOOL.Sleep(500);
  2352.  
  2353. if (items != false && typeof(items) != "undefined") {
  2354.  
  2355.  
  2356. var html = '';
  2357. html += '<div class="javaex-panel-box" style="width: auto;">';
  2358. html += ' <ul>';
  2359. html += ` <p style="color: #FFF;">@信息</p>`;
  2360. items.forEach(function(item) {
  2361.  
  2362. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  2363. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  2364. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  2365.  
  2366. html +=
  2367. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  2368. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  2369. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  2370. html += ' <hr class="javaex-divider"></hr>';
  2371. });
  2372. html += ' </ul>';
  2373. html += '</div>';
  2374.  
  2375.  
  2376. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  2377. javaex.panel(document.getElementById("getAtMsg"), {
  2378. position: "right",
  2379. content: html
  2380. });
  2381. } else {
  2382. javaex.panel(document.getElementById("chackList"), {
  2383. position: "right",
  2384. content: html
  2385. });
  2386. }
  2387.  
  2388.  
  2389. }
  2390.  
  2391. }
  2392.  
  2393.  
  2394. let addStyle = function() {
  2395. const animate = GM_getResourceText('animate');
  2396. const common = GM_getResourceText('common');
  2397. const defaultCss = GM_getResourceText('defaultCss');
  2398. //const icomoonex = GM_getResourceText('icomoonex');
  2399. //const AllCss = animate + common + defaultCss + icomoonex;
  2400. const AllCss = animate + common + defaultCss;
  2401. const style = document.createElement('style');
  2402. style.innerHTML = AllCss;
  2403. return document.getElementsByTagName('head')[0].appendChild(style);
  2404. }
  2405.  
  2406. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  2407.  
  2408.  
  2409. /*-----------------------------------------------常用API--------------------------------------------------*/
  2410.  
  2411. let HNAPI = {
  2412.  
  2413. basePost: async function(api, data) {
  2414. return new Promise((resolve) => {
  2415. Ajax.post({
  2416. url: api,
  2417. hasCookies: true,
  2418. dataType: 'application/x-www-form-urlencoded',
  2419. data: data,
  2420. success: responseText => {
  2421. let res = HNTOOL.strToJson(responseText);
  2422. if (res.code === 0) {
  2423.  
  2424. resolve(res);
  2425. } else {
  2426. HNTOOL.console(res.message);
  2427.  
  2428. resolve({
  2429. err: res.message
  2430. });
  2431. }
  2432. }
  2433. })
  2434. });
  2435. },
  2436.  
  2437.  
  2438.  
  2439. baseGet: async function(api, queryObj) {
  2440. return new Promise((resolve) => {
  2441.  
  2442. Ajax.get({
  2443. url: api,
  2444. queryStringsObj: queryObj,
  2445. hasCookies: true,
  2446. success: responseText => {
  2447. let res = HNTOOL.strToJson(responseText);
  2448. if (res.code === 0) {
  2449.  
  2450. resolve(res);
  2451. } else {
  2452.  
  2453. resolve(false);
  2454. }
  2455. }
  2456. })
  2457. });
  2458. },
  2459.  
  2460. exchange_chance: async function(activity_id) {
  2461. return new Promise((resolve) => {
  2462.  
  2463. Ajax.get({
  2464. url: "https://qcloud-sdkact-api.biligame.com/exchange/chance",
  2465. queryStringsObj: {
  2466. 't': Math.round(new Date()),
  2467. 'activity_id': activity_id,
  2468.  
  2469. },
  2470. hasCookies: true,
  2471. success: responseText => {
  2472. let res = HNTOOL.strToJson(responseText);
  2473. if (res.code === 0) {
  2474.  
  2475. resolve(true);
  2476. } else {
  2477.  
  2478. resolve(false);
  2479. }
  2480. }
  2481. })
  2482. });
  2483. },
  2484. wwjdg_inform: async function(activity_id) {
  2485. return new Promise((resolve) => {
  2486.  
  2487. Ajax.get({
  2488. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform",
  2489. queryStringsObj: {
  2490. 't': Math.round(new Date()),
  2491. 'activity_id': activity_id,
  2492.  
  2493. },
  2494. hasCookies: true,
  2495. success: responseText => {
  2496. let res = HNTOOL.strToJson(responseText);
  2497. if (res.code === 0) {
  2498.  
  2499. resolve(true);
  2500. } else {
  2501.  
  2502. resolve(false);
  2503. }
  2504. }
  2505. })
  2506. });
  2507. },
  2508. wwjdg_inform_off: async function(activity_id, info_no) {
  2509. return new Promise((resolve) => {
  2510. Ajax.post({
  2511. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/inform/off?t=" + Math.round(
  2512. new Date()),
  2513. hasCookies: true,
  2514. dataType: 'application/x-www-form-urlencoded',
  2515. data: {
  2516.  
  2517. activity_id: activity_id,
  2518. info_no: info_no,
  2519.  
  2520. },
  2521. success: responseText => {
  2522. let res = HNTOOL.strToJson(responseText);
  2523. if (res.code === 0) {
  2524.  
  2525. resolve(true);
  2526. } else {
  2527.  
  2528. resolve(false);
  2529. }
  2530. }
  2531. })
  2532. });
  2533. },
  2534.  
  2535. exchange_prize: async function(activity_id) {
  2536. return new Promise((resolve) => {
  2537.  
  2538. Ajax.get({
  2539. url: "https://qcloud-sdkact-api.biligame.com/wwjdg/exchange_prize",
  2540. queryStringsObj: {
  2541. 't': Math.round(new Date()),
  2542. 'activity_id': activity_id,
  2543. 'prize_id': 5629853426288896,
  2544. },
  2545. hasCookies: true,
  2546. success: responseText => {
  2547. let res = HNTOOL.strToJson(responseText);
  2548. if (res.code === 0) {
  2549.  
  2550. resolve(true);
  2551. } else {
  2552.  
  2553. resolve(false);
  2554. }
  2555. }
  2556. })
  2557. });
  2558. },
  2559. lottery_draw_one: async function() {
  2560. return new Promise((resolve) => {
  2561. Ajax.post({
  2562. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" + Math
  2563. .round(new Date()),
  2564. hasCookies: true,
  2565. dataType: 'application/x-www-form-urlencoded',
  2566. data: {
  2567.  
  2568. activity_id: 5629854950017280
  2569.  
  2570. },
  2571. success: responseText => {
  2572. let res = HNTOOL.strToJson(responseText);
  2573. if (res.code === 0) {
  2574.  
  2575. alert(res.data.name)
  2576.  
  2577. } else if (res.code === 11001 || res.code == -905) {
  2578.  
  2579. Ajax.post({
  2580. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw?t=" +
  2581. Math
  2582. .round(new Date()),
  2583. hasCookies: true,
  2584. dataType: 'application/x-www-form-urlencoded',
  2585. data: {
  2586.  
  2587. activity_id: 5629850673711360
  2588.  
  2589. },
  2590. success: responseText => {
  2591. let res2 = HNTOOL.strToJson(responseText);
  2592. if (res2.code === 0) {
  2593.  
  2594. alert(res2.data.name)
  2595. } else if (res.code == -905) {
  2596. alert(res2.message);
  2597. } else {
  2598.  
  2599. resolve(false);
  2600. }
  2601. }
  2602. })
  2603.  
  2604. } else {
  2605.  
  2606. resolve(false);
  2607. }
  2608. }
  2609. })
  2610. });
  2611. },
  2612. /**
  2613. *
  2614. */
  2615.  
  2616. jury_vote: async function(case_id, vote, anonymous) {
  2617. return new Promise((resolve) => {
  2618. Ajax.post({
  2619. url: BILIBLI_PATH.api + "/x/credit/v2/jury/vote",
  2620. hasCookies: true,
  2621. dataType: 'application/x-www-form-urlencoded',
  2622. data: {
  2623.  
  2624. case_id: case_id,
  2625. vote: vote,
  2626. anonymous: anonymous,
  2627. content: "",
  2628. csrf: Live_info.csrf_token
  2629. },
  2630. success: responseText => {
  2631. let res = HNTOOL.strToJson(responseText);
  2632. if (res.code === 0) {
  2633.  
  2634. resolve(true);
  2635. } else {
  2636.  
  2637. resolve(res.message);
  2638. }
  2639. }
  2640. })
  2641. });
  2642. },
  2643.  
  2644. /**
  2645. *
  2646. */
  2647. jury_case_opinion: async function(case_id) {
  2648. return new Promise((resolve) => {
  2649.  
  2650. Ajax.get({
  2651. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/opinion",
  2652. queryStringsObj: {
  2653. 'case_id': case_id,
  2654. 'pn': 1,
  2655. 'ps': 5,
  2656.  
  2657. },
  2658. hasCookies: true,
  2659. success: responseText => {
  2660. let res = HNTOOL.strToJson(responseText);
  2661. if (res.code === 0) {
  2662. resolve(true);
  2663. } else {
  2664.  
  2665. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2666.  
  2667. resolve(false);
  2668. }
  2669. }
  2670. })
  2671. });
  2672. },
  2673. /**
  2674. *
  2675. */
  2676. jury_case_info: async function(case_id) {
  2677. return new Promise((resolve) => {
  2678.  
  2679. Ajax.get({
  2680. url: BILIBLI_PATH.api + "/x/credit/v2/jury/case/info",
  2681. queryStringsObj: {
  2682. 'case_id': case_id
  2683. },
  2684. hasCookies: true,
  2685. success: responseText => {
  2686. let res = HNTOOL.strToJson(responseText);
  2687. if (res.code === 0) {
  2688. let comment_content = "";
  2689. let itemlist = [1, 1, 1, 1, 2, 2, 2, 2, 3, 0];
  2690. let x = itemlist[HNTOOL.random(0, 10)];
  2691.  
  2692. let vote_item = res.data.vote_items[x];
  2693. let case_type = res.data.case_type;
  2694. if (case_type == 4) {
  2695. //4:截屏内弹幕
  2696. comment_content = "截屏内弹幕";
  2697.  
  2698. } else {
  2699. comment_content = res.data.case_info.comment.content;
  2700. }
  2701.  
  2702.  
  2703. HNTOOL.console(
  2704. "\n 案号:" + case_id +
  2705. "\n 详情:" + comment_content +
  2706. "\n 选择:" + vote_item.vote_text
  2707. );
  2708. resolve(vote_item.vote);
  2709. } else {
  2710.  
  2711. HNTOOL.console("获取案件详情发生错误!" + res.message, "error");
  2712.  
  2713. resolve(false);
  2714. }
  2715. }
  2716. })
  2717. });
  2718. },
  2719.  
  2720. /**
  2721. *
  2722. */
  2723. jury_case_next: async function() {
  2724. return new Promise((resolve) => {
  2725.  
  2726. Ajax.get({
  2727. url: BILIBLI_PATH.api + '/x/credit/v2/jury/case/next',
  2728. queryStringsObj: {
  2729.  
  2730. },
  2731. hasCookies: true,
  2732. success: responseText => {
  2733. let res = HNTOOL.strToJson(responseText);
  2734. if (res.code === 0) {
  2735.  
  2736. resolve(res.data.case_id);
  2737. } else if (res.code === 25014 || res.code === 25008) {
  2738.  
  2739. HNTOOL.console(res.message);
  2740.  
  2741.  
  2742. } else {
  2743. HNTOOL.console("今日风纪已完成&暂时无案子!");
  2744. resolve(false);
  2745. }
  2746. }
  2747. })
  2748. });
  2749. },
  2750.  
  2751. answer_check: async function(question_id, ans_hash, type) {
  2752. return new Promise((resolve) => {
  2753. Ajax.post({
  2754.  
  2755. url: "https://api.bilibili.com/x/answer/v4/" + type + "/check",
  2756. hasCookies: true,
  2757. dataType: 'application/x-www-form-urlencoded',
  2758. data: {
  2759. question_id: question_id,
  2760. ans_hash: ans_hash,
  2761. csrf: Live_info.csrf_token
  2762. },
  2763. success: responseText => {
  2764. let res = HNTOOL.strToJson(responseText);
  2765. if (res.code === 0) {
  2766. console.log("答题成功");
  2767. resolve(res.data);
  2768. } else if (res.code === 41020) {
  2769. resolve(1);
  2770. } else {
  2771. javaex.tip({
  2772. content: "错误!",
  2773. type: "error"
  2774. });
  2775. resolve(false);
  2776. }
  2777. }
  2778. })
  2779. });
  2780. },
  2781.  
  2782. /**
  2783. *
  2784. */
  2785. pull_answer: async function(type) {
  2786. return new Promise((resolve) => {
  2787.  
  2788. Ajax.get({
  2789. url: 'https://api.bilibili.com/x/answer/v4/' + type,
  2790. queryStringsObj: {
  2791.  
  2792. },
  2793. hasCookies: true,
  2794. success: responseText => {
  2795. let res = HNTOOL.strToJson(responseText);
  2796. if (res.code === 0) {
  2797.  
  2798. resolve(res.data);
  2799. } else if (res.code === 41020) {
  2800. console.log("用户" + type + "题已通过")
  2801. resolve(1);
  2802. } else {
  2803. console.log("拉取" + type + "题目失败:" + res.message);
  2804. resolve(false);
  2805. }
  2806. }
  2807. })
  2808. });
  2809. },
  2810.  
  2811. /**
  2812. *
  2813. */
  2814. answer_status: async function() {
  2815. return new Promise((resolve) => {
  2816. Ajax.get({
  2817. url: 'https://api.bilibili.com/x/answer/v4/status',
  2818. queryStringsObj: {
  2819.  
  2820. },
  2821. hasCookies: true,
  2822. success: responseText => {
  2823. let res = HNTOOL.strToJson(responseText);
  2824. if (res.code === 0) {
  2825.  
  2826. resolve(res.data);
  2827.  
  2828. } else {
  2829. console.log("查询答题状态失败:" + res.message);
  2830. resolve(false);
  2831. }
  2832. }
  2833. })
  2834. });
  2835. },
  2836.  
  2837. /**
  2838. * 查询每日投币数量
  2839. */
  2840. get_account_exp: async function() {
  2841. return new Promise((resolve) => {
  2842. Ajax.get({
  2843. url: 'http://www.bilibili.com/plus/account/exp.php',
  2844. queryStringsObj: {
  2845.  
  2846. },
  2847. hasCookies: true,
  2848. success: responseText => {
  2849. let res = HNTOOL.strToJson(responseText);
  2850. if (res.code === 0) {
  2851.  
  2852. resolve(res.number);
  2853.  
  2854. } else {
  2855. console.log("查询每日投币数量失败:" + res.message);
  2856. resolve(false);
  2857. }
  2858. }
  2859. })
  2860. });
  2861. },
  2862. /**
  2863. * 查询每日奖励状态
  2864. */
  2865. get_exp_reward: async function() {
  2866. return new Promise((resolve) => {
  2867. Ajax.get({
  2868. url: BILIBLI_PATH.api + '/x/member/web/exp/reward',
  2869. queryStringsObj: {
  2870.  
  2871. },
  2872. hasCookies: true,
  2873. success: responseText => {
  2874. let res = HNTOOL.strToJson(responseText);
  2875. if (res.code === 0) {
  2876.  
  2877. resolve(res.data);
  2878.  
  2879. } else {
  2880. console.log("查询每日奖励状态失败:" + res.message);
  2881. resolve(false);
  2882. }
  2883. }
  2884. })
  2885. });
  2886. },
  2887.  
  2888. diary_upload: async function(activity_id, game_part) {
  2889. return new Promise((resolve) => {
  2890. Ajax.post({
  2891. url: "https://qcloud-sdkact-api.biligame.com/rabbit/diary/upload",
  2892. hasCookies: true,
  2893. dataType: 'application/x-www-form-urlencoded',
  2894. data: {
  2895. t: Math.round(new Date()),
  2896. activity_id: activity_id,
  2897. game_part: game_part
  2898. },
  2899. payload: '{"activity_id":"' + activity_id + '","game_part":' + game_part + '}',
  2900.  
  2901. success: responseText => {
  2902. let res = HNTOOL.strToJson(responseText);
  2903. if (res.code === 0) {
  2904. console.log("成功:");
  2905. resolve(true);
  2906. } else {
  2907. javaex.tip({
  2908. content: "错误!",
  2909. type: "error"
  2910. });
  2911. resolve(false);
  2912. }
  2913. }
  2914. })
  2915. });
  2916. },
  2917. lottery_draw: async function(activity_id) {
  2918. return new Promise((resolve) => {
  2919. Ajax.post({
  2920. url: "https://qcloud-sdkact-api.biligame.com/activity/lottery/draw",
  2921. hasCookies: true,
  2922. dataType: 'application/x-www-form-urlencoded',
  2923. data: {
  2924. t: Math.round(new Date()),
  2925. activity_id: activity_id,
  2926. },
  2927. payload: '{"activity_id":"' + activity_id + '","t":' + Math.round(new Date()) +
  2928. '}',
  2929.  
  2930. success: responseText => {
  2931. let res = HNTOOL.strToJson(responseText);
  2932. if (res.code === 0) {
  2933. console.log("成功");
  2934. resolve(true);
  2935. } else {
  2936. javaex.tip({
  2937. content: "错误!",
  2938. type: "error"
  2939. });
  2940. resolve(false);
  2941. }
  2942. }
  2943. })
  2944. });
  2945. },
  2946. lottery_record: async function(activity_id) {
  2947. return new Promise((resolve) => {
  2948. Ajax.get({
  2949. url: 'https://qcloud-sdkact-api.biligame.com/common/lottery/record',
  2950. queryStringsObj: {
  2951. t: Math.round(new Date()),
  2952. activity_id: activity_id,
  2953. },
  2954. hasCookies: true,
  2955. success: responseText => {
  2956. let res = HNTOOL.strToJson(responseText);
  2957. if (res.code === 0) {
  2958. let str = "";
  2959. for (let s of res.data) {
  2960. str += s.name
  2961. }
  2962.  
  2963. resolve(str);
  2964.  
  2965. } else {
  2966. console.log("查询每日奖励状态失败:" + res.message);
  2967. resolve(false);
  2968. }
  2969. }
  2970. })
  2971. });
  2972. },
  2973. get_draw_chance: async function(activity_id) {
  2974. return new Promise((resolve) => {
  2975. Ajax.get({
  2976. url: 'https://qcloud-sdkact-api.biligame.com/activity/lottery/get_draw_chance',
  2977. queryStringsObj: {
  2978. t: Math.round(new Date()),
  2979. activity_id: activity_id,
  2980. },
  2981. hasCookies: true,
  2982. success: responseText => {
  2983. let res = HNTOOL.strToJson(responseText);
  2984. if (res.code === 0) {
  2985.  
  2986. resolve(true);
  2987.  
  2988. } else {
  2989. console.log("查询每日奖励状态失败:" + res.message);
  2990. resolve(false);
  2991. }
  2992. }
  2993. })
  2994. });
  2995. },
  2996. /**
  2997. * 转发一个视频
  2998. * @param {Object} videoAid
  2999. * @param {Object} videoMid
  3000. * @param {Object} randomStr
  3001. */
  3002.  
  3003. shareOneVideo: async function(videoAid, videoMid, randomStr) {
  3004. return new Promise((resolve) => {
  3005. Ajax.post({
  3006. url: BILIBLI_PATH.vcapi + "/dynamic_repost/v1/dynamic_repost/share",
  3007. hasCookies: true,
  3008. dataType: 'application/x-www-form-urlencoded',
  3009. data: {
  3010.  
  3011. platform: "pc",
  3012. uid: videoMid,
  3013. type: 8,
  3014. content: randomStr,
  3015. repost_code: 20000,
  3016. rid: videoAid,
  3017. csrf: Live_info.csrf_token
  3018. },
  3019. success: responseText => {
  3020. let res = HNTOOL.strToJson(responseText);
  3021. if (res.code === 0) {
  3022. console.log("转发一个视频成功:" + res.data.dynamic_id);
  3023. resolve(true);
  3024. } else {
  3025. javaex.tip({
  3026. content: "转发一个视频错误!" + res.message,
  3027. type: "error"
  3028. });
  3029. resolve(false);
  3030. }
  3031. }
  3032. })
  3033. });
  3034. },
  3035.  
  3036. /**
  3037. * 批量关注和拉黑 batchModify
  3038. *
  3039. * https://api.bilibili.com/x/relation/batch/modify
  3040. * @param uid
  3041. */
  3042.  
  3043. /**
  3044. * 发布动态
  3045. * @param {Object} mid
  3046. */
  3047. batchModify: async function(uids, act) {
  3048. return new Promise((resolve) => {
  3049. Ajax.post({
  3050. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  3051. hasCookies: true,
  3052. dataType: 'application/x-www-form-urlencoded',
  3053. data: {
  3054.  
  3055. "fids": uids,
  3056. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  3057. "re_src": 222,
  3058. "csrf": Live_info.csrf_token,
  3059. },
  3060. success: responseText => {
  3061. let res = HNTOOL.strToJson(responseText);
  3062. if (res.code === 0) {
  3063.  
  3064. if (res.data.failed_fids.length > 0) {
  3065. console.log("关注失败:" + res.data.failed_fids);
  3066. resolve(false);
  3067. } else {
  3068. console.log("关注成功:" + uids);
  3069. resolve(true);
  3070. }
  3071.  
  3072.  
  3073. } else {
  3074. javaex.tip({
  3075. content: "批量关注错误!" + res.message,
  3076. type: "error"
  3077. });
  3078. resolve(false);
  3079. }
  3080. }
  3081. })
  3082. });
  3083. },
  3084.  
  3085. /**
  3086. * 发布动态
  3087. * @param {Object} mid
  3088. */
  3089. sendOneDynamic: async function(content) {
  3090. return new Promise((resolve) => {
  3091. Ajax.post({
  3092. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/create',
  3093. hasCookies: true,
  3094. dataType: 'application/x-www-form-urlencoded',
  3095. data: {
  3096. csrf: Live_info.csrf_token,
  3097. dynamic_id: 0,
  3098. type: 4,
  3099. dynamic_id: 0,
  3100. content: content,
  3101. extension: '{"emoji_type":1,"from":{"emoji_type":1},"flag_cfg":{}}'
  3102. },
  3103. hasCookies: true,
  3104. success: responseText => {
  3105. let res = HNTOOL.strToJson(responseText);
  3106. if (res.code === 0) {
  3107.  
  3108. console.log("随机发送一条动态:" + content);
  3109. resolve(true);
  3110.  
  3111. } else {
  3112. console.log("随机发送一条动态:" + res.message);
  3113. resolve(false);
  3114. }
  3115. }
  3116. })
  3117. });
  3118. },
  3119. /**
  3120. * @param {num} mid
  3121. * 用户详细信息2 (用于名片)
  3122. */
  3123. getInterfaceCard: async function(mid) {
  3124. return new Promise((resolve) => {
  3125. Ajax.get({
  3126. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3127. queryStringsObj: {
  3128. "mid": mid
  3129. },
  3130.  
  3131. hasCookies: true,
  3132. success: responseText => {
  3133. let res = HNTOOL.strToJson(responseText);
  3134. if (res.code === 0) {
  3135.  
  3136. resolve(res.data.card);
  3137.  
  3138. } else {
  3139. console.log("获取用户详细信息失败:" + res.message);
  3140. resolve(false);
  3141. }
  3142. }
  3143. })
  3144. });
  3145. },
  3146.  
  3147.  
  3148. getLotteryNotice: async function(dynamic_id) {
  3149. return new Promise((resolve) => {
  3150. Ajax.get({
  3151. url: BILIBLI_PATH.vcapi + '/lottery_svr/v1/lottery_svr/lottery_notice',
  3152. queryStringsObj: {
  3153. "dynamic_id": dynamic_id
  3154. },
  3155. hasCookies: true,
  3156. success: responseText => {
  3157. let res = HNTOOL.strToJson(responseText);
  3158. if (res.code === 0) {
  3159.  
  3160. resolve(res.data);
  3161.  
  3162. } else {
  3163. console.log("获取开奖信息失败:" + res.message);
  3164. resolve(false);
  3165. }
  3166. }
  3167. })
  3168. });
  3169. },
  3170.  
  3171.  
  3172. likeDynamic: async function(dynamic_id) {
  3173.  
  3174. return new Promise((resolve) => {
  3175. Ajax.post({
  3176. url: BILIBLI_PATH.vcapi + '/dynamic_like/v1/dynamic_like/thumb',
  3177. hasCookies: true,
  3178. dataType: 'application/x-www-form-urlencoded',
  3179. data: {
  3180. uid: Live_info.uid,
  3181. dynamic_id: dynamic_id,
  3182. up: 1,
  3183. csrf: Live_info.csrf_token
  3184. },
  3185. success: responseText => {
  3186. let res = HNTOOL.strToJson(responseText);
  3187. if (res.code === 0) {
  3188.  
  3189. javaex.tip({
  3190. content: "动态点赞成功!",
  3191. type: "success"
  3192. });
  3193.  
  3194. resolve(true);
  3195. } else {
  3196.  
  3197. console.log("动态点赞发生错误!" + res.message);
  3198.  
  3199. javaex.tip({
  3200. content: "动态点赞发生错误!" + res.message,
  3201. type: "error"
  3202. });
  3203.  
  3204. resolve(false);
  3205. }
  3206. }
  3207. })
  3208. });
  3209. },
  3210.  
  3211. repostDynamic: async function(dynamic_id, content, ctrl) {
  3212.  
  3213. return new Promise((resolve) => {
  3214. Ajax.post({
  3215. url: BILIBLI_PATH.vcapi + '/dynamic_repost/v1/dynamic_repost/repost',
  3216. dataType: 'application/x-www-form-urlencoded',
  3217. hasCookies: true,
  3218. data: {
  3219. uid: Live_info.uid,
  3220. dynamic_id: dynamic_id,
  3221. content: content,
  3222. extension: '{"emoji_type":1}',
  3223. at_uids: "",
  3224. ctrl: ctrl == null || ctrl == "转发动态" ? "[]" : ctrl,
  3225. csrf_token: Live_info.csrf_token,
  3226. csrf: Live_info.csrf_token
  3227. },
  3228. success: responseText => {
  3229. let res = HNTOOL.strToJson(responseText);
  3230. if (res.code === 0) {
  3231.  
  3232. javaex.tip({
  3233. content: "动态转发成功!",
  3234. type: "success"
  3235. });
  3236.  
  3237. resolve(true);
  3238. } else {
  3239.  
  3240. console.log("动态转发发生错误!" + res.message);
  3241.  
  3242. javaex.tip({
  3243. content: "动态转发发生错误!" + res.message,
  3244. type: "error"
  3245. });
  3246.  
  3247. resolve(false);
  3248. }
  3249. }
  3250. })
  3251. });
  3252. },
  3253.  
  3254. addReply: async function(oid, type) {
  3255.  
  3256. return new Promise((resolve) => {
  3257. Ajax.post({
  3258. url: BILIBLI_PATH.api + '/x/v2/reply/add',
  3259. dataType: 'application/x-www-form-urlencoded',
  3260. hasCookies: true,
  3261. data: {
  3262. "oid": oid,
  3263. "type": type, //11官方 17 加码
  3264. "ordering": 'heat',
  3265. "message": HNTOOL.getRandomWordOfList(replyList) == undefined ? "不错[鼓掌]" :
  3266. HNTOOL.getRandomWordOfList(
  3267. replyList),
  3268. "jsonp": 'jsonp',
  3269. "csrf": Live_info.csrf_token
  3270. },
  3271. success: responseText => {
  3272. let res = HNTOOL.strToJson(responseText);
  3273. if (res.code === 0) {
  3274. javaex.tip({
  3275. content: "'自动评论成功'!",
  3276. type: "success"
  3277. });
  3278. resolve(0);
  3279. } else if (res.code === -404) {
  3280. console.log('自动评论原动态已删除');
  3281. resolve(0);
  3282. } else if (res.code === 12002) {
  3283. console.log('自动评论评论区已关闭');
  3284. resolve(0);
  3285. } else if (res.code === 12015) {
  3286. console.log('自动评论需要输入验证码');
  3287. resolve(1);
  3288. } else {
  3289. console.log('自动评论', `评论失败\n${responseText}`);
  3290. resolve(0);
  3291. }
  3292. }
  3293. })
  3294. });
  3295. },
  3296.  
  3297.  
  3298. setNotice: async function(notice) {
  3299.  
  3300. return new Promise((resolve) => {
  3301. Ajax.post({
  3302. url: BILIBLI_PATH.api + '/x/space/notice/set',
  3303. hasCookies: true,
  3304. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3305. data: {
  3306. notice: notice,
  3307. jsonp: 'jsonp',
  3308. csrf: Live_info.csrf_token
  3309. },
  3310. success: responseText => {
  3311. let res = HNTOOL.strToJson(responseText);
  3312. if (res.code === 0) {
  3313.  
  3314. javaex.tip({
  3315. content: "动态标记保存到个人公告成功!",
  3316. type: "success"
  3317. });
  3318.  
  3319. resolve(true);
  3320. } else {
  3321.  
  3322. javaex.tip({
  3323. content: res.message,
  3324. type: "error"
  3325. });
  3326.  
  3327. resolve(false);
  3328. }
  3329. }
  3330. })
  3331. });
  3332. },
  3333.  
  3334. getSpaceNotice: async function() {
  3335. return new Promise((resolve) => {
  3336. Ajax.get({
  3337. url: BILIBLI_PATH.api + '/x/space/notice',
  3338. queryStringsObj: {
  3339. "mid": Live_info.uid
  3340. },
  3341. hasCookies: true,
  3342. success: responseText => {
  3343. let res = HNTOOL.strToJson(responseText);
  3344. if (res.code === 0) {
  3345.  
  3346. resolve(res.data);
  3347.  
  3348. } else {
  3349. console.log("获取公告信息失败:" + res.message);
  3350. resolve(false);
  3351. }
  3352. }
  3353. })
  3354. });
  3355. },
  3356.  
  3357. getdynamicData: async function(dynamic_id_str) {
  3358. return new Promise((resolve) => {
  3359. Ajax.get({
  3360.  
  3361. url: BILIBLI_PATH.vcapi + '/dynamic_svr/v1/dynamic_svr/get_dynamic_detail',
  3362. queryStringsObj: {
  3363. "dynamic_id": dynamic_id_str
  3364. },
  3365. hasCookies: true,
  3366. success: responseText => {
  3367. let res = HNTOOL.strToJson(responseText);
  3368. if (res.code === 0) {
  3369.  
  3370. resolve(res.data);
  3371.  
  3372. } else {
  3373. console.log("获取动态信息失败:" + res.message);
  3374. resolve(false);
  3375. }
  3376. }
  3377. })
  3378. });
  3379. },
  3380.  
  3381. getAllFollow: async function() {
  3382. return new Promise((resolve) => {
  3383. Ajax.get({
  3384.  
  3385. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  3386. queryStringsObj: {
  3387. "uid": Live_info.uid
  3388. },
  3389. hasCookies: true,
  3390. success: responseText => {
  3391. let res = HNTOOL.strToJson(responseText);
  3392. if (res.code === 0) {
  3393.  
  3394. resolve(res.data.list);
  3395.  
  3396. } else {
  3397. console.log("查询失败!" + res.message);
  3398. resolve(false);
  3399. }
  3400. }
  3401. })
  3402. });
  3403. },
  3404.  
  3405. getCardByUID: async function(UID) {
  3406. return new Promise((resolve) => {
  3407. Ajax.get({
  3408.  
  3409. url: BILIBLI_PATH.api + '/x/web-interface/card',
  3410. queryStringsObj: {
  3411. "mid": UID
  3412. },
  3413. hasCookies: true,
  3414. success: responseText => {
  3415. let res = HNTOOL.strToJson(responseText);
  3416. if (res.code === 0) {
  3417.  
  3418. resolve(res.data.card);
  3419.  
  3420. } else {
  3421. console.log("查询失败!" + res.message);
  3422. resolve(false);
  3423. }
  3424. }
  3425. })
  3426. });
  3427. },
  3428.  
  3429.  
  3430. /**
  3431. *
  3432. *
  3433. */
  3434.  
  3435. getTodayDynamicList: async function(mid, index) {
  3436. return new Promise((resolve) => {
  3437. Ajax.get({
  3438.  
  3439. url: BILIBLI_PATH.api + '/x/space/article',
  3440. queryStringsObj: {
  3441. "mid": mid,
  3442. "pn": 1,
  3443. "ps": 12,
  3444. "sort": 'publish_time'
  3445. },
  3446. hasCookies: true,
  3447. success: responseText => {
  3448. let res = HNTOOL.strToJson(responseText);
  3449. if (res.code === 0) {
  3450. let artlist = false;
  3451. let articlesList = [];
  3452. let articles = res.data.articles;
  3453. for (var i = 0, len = articles.length; i < index; i++) {
  3454. articlesList[i] = articles[i];
  3455. }
  3456.  
  3457. resolve(articlesList);
  3458. } else {
  3459.  
  3460.  
  3461. console.log("查询失败!" + res.message);
  3462. resolve(false);
  3463. }
  3464. }
  3465. })
  3466. });
  3467. },
  3468.  
  3469. getDataByLiveSid: async function(ids) {
  3470. return new Promise((resolve) => {
  3471. Ajax.get({
  3472.  
  3473. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  3474. queryStringsObj: {
  3475. "ids": ids
  3476. },
  3477. hasCookies: true,
  3478. success: responseText => {
  3479. let res = HNTOOL.strToJson(responseText);
  3480. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  3481.  
  3482. resolve(res.data.list);
  3483. } else {
  3484.  
  3485. /* javaex.tip({
  3486. content: "查询失败!" + res.message,
  3487. type: "error"
  3488. }); */
  3489. console.log("查询失败!" + res.message);
  3490.  
  3491. resolve(false);
  3492. }
  3493. }
  3494. })
  3495. });
  3496. },
  3497.  
  3498. /**
  3499. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  3500. */
  3501. clickNow: async function() {
  3502. return new Promise((resolve) => {
  3503. Ajax.get({
  3504.  
  3505. url: BILIBLI_PATH.api + '/x/report/click/now',
  3506. queryStringsObj: {
  3507. jsonp: "jsonp"
  3508. },
  3509. hasCookies: true,
  3510. success: responseText => {
  3511. let res = HNTOOL.strToJson(responseText);
  3512. if (res.code === 0) {
  3513.  
  3514. javaex.tip({
  3515. content: "每日登录" + res.data.text,
  3516. type: "success"
  3517. });
  3518. resolve(true);
  3519.  
  3520. } else {
  3521.  
  3522. javaex.tip({
  3523. content: res.message,
  3524. type: "error"
  3525. });
  3526.  
  3527. resolve(false);
  3528. }
  3529. }
  3530. })
  3531. });
  3532. },
  3533.  
  3534. /**
  3535. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  3536. * @param {number} videoAid
  3537. */
  3538. addShare: async function(videoAid) {
  3539. return new Promise((resolve) => {
  3540. Ajax.post({
  3541. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  3542. hasCookies: true,
  3543. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3544. data: {
  3545. aid: videoAid,
  3546. csrf: Live_info.csrf_token
  3547. },
  3548. success: responseText => {
  3549. let res = HNTOOL.strToJson(responseText);
  3550. if (res.code === 0) {
  3551.  
  3552. javaex.tip({
  3553. content: "每日分享视频成功",
  3554. type: "success"
  3555. });
  3556.  
  3557. resolve(true);
  3558. } else {
  3559.  
  3560. javaex.tip({
  3561. content: res.message,
  3562. type: "error"
  3563. });
  3564.  
  3565. resolve(false);
  3566. }
  3567. }
  3568. })
  3569. });
  3570. },
  3571.  
  3572.  
  3573.  
  3574. /**
  3575. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3576. * @param {number} videoAid
  3577. */
  3578. addArticleCoin: async function(cvID, mid) {
  3579. return new Promise((resolve) => {
  3580. Ajax.post({
  3581. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3582. hasCookies: true,
  3583. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3584. data: {
  3585. aid: cvID,
  3586. upid: mid,
  3587. multiply: 2,
  3588. avtype: 2,
  3589. csrf: Live_info.csrf_token
  3590. },
  3591. success: responseText => {
  3592. let res = HNTOOL.strToJson(responseText);
  3593. if (res.code === 0) {
  3594.  
  3595. javaex.tip({
  3596. content: '专栏:' + cvID + "投币成功",
  3597. type: "success"
  3598. });
  3599.  
  3600. resolve(true);
  3601. } else {
  3602.  
  3603. javaex.tip({
  3604. content: res.message,
  3605. type: "error"
  3606. });
  3607.  
  3608. console.log('专栏投币失败:' + cvID + res.message);
  3609.  
  3610. resolve(false);
  3611. }
  3612. }
  3613. })
  3614. });
  3615. },
  3616.  
  3617. /**
  3618. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  3619. * @param {number} videoAid
  3620. */
  3621. addVideoCoin: async function(videoAid) {
  3622. return new Promise((resolve) => {
  3623. Ajax.post({
  3624. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  3625. hasCookies: true,
  3626. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3627. data: {
  3628. aid: videoAid,
  3629. multiply: 2,
  3630. select_like: 0,
  3631. cross_domain: true,
  3632. csrf: Live_info.csrf_token
  3633. },
  3634. success: responseText => {
  3635. let res = HNTOOL.strToJson(responseText);
  3636. if (res.code === 0) {
  3637.  
  3638. javaex.tip({
  3639. content: "投币成功",
  3640. type: "success"
  3641. });
  3642.  
  3643. resolve(true);
  3644. } else {
  3645.  
  3646. javaex.tip({
  3647. content: res.message,
  3648. type: "error"
  3649. });
  3650.  
  3651. resolve(false);
  3652. }
  3653. }
  3654. })
  3655. });
  3656. },
  3657.  
  3658.  
  3659. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  3660.  
  3661. DoSign: async function() {
  3662. return new Promise((resolve) => {
  3663. Ajax.get({
  3664.  
  3665. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  3666. queryStringsObj: {
  3667.  
  3668. },
  3669. hasCookies: true,
  3670. success: responseText => {
  3671. let res = HNTOOL.strToJson(responseText);
  3672. if (res.code === 0) {
  3673.  
  3674. javaex.tip({
  3675. content: "签到成功:" + res.data.text,
  3676. type: "success"
  3677. });
  3678. resolve(true);
  3679.  
  3680. } else if (res.code === 1011040) {
  3681.  
  3682. javaex.tip({
  3683. content: res.message,
  3684. type: "success"
  3685. });
  3686.  
  3687. resolve(true);
  3688. } else {
  3689.  
  3690. javaex.tip({
  3691. content: res.message,
  3692. type: "error"
  3693. });
  3694.  
  3695. resolve(false);
  3696. }
  3697. }
  3698. })
  3699. });
  3700. },
  3701.  
  3702.  
  3703. /**
  3704. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  3705. */
  3706. getArticleRecommends: async function() {
  3707. return new Promise((resolve) => {
  3708. Ajax.get({
  3709.  
  3710. url: BILIBLI_PATH.api + '/x/article/recommends',
  3711. queryStringsObj: {
  3712. "cid": 0,
  3713. "pn": 1
  3714. },
  3715. hasCookies: true,
  3716. success: responseText => {
  3717. let res = HNTOOL.strToJson(responseText);
  3718. if (res.code === 0) {
  3719.  
  3720. javaex.tip({
  3721. content: "获取最新专栏成功!",
  3722. type: "success"
  3723. });
  3724. resolve(res.data);
  3725.  
  3726. } else {
  3727.  
  3728. javaex.tip({
  3729. content: "获取最新专栏失败!" + res.message,
  3730. type: "error"
  3731. });
  3732.  
  3733. console.log(res.message);
  3734.  
  3735. resolve(false);
  3736. }
  3737. }
  3738. })
  3739. });
  3740. },
  3741. /**
  3742. * // 获取分区最新视频列表
  3743. */
  3744. getDynamicRegion: async function() {
  3745. return new Promise((resolve) => {
  3746. Ajax.get({
  3747.  
  3748. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  3749. queryStringsObj: {
  3750. "pn": 1,
  3751. "ps": 20,
  3752. "rid": 21
  3753. },
  3754. hasCookies: true,
  3755. success: responseText => {
  3756. let res = HNTOOL.strToJson(responseText);
  3757. if (res.code === 0) {
  3758.  
  3759. javaex.tip({
  3760. content: "获取分区最新视频成功",
  3761. type: "success"
  3762. });
  3763. resolve(res.data.archives);
  3764.  
  3765. } else {
  3766.  
  3767. javaex.tip({
  3768. content: "获取分区最新视频失败" + res.message,
  3769. type: "error"
  3770. });
  3771.  
  3772. resolve(false);
  3773. }
  3774. }
  3775. })
  3776. });
  3777. },
  3778.  
  3779. /*
  3780. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  3781. * @param {Object} sid
  3782. */
  3783. reserveActivity: async function(sid) {
  3784. return new Promise((resolve) => {
  3785. Ajax.post({
  3786. url: BILIBLI_PATH.api + '/x/space/reserve',
  3787. hasCookies: true,
  3788. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3789. data: {
  3790. sid: sid, //当前用户
  3791. jsonp: "jsonp",
  3792. csrf: Live_info.csrf_token
  3793. },
  3794. success: responseText => {
  3795. let res = HNTOOL.strToJson(responseText);
  3796. if (res.code === 0) {
  3797.  
  3798. resolve(true);
  3799. } else {
  3800. javaex.tip({
  3801. content: res.message,
  3802. type: "error"
  3803. });
  3804. resolve(false);
  3805. }
  3806. }
  3807. })
  3808. });
  3809. },
  3810. /**
  3811. reserveActivity: async function(sid, reserve_total) {
  3812. return new Promise((resolve) => {
  3813. Ajax.post({
  3814. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  3815. hasCookies: true,
  3816. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3817. data: {
  3818. reserve_id: sid,
  3819. cur_btn_status: 1,
  3820. reserve_total: reserve_total,
  3821. csrf: Live_info.csrf_token
  3822. },
  3823. success: responseText => {
  3824. let res = HNTOOL.strToJson(responseText);
  3825. if (res.code === 0) {
  3826. resolve(res.data);
  3827. } else {
  3828. javaex.tip({
  3829. content: res.message,
  3830. type: "error"
  3831. });
  3832. resolve(false);
  3833. }
  3834. }
  3835. })
  3836. });
  3837. }, */
  3838.  
  3839. getGiftList: async function(room) {
  3840. return new Promise((resolve) => {
  3841. Ajax.get({
  3842.  
  3843. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  3844. queryStringsObj: {
  3845. "room_id": room
  3846. },
  3847. hasCookies: true,
  3848. success: responseText => {
  3849. let res = HNTOOL.strToJson(responseText);
  3850. if (res.code === 0) {
  3851.  
  3852. resolve(res.data.list);
  3853. } else {
  3854.  
  3855. javaex.tip({
  3856. content: "查询包裹失败!" + res.message,
  3857. type: "error"
  3858. });
  3859.  
  3860. resolve(false)
  3861. }
  3862. }
  3863. })
  3864. });
  3865. },
  3866.  
  3867. /**
  3868. * 送银B克拉
  3869. * @param {Object} ruid
  3870. * @param {Object} roomid
  3871. */
  3872. bagSendGift: async function(ruid, roomid, bag_id) {
  3873. return new Promise((resolve) => {
  3874. Ajax.post({
  3875. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  3876. hasCookies: true,
  3877. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  3878. data: {
  3879. uid: Live_info.uid, //当前用户
  3880. gift_id: 3,
  3881. ruid: ruid,
  3882. send_ruid: 0,
  3883. gift_num: 1,
  3884. bag_id: bag_id,
  3885. //rnd: Math.round(new Date() / 1000); //时间戳,
  3886. platform: 'pc',
  3887. biz_code: 'Live',
  3888. biz_id: roomid,
  3889. storm_beat_id: 0,
  3890. price: 0,
  3891. csrf_token: Live_info.csrf_token,
  3892. csrf: Live_info.csrf_token
  3893.  
  3894. },
  3895. success: responseText => {
  3896. let res = HNTOOL.strToJson(responseText);
  3897. if (res.code === 0) {
  3898.  
  3899. javaex.tip({
  3900. content: roomid + "赠送b克拉成功!" + res.message,
  3901. type: "success"
  3902. });
  3903.  
  3904. resolve(true);
  3905. } else {
  3906.  
  3907. javaex.tip({
  3908. content: res.message,
  3909. type: "error"
  3910. });
  3911.  
  3912. resolve(false);
  3913. }
  3914. }
  3915. })
  3916. });
  3917. },
  3918.  
  3919.  
  3920. /**
  3921. * 判断是否有勋章
  3922. * @param {Object} uid
  3923. * @param {Object} room
  3924. */
  3925.  
  3926. getFansMedalInfo: async function(uid, room) {
  3927. return new Promise((resolve) => {
  3928. Ajax.get({
  3929.  
  3930. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  3931. queryStringsObj: {
  3932. "target_id": uid,
  3933. "room_id": room
  3934. },
  3935. //dataType:'application/json, text/plain, */*',
  3936. hasCookies: true,
  3937. success: responseText => {
  3938. let res = HNTOOL.strToJson(responseText);
  3939. if (res.code === 0) {
  3940.  
  3941. if (res.data.my_fans_medal.level == 0) {
  3942. resolve(false)
  3943. } else {
  3944. resolve(true)
  3945. }
  3946.  
  3947. } else {
  3948.  
  3949. javaex.tip({
  3950. content: "查询勋章失败!" + res.message,
  3951. type: "error"
  3952. });
  3953.  
  3954. resolve(false)
  3955. }
  3956. }
  3957. })
  3958. });
  3959. },
  3960.  
  3961.  
  3962.  
  3963.  
  3964. getDisuidList: async function(re_version, pn) {
  3965. return new Promise((resolve) => {
  3966. Ajax.get({
  3967.  
  3968. url: BILIBLI_PATH.api + '/x/relation/blacks',
  3969. queryStringsObj: {
  3970. "re_version": re_version,
  3971. "pn": pn
  3972. },
  3973. hasCookies: true,
  3974. success: responseText => {
  3975. let res = HNTOOL.strToJson(responseText);
  3976. if (res.code === 0) {
  3977. resolve(res.data.list)
  3978. } else {
  3979.  
  3980. javaex.tip({
  3981. content: "查询黑名单失败!" + res.message,
  3982. type: "error"
  3983. });
  3984.  
  3985. resolve(null)
  3986. }
  3987. }
  3988. })
  3989. });
  3990. },
  3991.  
  3992. /**
  3993. * @param {Object} uid
  3994. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  3995. */
  3996. cancelAtt: async function(uid, act, re_src) {
  3997. return new Promise((resolve) => {
  3998. Ajax.post({
  3999. url: BILIBLI_PATH.api + '/x/relation/modify',
  4000. hasCookies: true,
  4001. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4002. data: {
  4003. fid: uid,
  4004. act: act,
  4005. re_src: re_src == undefined ? 11 : 116,
  4006. jsonp: "jsonp",
  4007. csrf: Live_info.csrf_token,
  4008. },
  4009. success: responseText => {
  4010. let res = HNTOOL.strToJson(responseText);
  4011. if (res.code === 0) {
  4012.  
  4013. //HNAPI.cancelAtt(uid, 6);
  4014.  
  4015. javaex.tip({
  4016. content: "取关成功!" + res.message,
  4017. type: "success"
  4018. });
  4019.  
  4020. resolve(true);
  4021. } else if (res.code === 22003) {
  4022.  
  4023. HNAPI.cancelAtt(uid, 6);
  4024.  
  4025. javaex.tip({
  4026. content: "取消拉黑" + res.message,
  4027. type: "success"
  4028. });
  4029. resolve(true);
  4030. } else {
  4031.  
  4032. javaex.tip({
  4033. content: res.message,
  4034. type: "error"
  4035. });
  4036.  
  4037. resolve(false);
  4038. }
  4039. }
  4040. })
  4041. });
  4042. },
  4043.  
  4044. getRoomMsg: async function(roomid) {
  4045. return new Promise((resolve) => {
  4046. Ajax.get({
  4047.  
  4048. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  4049. queryStringsObj: {
  4050. "roomid": roomid
  4051. },
  4052. hasCookies: true,
  4053. success: responseText => {
  4054. let res = HNTOOL.strToJson(responseText);
  4055. if (res.code === 0) {
  4056. resolve(res.data.info.uid)
  4057. } else {
  4058. resolve(false)
  4059. }
  4060. }
  4061. })
  4062. });
  4063. },
  4064.  
  4065. /**
  4066. *
  4067. * @param sid
  4068. * @returns {Promise<unknown>}
  4069. */
  4070. lotteryDo: async function(sid, name) {
  4071. return new Promise((resolve) => {
  4072. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/do';
  4073. if (sid.indexOf("newLottery") != -1) {
  4074. func_url = BILIBLI_PATH.api + "/x/lottery/do";
  4075. }
  4076. Ajax.post({
  4077. url: func_url,
  4078. hasCookies: true,
  4079. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4080. data: {
  4081.  
  4082. sid: sid,
  4083. type: 1,
  4084. csrf: Live_info.csrf_token,
  4085. },
  4086. success: responseText => {
  4087. let res = HNTOOL.strToJson(responseText);
  4088. if (res.code === 0) {
  4089. HNTOOL.console("活动转盘:" + name + "\n " + (res.data)[0].gift_name);
  4090. resolve((res.data)[0].gift_name);
  4091.  
  4092. } else if (res.code ===
  4093. 75400) { // || res.code === 75003 || res.code === 75403
  4094.  
  4095. resolve(true);
  4096. } else {
  4097. javaex.tip({
  4098. content: "本次抽奖失败!" + res.message,
  4099. type: "error"
  4100. });
  4101. resolve(false);
  4102. }
  4103. }
  4104. })
  4105. });
  4106. },
  4107.  
  4108.  
  4109. getLotteryMytimes: async function(sid) {
  4110. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/mytimes';
  4111. if (sid.indexOf("newLottery") != -1) {
  4112. func_url = BILIBLI_PATH.api + "/x/lottery/mytimes";
  4113. }
  4114. return new Promise((resolve) => {
  4115. Ajax.get({
  4116. url: func_url,
  4117. queryStringsObj: {
  4118. sid: sid
  4119. },
  4120. hasCookies: true,
  4121. success: responseText => {
  4122. let res = HNTOOL.strToJson(responseText);
  4123. if (res.code === 0) {
  4124. resolve(res.data.times)
  4125. } else {
  4126. resolve(0)
  4127. }
  4128. }
  4129. })
  4130. });
  4131. },
  4132.  
  4133. /**
  4134. * 增加抽奖次数一般是分享
  4135. * @param sid 活动sid
  4136. * @returns {Promise<unknown>} 0 成功 1:活动结束
  4137. */
  4138. addLotteryTimes: async function(sid) {
  4139. let func_url = BILIBLI_PATH.api + '/x/activity/lottery/addtimes';
  4140. if (sid.indexOf("newLottery") != -1) {
  4141. func_url = BILIBLI_PATH.api + "/x/lottery/addtimes";
  4142. }
  4143.  
  4144. return new Promise((resolve) => {
  4145. Ajax.post({
  4146. url: func_url,
  4147. hasCookies: true,
  4148. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4149. data: {
  4150.  
  4151. sid: sid,
  4152. action_type: 3,
  4153. csrf: Live_info.csrf_token,
  4154. },
  4155. success: responseText => {
  4156. let res = HNTOOL.strToJson(responseText);
  4157. if (res.code === 0) {
  4158.  
  4159. resolve(0)
  4160. } else if (res.code === 75003 || res.code === 170405 || res.code ===
  4161. 75001 || res.code === 170001 || res.code === 75405) {
  4162.  
  4163. resolve(1)
  4164.  
  4165. } else {
  4166.  
  4167. resolve(res.message);
  4168. }
  4169. }
  4170. })
  4171. });
  4172. },
  4173. /**
  4174. * 查询用户关注 默认一次查询50
  4175. * @param vmid 用户uid
  4176. * @param pn 页码
  4177. * @returns {Promise<unknown>}
  4178. */
  4179. getMyFollow: async function(vmid, pn) {
  4180. return new Promise((resolve) => {
  4181. Ajax.get({
  4182. url: BILIBLI_PATH.api + '/x/relation/followings',
  4183. queryStringsObj: {
  4184. vmid: vmid,
  4185. pn: pn
  4186. },
  4187. hasCookies: true,
  4188. success: responseText => {
  4189. let res = HNTOOL.strToJson(responseText);
  4190. if (res.code === 0) {
  4191. resolve(res.data)
  4192. } else {
  4193. resolve(null)
  4194. }
  4195. }
  4196. })
  4197. });
  4198. },
  4199.  
  4200.  
  4201. getMyinfo: function() {
  4202. return new Promise((resolve) => {
  4203. Ajax.get({
  4204. url: BILIBLI_PATH.api + '/x/space/myinfo',
  4205. queryStringsObj: {},
  4206. hasCookies: true,
  4207. success: responseText => {
  4208. let res = HNTOOL.strToJson(responseText);
  4209. if (res.code === 0) {
  4210. resolve(res.data)
  4211. } else {
  4212. resolve(null)
  4213. }
  4214. }
  4215. })
  4216. });
  4217. },
  4218.  
  4219. getMyJson: function(url) {
  4220. return new Promise((resolve) => {
  4221. GM_xmlhttpRequest({
  4222. method: "GET",
  4223. url: url,
  4224. onload: function(response) {
  4225. const res = HNTOOL.strToJson((response || {}).responseText)
  4226. resolve(res);
  4227. }
  4228. });
  4229. })
  4230. },
  4231.  
  4232.  
  4233. userInfo: function(mid) {
  4234.  
  4235. Ajax.get({
  4236. url: BILIBLI_PATH.api + '/x/space/acc/info',
  4237. queryStringsObj: {
  4238. mid: mid
  4239. },
  4240. hasCookies: true,
  4241. success: responseText => {
  4242.  
  4243. var json = JSON.parse(responseText);
  4244.  
  4245. if (json.code != 0) {
  4246.  
  4247.  
  4248. }
  4249. }
  4250. });
  4251.  
  4252. },
  4253.  
  4254. sendQmsg: async function(key, msg) {
  4255.  
  4256. $.ajax({
  4257. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  4258.  
  4259. success: function(result) {
  4260.  
  4261. }
  4262. });
  4263.  
  4264.  
  4265. /*GM_xmlhttpRequest({
  4266. method: "GET",
  4267. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  4268. onload: function (response) {
  4269. let json = JSON.parse(response.response);
  4270. if (json.code == 0) {
  4271. javaex.tip({
  4272. content: "自动动态中奖提醒成功!" + json.reason,
  4273. type: "success"
  4274. });
  4275. } else {
  4276. console.log("自动动态中奖提醒失败!" + json.reason);
  4277. javaex.tip({
  4278. content: "自动动态中奖提醒失败!" + json.reason,
  4279. type: "error"
  4280. });
  4281. }
  4282. }
  4283. });*/
  4284.  
  4285. },
  4286.  
  4287. /**
  4288. * //https://api.bilibili.com/x/relation/modify
  4289. *
  4290. * @param UID
  4291. */
  4292. disUserByUid: function(vmid) {
  4293.  
  4294. Ajax.post({
  4295. url: BILIBLI_PATH.api + '/x/relation/modify',
  4296. data: {
  4297. fid: parseInt(vmid),
  4298. re_src: 11,
  4299. act: 5,
  4300. jsonp: "jsonp",
  4301. csrf: Live_info.csrf_token,
  4302. },
  4303. hasCookies: true,
  4304. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4305. success: responseText => {
  4306.  
  4307. var json = JSON.parse(responseText);
  4308.  
  4309. if (json.code != 0) {
  4310.  
  4311. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  4312. javaex.tip({
  4313. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  4314. type: "error"
  4315. });
  4316.  
  4317. } else {
  4318. console.log("拉黑用户成功 uid:" + vmid);
  4319. javaex.tip({
  4320. content: "拉黑用户成功 uid:" + vmid,
  4321. type: "success"
  4322. });
  4323. }
  4324. }
  4325. });
  4326.  
  4327. },
  4328. /**
  4329. * http://api.bilibili.com/x/web-interface/view
  4330. * @param BV
  4331. * 心跳间隔15秒
  4332. */
  4333. watchOneVideo: function(BV, MID) {
  4334.  
  4335. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  4336. Ajax.post({
  4337. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  4338. hasCookies: true,
  4339. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4340. data: {
  4341.  
  4342. "bvid": BV,
  4343. "part": 1,
  4344. "mid": Live_info.uid,
  4345. "lv": 2,
  4346. "jsonp": "jsonp",
  4347. "type": 3,
  4348. "sub_type": 0
  4349. },
  4350. success: responseText => {
  4351.  
  4352. let json = JSON.parse(responseText);
  4353.  
  4354. if (/^{"code":0/.test(responseText)) {
  4355. //发送一次心跳
  4356. HNAPI.sendHeartbeat(BV, MID);
  4357.  
  4358. } else {
  4359. javaex.tip({
  4360. content: "视频" + data.bvid + "播放失败!" + json.message,
  4361. type: "error"
  4362. });
  4363. }
  4364. }
  4365. })
  4366.  
  4367.  
  4368. },
  4369.  
  4370. //上报视频播放心跳(web端)
  4371. /**
  4372. * http://api.bilibili.com/x/click-interface/web/heartbeat
  4373. * @param json
  4374. */
  4375. sendHeartbeat: function(bvid, MID) {
  4376.  
  4377. Ajax.post({
  4378. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  4379. hasCookies: true,
  4380. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4381. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  4382. data: {
  4383. "bvid": bvid,
  4384. "type": 3,
  4385. "dt": 2,
  4386. "played_time": HNTOOL.random(12, 40),
  4387. "realtime": HNTOOL.random(12, 40),
  4388. "play_type": 0
  4389. },
  4390. success: responseText => {
  4391.  
  4392. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  4393.  
  4394. javaex.tip({
  4395. content: "视频BV" + bvid + "播放一次!",
  4396. type: "success"
  4397. });
  4398. }
  4399. }
  4400. })
  4401.  
  4402. },
  4403.  
  4404. //获取up所有投稿视频
  4405. /**
  4406. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  4407. * @param mid
  4408. */
  4409. getUpAllBV: function(mid, pn, ps) {
  4410. ps = (ps === undefined ? 30 : ps); // a默认值为1
  4411. Ajax.get({
  4412. url: BILIBLI_PATH.api + '/x/space/arc/search',
  4413. queryStringsObj: {
  4414. mid: mid,
  4415. tid: 0,
  4416. order: 'pubdate',
  4417. jsonp: 'jsonp',
  4418. pn: pn,
  4419. ps: ps
  4420. },
  4421. hasCookies: true,
  4422. success: responseText => {
  4423.  
  4424. var json = JSON.parse(responseText);
  4425.  
  4426. if (json.code != 0) {
  4427.  
  4428. javaex.tip({
  4429. content: "获取up所有投稿视频失败!" + json.message,
  4430. type: "success"
  4431. });
  4432.  
  4433. } else {
  4434. BiliData.BVList = json.data.list.vlist;
  4435.  
  4436. }
  4437. }
  4438. });
  4439.  
  4440. },
  4441.  
  4442.  
  4443. /**
  4444. *
  4445. * @param path
  4446. * @param data
  4447. * @param saveObj
  4448. * @param Func
  4449. */
  4450. publicGet: function(path, queryStringsObj) {
  4451.  
  4452. if (typeof(queryStringsObj) != "undefined") {
  4453. queryStringsObj = {};
  4454. }
  4455. Ajax.get({
  4456. url: BILIBLI_PATH.api + path,
  4457. queryStringsObj: queryStringsObj,
  4458. hasCookies: true,
  4459. success: responseText => {
  4460.  
  4461. let json = JSON.parse(responseText);
  4462. if (chackCode(json.code) && json.code == 0) {
  4463.  
  4464. return json.data;
  4465. }
  4466.  
  4467. return false;
  4468.  
  4469. }
  4470. })
  4471.  
  4472. },
  4473.  
  4474. /**
  4475. * 导航栏用户信息
  4476. */
  4477. getUserNav: async function() {
  4478.  
  4479. GM_xmlhttpRequest({
  4480. method: "GET",
  4481. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  4482. //timeout:3000,
  4483. onload: function(response) {
  4484.  
  4485. let json = JSON.parse(response.response);
  4486. console.log(json);
  4487. BiliData.login_code = json.code;
  4488. BiliData.login_message = json.message;
  4489. BiliData.LoginData = json.data;
  4490.  
  4491. }
  4492. });
  4493.  
  4494. },
  4495.  
  4496. /**
  4497. * 获取某up详细信息
  4498. * http://api.bilibili.com/x/web-interface/card
  4499. */
  4500. getUpCard: function(mid) {
  4501.  
  4502. Ajax.get({
  4503. url: BILIBLI_PATH.api + '/x/web-interface/card',
  4504. queryStringsObj: {
  4505. mid: mid,
  4506. photo: false
  4507. },
  4508. hasCookies: true,
  4509. success: responseText => {
  4510.  
  4511. var json = JSON.parse(responseText);
  4512.  
  4513. if (json.code != 0) {
  4514.  
  4515. javaex.tip({
  4516. content: "查询失败!" + json.message,
  4517. type: "success"
  4518. });
  4519. return false;
  4520. } else {
  4521. BiliData.upCard = json;
  4522.  
  4523. }
  4524.  
  4525.  
  4526. }
  4527. })
  4528.  
  4529. },
  4530.  
  4531. /**
  4532. *
  4533. * @param uid 用户uid
  4534. * @param ps 每页视频个数 默认30个
  4535. * @param pn 第几页
  4536. */
  4537. getUpAllVideo: function(uid, ps, pn) {
  4538.  
  4539. },
  4540. getChallenge: async function() {
  4541.  
  4542.  
  4543. },
  4544. /**
  4545. * 硬币记录
  4546. * @returns {Promise<void>}
  4547. */
  4548. getCoinLog: async function() {
  4549.  
  4550. GM_xmlhttpRequest({
  4551. method: "GET",
  4552. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  4553. //url: "http://api.bilibili.com/x/member/web/coin/log",
  4554. onload: function(response) {
  4555.  
  4556. let json = JSON.parse(response.response);
  4557. if (json.code == 0) {
  4558.  
  4559. console.log("硬币记录" + json);
  4560. BiliData.CoinLog = json.data;
  4561.  
  4562. return true;
  4563. }
  4564.  
  4565. }
  4566. });
  4567. },
  4568. /**
  4569. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  4570. * @returns {Promise<void>}
  4571. */
  4572. getUnread: async function() {
  4573.  
  4574. Ajax.get({
  4575. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4576. hasCookies: true,
  4577. success: responseText => {
  4578.  
  4579. let json = JSON.parse(responseText);
  4580. if (chackCode(json.code) && json.code == 0) {
  4581.  
  4582. BiliData.Unread = json.data;
  4583. showUnreadMsg();
  4584. }
  4585.  
  4586. return false;
  4587.  
  4588. }
  4589. })
  4590.  
  4591. /* GM_xmlhttpRequest({
  4592. method: "GET",
  4593. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  4594. onload: function (response) {
  4595. let json = JSON.parse(response.response);
  4596. if (chackCode(json.code) && json.code == 0) {
  4597. BiliData.Unread = json.code;
  4598. showUnreadMsg();
  4599. }
  4600. }
  4601. });*/
  4602. },
  4603. /**
  4604. *
  4605. * @param type reply:回复我的 at @我的
  4606. */
  4607. getMsgfeed: function(type) {
  4608. Ajax.get({
  4609. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  4610. queryStringsObj: {
  4611. build: 0,
  4612. mobi_app: 'web'
  4613. },
  4614. hasCookies: true,
  4615. success: responseText => {
  4616.  
  4617. var json = JSON.parse(responseText);
  4618.  
  4619. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  4620. return false;
  4621. } else {
  4622. chackAtMsg(json.data.items);
  4623.  
  4624. return true;
  4625. }
  4626.  
  4627.  
  4628. }
  4629. })
  4630.  
  4631. },
  4632.  
  4633. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  4634. * @returns {Promise<void>}
  4635. */
  4636. getUnrewad: async function() {
  4637.  
  4638. GM_xmlhttpRequest({
  4639. method: "GET",
  4640. data: {
  4641. "mid": 99439379,
  4642. "pn": 1,
  4643. "ps": 5,
  4644. },
  4645. url: BILIBLI_PATH.api + "/x/space/arc/search",
  4646. onload: function(response) {
  4647.  
  4648. let json = JSON.parse(response.response);
  4649. if (json.code == 0) {
  4650.  
  4651. BiliData.Video = json.data;
  4652. console.log("未读消息数" + json);
  4653. }
  4654.  
  4655. }
  4656. });
  4657. },
  4658.  
  4659. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  4660. * @param {number} oid
  4661. * @param {nbumber} rpid
  4662. * @param {number} action
  4663. * @returns {Promise<void>}
  4664. * type: 11
  4665. * ordering: heat
  4666. * jsonp: jsonp
  4667. * csrf: 54a******* CSRF Token(位于cookie)
  4668. */
  4669.  
  4670. likeInDynamicComments: async function(latestDynamic) {
  4671.  
  4672.  
  4673. Ajax.post({
  4674. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  4675. hasCookies: true,
  4676. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  4677. data: {
  4678. "oid": oid,
  4679. "type": 11,
  4680. "rpid": rpid,
  4681. "action": action,
  4682. "ordering": "heat",
  4683. "jsonp": "jsonp",
  4684. "csrf": Live_info.csrf_token,
  4685. },
  4686. success: responseText => {
  4687.  
  4688. if (/^{"code":0/.test(responseText)) {
  4689.  
  4690. BiliData.replyAction = JSON.parse(responseText);
  4691. console.log("点赞成功!" + responseText);
  4692. }
  4693. }
  4694. })
  4695.  
  4696. }
  4697.  
  4698.  
  4699. }
  4700.  
  4701. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  4702. var http_request = null;
  4703.  
  4704. function send_request(url, method) {}
  4705.  
  4706. let HNTOOL = {
  4707.  
  4708. getvisit_id: function(name = NAME) {
  4709.  
  4710. let str = "xxxxxxxxxxxx".replace(/[x]/g, (function(name) {
  4711. let randomInt = 16 * Math.random() | 0;
  4712. return ("x" === name ? randomInt : 3 & randomInt | 8).toString(16).toLowerCase();
  4713. }))
  4714. return str
  4715.  
  4716. },
  4717. /**
  4718. * 判断是否为整数类型方式
  4719. * @param {Object} obj
  4720. */
  4721. isInteger: function(obj) {
  4722.  
  4723. return obj % 1 === 0
  4724.  
  4725. },
  4726.  
  4727. jury_case: async function() {
  4728.  
  4729. for (let i = 0; i < 30; i++) {
  4730.  
  4731. //1.获取题号
  4732. let case_id = await HNAPI.jury_case_next();
  4733. await HNTOOL.Sleep(1000);
  4734. if (case_id == false) {
  4735. break;
  4736. }
  4737. //2.获取该题号详情
  4738. let vote = await HNAPI.jury_case_info(case_id);
  4739. await HNTOOL.Sleep(4 * 1000);
  4740. if (vote == false) {
  4741. break;
  4742. }
  4743. let opinion = await HNAPI.jury_case_opinion(case_id);
  4744. await HNTOOL.Sleep(15 * 1000);
  4745. //3.开始答题
  4746. let result = await HNAPI.jury_vote(case_id, vote, 1);
  4747. if (result) {
  4748. HNTOOL.console("第" + (i + 1) + "个案号:" + case_id + "完成!");
  4749. } else {
  4750. alert(result);
  4751. }
  4752. let case_id3 = await HNAPI.jury_case_next();
  4753.  
  4754. }
  4755.  
  4756. },
  4757. console: function(str, color, type) {
  4758. if (color != undefined) {
  4759. console.log(javaex.now() + "\n" + "%c " + str, "color:#" + color + ";font-weight:bold;");
  4760. } else {
  4761. console.log(javaex.now() + "\n" + "%c " + str, "color:#005500;font-weight:bold;");
  4762. }
  4763.  
  4764.  
  4765. javaex.tip({
  4766. content: str,
  4767. type: type == undefined || type == "success" ? "success" : type
  4768. });
  4769.  
  4770. },
  4771.  
  4772. doOneDynamic: async function(randomtime) {
  4773.  
  4774. var myVar = setInterval(async function() {
  4775.  
  4776. let randomStr = await HNTOOL.getRandomString();
  4777. await HNAPI.sendOneDynamic(randomStr);
  4778.  
  4779. }, randomtime);
  4780. },
  4781.  
  4782. getRandomString: function() {
  4783.  
  4784. return new Promise((resolve) => {
  4785. Ajax.get({
  4786. url: "https://api.mcloc.cn/love/",
  4787. //url: 'https://api.mcloc.cn/words/?type=json',//随机一个句子
  4788. //url: 'https://interface.meiriyiwen.com/article/random?dev=1',//随机一个句子
  4789. queryStringsObj: {
  4790. type: "json"
  4791. },
  4792. dataType: "text/html; charset=UTF-8",
  4793. hasCookies: false,
  4794. success: responseText => {
  4795.  
  4796. try {
  4797. let res = HNTOOL.strToJson(responseText);
  4798. resolve(res.data); //随机一句情话
  4799. //resolve(body.data+"---"+body.creator);//随机一个句子
  4800. //resolve(body.data.digest);//随机一个句子
  4801. } catch (e) {
  4802.  
  4803. resolve("你的名字,是我见过最短的情诗。"); //随机一句情话
  4804. }
  4805.  
  4806.  
  4807. }
  4808. })
  4809. });
  4810. },
  4811.  
  4812. getLatestDynamic: async function() {
  4813.  
  4814. let latestDynamic = await HNAPI.getTodayDynamicList(226257459, 3);
  4815. await HNTOOL.Sleep(1000);
  4816. let ldList = [];
  4817. let ldList2 = [];
  4818. for (let ld1 of latestDynamic) {
  4819.  
  4820. let ld = await HNTOOL.getDynamicIdList(ld1);
  4821. await HNTOOL.Sleep(1000);
  4822. ldList = ldList.concat(ld);
  4823. }
  4824.  
  4825. let latestDynamic2 = await HNAPI.getTodayDynamicList(2295698, 2);
  4826. await HNTOOL.Sleep(1000);
  4827.  
  4828. for (let ld2 of latestDynamic) {
  4829.  
  4830. let ld = await HNTOOL.getDynamicIdList(ld2);
  4831. await HNTOOL.Sleep(1000);
  4832. ldList2 = ldList2.concat(ld);
  4833. }
  4834. ldList.push.apply(ldList, ldList2);
  4835.  
  4836. let result = HNTOOL.arrUnique(ldList, false);
  4837.  
  4838. return result;
  4839.  
  4840. },
  4841.  
  4842. getDynamicIdList: async function(latestDynamic) {
  4843.  
  4844.  
  4845.  
  4846. return new Promise((resolve) => {
  4847. Ajax.get({
  4848. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  4849. queryStringsObj: {
  4850.  
  4851. },
  4852. dataType: "text/html; charset=utf-8",
  4853. hasCookies: true,
  4854. success: responseText => {
  4855. let datalist = HNTOOL.httpString(responseText);
  4856. let dls;
  4857. let returnlist = [];
  4858. if (datalist != undefined && datalist.length > 0) {
  4859. for (let dl of datalist) {
  4860.  
  4861. let len = dl.indexOf("?");
  4862. if (len == -1) {
  4863. dl += "?tab=2";
  4864. }
  4865. dls = dl.substring(dl.indexOf("?") - 18, dl.indexOf("?"));
  4866. if (dls == false ||
  4867. dls == null ||
  4868. dl.indexOf("read") > -1 ||
  4869. dl.indexOf("html") > -1 ||
  4870. dl.indexOf("pixiv") > -1 ||
  4871. returnlist.indexOf(dls) > -1) {
  4872. continue;
  4873. }
  4874.  
  4875. returnlist.push(dls);
  4876.  
  4877. }
  4878.  
  4879. resolve(HNTOOL.arrUnique(returnlist, false));
  4880. } else {
  4881. resolve(false);
  4882. }
  4883. }
  4884. })
  4885. });
  4886. },
  4887.  
  4888. httpString: function(s) {
  4889. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  4890. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  4891. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4892. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  4893. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  4894. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  4895. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  4896. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  4897. s = s.match(reg);
  4898. console.log(s)
  4899. return (s)
  4900. },
  4901.  
  4902. saveConfig: function() {
  4903.  
  4904. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  4905. /* javaex.tip({
  4906. content: "配置保存成功!",
  4907. type: "success"
  4908. }); */
  4909.  
  4910. },
  4911.  
  4912. copyText: function(domId) {
  4913. let btn = document.getElementById(domId);
  4914. btn.select();
  4915. if (document.execCommand('copy')) {
  4916. document.execCommand('copy');
  4917. javaex.tip({
  4918. content: "复制成功!",
  4919. type: "success"
  4920. });
  4921. }
  4922.  
  4923. },
  4924. /**
  4925. * s数组去重并排序
  4926. */
  4927.  
  4928. arrUnique: function(ary, isSort) {
  4929.  
  4930. if (isSort == undefined) {
  4931. isSort = true
  4932. }
  4933. let obj = {};
  4934. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  4935. let item = ary[i]
  4936. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  4937. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  4938. // 如果没有 将这个元素添加到对象中
  4939. if (isSort) {
  4940. ary.sort((a, b) => {
  4941. return a - b
  4942. }) // 数组去重后 按升序排列
  4943. }
  4944.  
  4945. obj = null;
  4946.  
  4947. javaex.tip({
  4948. content: "已去重!",
  4949. type: "success"
  4950. });
  4951. return ary;
  4952.  
  4953. },
  4954.  
  4955. split_array: function(arr, len) {
  4956.  
  4957. let arr_length = arr.length;
  4958. let newArr = [];
  4959. for (let i = 0; i < arr_length; i += len) {
  4960. newArr.push(arr.slice(i, i + len));
  4961. }
  4962. return newArr;
  4963. },
  4964. strToJson: function(params) {
  4965. const isJSON = (str => {
  4966. if (typeof str === 'string') {
  4967. try {
  4968. const obj = JSON.parse(str);
  4969. return typeof obj === 'object' ? obj : false
  4970. } catch (_) {
  4971. console.log(str);
  4972. return false;
  4973. }
  4974. } else {
  4975. console.log(`${str}\nIt is not a string!`);
  4976. return false;
  4977. }
  4978. })(params);
  4979. return isJSON ? isJSON : {}
  4980. },
  4981.  
  4982. chackAtMsg: function() {
  4983.  
  4984. let config = HNTOOL.getConfig();
  4985. if (config.qmsg_checked == true && config.qmsg_key) {
  4986.  
  4987. document.getElementById("getAtMsg").click();
  4988.  
  4989. }
  4990.  
  4991. },
  4992.  
  4993. cssChecked: function(id, dom) {
  4994.  
  4995. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  4996.  
  4997.  
  4998. },
  4999. getConfig: function() {
  5000.  
  5001. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  5002.  
  5003. if (CONFIG == null) {
  5004. CONFIG = HN_SETUP_CONFIG;
  5005. }
  5006.  
  5007. return CONFIG;
  5008. },
  5009.  
  5010. /**
  5011. * 获取cookie 中某个键对应的值
  5012. * @param name
  5013. */
  5014.  
  5015. getCookie: function(name) {
  5016. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  5017. if (arr != null) return escape(arr[2]);
  5018. return false;
  5019. },
  5020. /**
  5021. * 得到一个字符串数组的中随机一个
  5022. * @param {List} list
  5023. */
  5024.  
  5025.  
  5026. getRandomWordOfList: function(list) {
  5027. var L = list.length;
  5028. var i = Math.ceil(Math.random() * (L - 1));
  5029.  
  5030. return list[i];
  5031. },
  5032. random: function(min, max) {
  5033.  
  5034. return Math.floor(Math.random() * (max - min)) + min;
  5035. },
  5036.  
  5037. Sleep: function(ms) {
  5038. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  5039. }
  5040.  
  5041. }
  5042.  
  5043. let errorMsg = {
  5044. "-1": "应用程序不存在或已被封禁!",
  5045. "-2": "Access Key错误!",
  5046. "-3": "API校验密匙错误!",
  5047. "-4": "调用方对该Method没有权限!",
  5048. "-101": "账号未登录!",
  5049. "-102": "账号被封停!",
  5050. "-103": "积分不足!",
  5051. "-104": "硬币不足!",
  5052. "-105": "验证码错误!",
  5053. "-106": "账号非正式会员或在适应期!",
  5054. "-107": "应用不存在或者被封禁!",
  5055. "-108": "未绑定手机!",
  5056. "-109": "未知!",
  5057. "-110": "未绑定手机!",
  5058. "-111": "csrf 校验失败!",
  5059. "-112": "系统升级中!",
  5060. "-113": "账号尚未实名认证!",
  5061. "-114": "请先绑定手机!",
  5062. "-115": "请先完成实名认证!",
  5063. "-304": "木有改动!",
  5064. "-307": "撞车跳转!",
  5065. "-400": "请求错误!",
  5066. "-401": "未认证!",
  5067. "-403": "访问权限不足!",
  5068. "-404": "啥都木有!",
  5069. }
  5070.  
  5071. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  5072. /**
  5073. *
  5074. * @param code
  5075. * @constructor
  5076. */
  5077. let chackCode = function(code) {
  5078.  
  5079. let emsg = errorMsg[code + ""];
  5080. if (emsg != null) {
  5081. javaex.tip({
  5082. content: emsg,
  5083. type: "error"
  5084. });
  5085.  
  5086. return false;
  5087. }
  5088.  
  5089. return true;
  5090. }
  5091.  
  5092.  
  5093. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  5094. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  5095.  
  5096. /*window.onbeforeunload = function() {
  5097. if (!canLeavePage()) {
  5098. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  5099. }
  5100. };*/
  5101.  
  5102.  
  5103. /**
  5104. * Ajax请求对象
  5105. */
  5106. const Ajax = (() => {
  5107. /**
  5108. * 检查options是否符合要求
  5109. * @param {object} options
  5110. * @returns {boolean}
  5111. */
  5112. function checkOptions(options) {
  5113. let result = false;
  5114. if (typeof options !== 'object') {
  5115. console.warn('类型错误: typeof Options !== Object');
  5116. return result;
  5117. } else {
  5118. if (typeof options.url !== 'string') {
  5119. console.warn('类型错误: typeof Link !== Strings');
  5120. return result;
  5121. } else {
  5122. const reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  5123. //const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  5124. if (!reg.test(options.url)) {
  5125. console.warn('url字符串须为完整http链接');
  5126. return result;
  5127. }
  5128. result = true;
  5129. }
  5130. }
  5131. return result;
  5132. }
  5133.  
  5134. /**
  5135. * 对象转URL编码
  5136. * @param {object} data
  5137. */
  5138. function objToURLCode(data) {
  5139. var _result = [];
  5140. for (var key in data) {
  5141. var value = data[key];
  5142. if (value instanceof Array) {
  5143. value.forEach(function(_value) {
  5144. _result.push(key + "=" + _value);
  5145. });
  5146. } else {
  5147. _result.push(key + '=' + value);
  5148. }
  5149. }
  5150. return _result.join('&');
  5151. }
  5152.  
  5153. /**
  5154. * 请求
  5155. * @param {string} method
  5156. * @param {object} options
  5157. */
  5158. function request(method, options) {
  5159. if (checkOptions(options)) {
  5160. let xhr = new XMLHttpRequest();
  5161. const {
  5162. url: _url,
  5163. queryStringsObj,
  5164. data,
  5165. dataType,
  5166. payload,
  5167. hasCookies
  5168. } = options, url = typeof queryStringsObj === 'object' ?
  5169. _url + '?' + objToURLCode(queryStringsObj) : _url;
  5170. switch (method) {
  5171. case 'GET':
  5172. xhr.open("GET", url);
  5173. break;
  5174. case 'POST':
  5175. xhr.open("POST", url);
  5176. xhr.setRequestHeader('Content-Type', dataType);
  5177. //xhr.setRequestHeader('Accept-Encoding', "Mozilla/5.0 (Linux; U; Android 4.0; en-us; GT-I9300 Build/IMM76D) AppleWebKit/534.30 (KHTML, like Gecko) Version/4.0 Mobile Safari/534.30");
  5178. break;
  5179. default:
  5180. break;
  5181. }
  5182. if (hasCookies) xhr.withCredentials = true;
  5183. xhr.timeout = 3000;
  5184. xhr.addEventListener('load', () => {
  5185. if (xhr.status === 200) {
  5186. options.success(xhr.responseText)
  5187. } else {
  5188. console.error(`status:${xhr.status}`);
  5189. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  5190. }
  5191. })
  5192. xhr.addEventListener('error', () => {
  5193. console.error('ajax请求出错')
  5194. options.success('{"code":-1,"msg":"ajax请求出错"}');
  5195. })
  5196. xhr.addEventListener('timeout', () => {
  5197. console.error('请求超时')
  5198. options.success('{"code":-1,"msg":"请求超时"}');
  5199. })
  5200. switch (method) {
  5201. case 'GET':
  5202. xhr.send()
  5203. break;
  5204. case 'POST':
  5205. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  5206. //xhr.send(payload);
  5207. break;
  5208. default:
  5209. break;
  5210. }
  5211. }
  5212. }
  5213.  
  5214. return {
  5215. /**
  5216. * 发送Get请求
  5217. * @param {Object} options
  5218. */
  5219. get(options) {
  5220. request("GET", options);
  5221. },
  5222. /**
  5223. * 发送Post请求
  5224. * @param {object} options
  5225. */
  5226. post(options) {
  5227. request("POST", options);
  5228. }
  5229. }
  5230. })()