-哔哩猫-(试用版)

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

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

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