-哔哩猫-(试用版)

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

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

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

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