-哔哩猫-(试用版)

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

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

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