-哔哩猫-(试用版)

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

目前為 2021-07-25 提交的版本,檢視 最新版本

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