Greasy Fork is available in English.

-哔哩猫-(试用版)

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

2021-07-30 يوللانغان نەشرى. ئەڭ يېڭى نەشرىنى كۆرۈش.

بۇ قوليازمىنى بىۋاسىتە قاچىلاشقا بولمايدۇ. بۇ باشقا قوليازمىلارنىڭ ئىشلىتىشى ئۈچۈن تەمىنلەنگەن ئامبار بولۇپ، ئىشلىتىش ئۈچۈن مېتا كۆرسەتمىسىگە قىستۇرىدىغان كود: // @require https://update.greatest.deepsurf.us/scripts/422731/955637/-%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.51
  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.  
  1114. $("#dynamicActivity").bind("click", async function() {
  1115.  
  1116. let dynamic_id_list = HNTOOL.getDynamicIdList();
  1117.  
  1118. console.log(dynamic_id_list)
  1119.  
  1120.  
  1121. });
  1122.  
  1123. $("#batchFollowOfbastard").bind("click", async function() {
  1124.  
  1125. if (confirm("作者个人需求开发,谨慎使用!!!\n 本功能会取关设定值以下没有认证(官方&&个人)的关注! \n 不确定使用请取消!")) {
  1126.  
  1127. let fansNum = prompt("请输入最低粉丝数量", "50000");
  1128.  
  1129. if (fansNum != null && fansNum != "") {
  1130. //fansNum
  1131.  
  1132. let followList = await HNAPI.getAllFollow();
  1133. console.log(followList);
  1134. await HNTOOL.Sleep(2000);
  1135.  
  1136. for (let fl of followList) {
  1137.  
  1138. if (fl == 99439379) {
  1139. continue;
  1140. }
  1141. let user = await HNAPI.getCardByUID(fl);
  1142. await HNTOOL.Sleep(1000);
  1143. if (user.fans < parseInt(fansNum) && user.official_verify.type == -1) {
  1144.  
  1145. await HNAPI.cancelAtt(fl, 2);
  1146.  
  1147. javaex.tip({
  1148. content: "uid:" + user.mid + "-" + user.name +"---符合条件 取关成功!!!",
  1149. type: "success"
  1150. });
  1151. console.log("uid:" + user.mid + "-" + user.name +"--符合条件 取关成功!!!");
  1152.  
  1153. }else{
  1154. javaex.tip({
  1155. content: "uid:" + user.mid + "-" + user.name +"---不符合条件 取消!!!",
  1156. type: "success"
  1157. });
  1158. console.log("uid:" + user.mid + "-" + user.name +"---不符合条件 取消!!!");
  1159. }
  1160. }
  1161. }
  1162.  
  1163. }
  1164.  
  1165. });
  1166.  
  1167.  
  1168. $("#reserveActivity").bind("click", async function() {
  1169.  
  1170.  
  1171. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1172. let myjson = await HNAPI.getMyJson(url);
  1173.  
  1174. let lastSid = HNTOOL.getConfig().Booking_last_sid;
  1175. if (typeof(lastSid) == "undefined") {
  1176. lastSid = HN_SETUP_CONFIG.Booking_last_sid;
  1177. }
  1178. lastSid = lastSid.split("&")[1];
  1179.  
  1180.  
  1181.  
  1182. for (const sid in myjson) {
  1183.  
  1184. if (lastSid >= sid) {
  1185.  
  1186. continue;
  1187. }
  1188.  
  1189. let siddata = myjson[sid];
  1190. //let sidList = await HNAPI.getDataByLiveSid(sid);
  1191. //await HNTOOL.Sleep(2000);
  1192.  
  1193. //let returnData = await HNAPI.reserveActivity(sid, sidList[sid].total);
  1194. await HNAPI.reserveActivity(sid);
  1195. await HNTOOL.Sleep(2000);
  1196.  
  1197. let tiplog = "\n --预约开始:" + javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') +
  1198. //"\n --预约SID:" + siddata.sid +
  1199. //"\n --预约UID:" + siddata.upmid +
  1200. //"\n --预约地址:" + siddata.prizeInfo.jumpUrl +
  1201. "\n --预约人数:" + siddata.total + "人" +
  1202. "\n --预约奖品:" + siddata.prizeInfo.text;
  1203.  
  1204. console.log(tiplog);
  1205.  
  1206. javaex.tip({
  1207. content: tiplog,
  1208. type: "success"
  1209. });
  1210.  
  1211. HN_SETUP_CONFIG.Booking_last_sid = Live_info.uid + "&" + sid;
  1212.  
  1213. }
  1214.  
  1215. HNTOOL.saveConfig();
  1216.  
  1217. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  1218.  
  1219. alert("预约抽奖结束");
  1220. });
  1221.  
  1222. $("#plateActivity").bind("click", async function() {
  1223.  
  1224. //获取轮盘数据
  1225.  
  1226. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1227. let myjson = await HNAPI.getMyJson(url);
  1228. let lmt = 0;
  1229. let k = 20; //重试次数 防止卡主
  1230. let giftArr = [];
  1231. let endAtion = [];
  1232.  
  1233. javaex.tip({
  1234. content: "开始参加轮盘!!!",
  1235. type: "success"
  1236. });
  1237.  
  1238. await HNAPI.getUserNav();
  1239. await HNTOOL.Sleep(1500);
  1240.  
  1241.  
  1242. for (const json of myjson) {
  1243. //let x = json.name;
  1244. for (let i = 0; i < 20; i++) {
  1245. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1246. let resout = await HNAPI.addLotteryTimes(json.sid);
  1247.  
  1248. await HNTOOL.Sleep(200);
  1249. if (resout == 1) {
  1250.  
  1251. endAtion.push(json.name + ":活动已结束!");
  1252. javaex.tip({
  1253. content: json.name + "活动已结束!",
  1254. type: "success"
  1255. });
  1256.  
  1257. break;
  1258. }
  1259. if (resout != 0 && resout != 1) {
  1260.  
  1261. javaex.tip({
  1262. content: json.name + resout,
  1263. type: "error"
  1264. });
  1265.  
  1266. break;
  1267. }
  1268.  
  1269. if (resout == 0) {
  1270.  
  1271. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1272. continue;
  1273. }
  1274.  
  1275. }
  1276.  
  1277. javaex.tip({
  1278. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1279. type: "success"
  1280. });
  1281.  
  1282. await HNTOOL.Sleep(1500);
  1283.  
  1284. for (let i = 0; i < lmt; i++) {
  1285.  
  1286. let gift = await HNAPI.lotteryDo(json.sid);
  1287.  
  1288.  
  1289. if (gift == true) {
  1290.  
  1291. javaex.tip({
  1292. content: "点击过快,9秒后自动重试!!!",
  1293. type: "error"
  1294. });
  1295.  
  1296. i--;
  1297. k--;
  1298. }
  1299.  
  1300. if (gift == false || k == 0) {
  1301. break;
  1302. }
  1303.  
  1304. if (gift != "未中奖0" && gift != true) {
  1305. giftArr.push(json.name + "奖品为:" + gift);
  1306. break;
  1307. } else {
  1308. javaex.tip({
  1309. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1310. type: "success"
  1311. });
  1312. }
  1313. await HNTOOL.Sleep(9000);
  1314.  
  1315. }
  1316.  
  1317.  
  1318. }
  1319.  
  1320.  
  1321. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1322. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1323.  
  1324. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1325. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1326.  
  1327.  
  1328. });
  1329.  
  1330. $("#addPlay").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.  
  1338. html += ' <div class="javaex-unit clear">'
  1339. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1340. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1341. html +=
  1342. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1343. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1344. html += ' </div>'
  1345. html += ' </div>'
  1346. html += ' <div class="javaex-unit clear">'
  1347. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1348. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1349. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1350. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1351. html += ' </div>'
  1352. html += ' </div>'
  1353. html += '</form>';
  1354. html += ' <div class="javaex-unit clear tc">'
  1355. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1356. html += ' </div>'
  1357. html += '<hr class="javaex-divider"></hr>';
  1358. html += '</div>';
  1359.  
  1360.  
  1361. javaex.panel(this, {
  1362. position: "right",
  1363. content: html
  1364. });
  1365.  
  1366. $("#addPlay_bgn").click(async function() {
  1367.  
  1368. let MID = javaex.getSelectVal("#addPlay_uid")
  1369. let BV = javaex.getSelectVal("#addPlay_bv");
  1370. let bvArr = [];
  1371. let bvArr2 = [];
  1372.  
  1373. MID = javaex.ifnull(MID, BiliData.author_uid);
  1374.  
  1375.  
  1376. if (BV == "0") {
  1377.  
  1378. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1379. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1380. await HNTOOL.Sleep(500);
  1381. bvArr2 = BiliData.BVList;
  1382.  
  1383. for (let i = 1; i > 0; i++) {
  1384.  
  1385. HNAPI.getUpAllBV(MID, i);
  1386.  
  1387. await HNTOOL.Sleep(500);
  1388.  
  1389. if (BiliData.BVList.length == 0) {
  1390. if (bvArr.length == 0) {
  1391. javaex.tip({
  1392. content: "该用户无投稿视频,请确认是否有误!",
  1393. type: "success"
  1394. });
  1395. await HNTOOL.Sleep(2000);
  1396. }
  1397. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1398. bvArr = bvArr.concat(bvArr2);
  1399. break;
  1400. }
  1401.  
  1402. bvArr = bvArr.concat(BiliData.BVList);
  1403. }
  1404.  
  1405.  
  1406. if (bvArr.length != 0) {
  1407.  
  1408. for (const emt of bvArr) {
  1409.  
  1410. HNAPI.playOneVideo(emt.bvid, MID);
  1411.  
  1412. await HNTOOL.Sleep(2000);
  1413.  
  1414. }
  1415.  
  1416. alert("播放完成!!!");
  1417.  
  1418. }
  1419.  
  1420.  
  1421. } else {
  1422. //1.调用点击播放接口
  1423. //2.发送心跳
  1424.  
  1425. await HNTOOL.Sleep(500);
  1426.  
  1427. HNAPI.playOneVideo(BV);
  1428. }
  1429.  
  1430.  
  1431. });
  1432.  
  1433.  
  1434. });
  1435.  
  1436. }
  1437.  
  1438.  
  1439. let addSetPage = async function() {
  1440.  
  1441. HNTOOL.Sleep(1000);
  1442.  
  1443. $('body').append('' +
  1444. '<div id="left_navbar">' +
  1445. '<div class="javaex-menu-container"> ' +
  1446. ' <div id="menu" class="javaex-menu"> ' +
  1447. ' <ul> ' +
  1448. ' <li class="javaex-menu-item alone hover" > ' +
  1449. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1450. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1451. ' </li> ' +
  1452. ' </ul> ' +
  1453. ' <ul> ' +
  1454. ' <li class="javaex-menu-item"> ' +
  1455. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1456. ' <ul> ' +
  1457. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1458. ' </ul> ' +
  1459. ' </li> ' +
  1460. ' <li id="chackList" class="javaex-menu-item"> ' +
  1461. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1462. ' <ul> ' +
  1463. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1464. //' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1465. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1466. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1467. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1468. ' </ul> ' +
  1469. ' </li> ' +
  1470. ' <li class="javaex-menu-item"> ' +
  1471. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1472. ' <ul> ' +
  1473. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1474. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1475. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1476. ' <li id="batchFollowOfbastard" class="javaex-hover-pulse"><a href="javaScript:;" >批量取关-慎用</a></li> ' +
  1477. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1478. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1479. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1480. ' </ul> ' +
  1481. ' </li> ' +
  1482. ' <li class="javaex-menu-item"> ' +
  1483. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1484. ' <ul> ' +
  1485. ' <li id="everyDayTask" class="javaex-hover-pulse"><a href="javaScript:;" >一键日常任务</a></li> ' +
  1486. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1487. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1488. //' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1489. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1490. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1491. //' <li id="dynamicActivity" class="javaex-hover-pulse"><a href="javaScript:;" >动态抽奖</a></li> ' +
  1492. //' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1493. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1494. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1495. ' </ul> ' +
  1496. ' </li> ' +
  1497. ' <li class="javaex-menu-item"> ' +
  1498. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1499. ' <ul> ' +
  1500. ' <li class="javaex-hover-pulse"><a href="https://greatest.deepsurf.us/zh-CN/scripts/422731" >更新</a></li> ' +
  1501. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1502. ' </ul> ' +
  1503. ' </li> ' +
  1504.  
  1505. ' </ul> ' +
  1506. ' </div> ' +
  1507. '</div>' +
  1508. '</div>');
  1509. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1510.  
  1511. javaex.menu({
  1512. id: "menu",
  1513. isShowAll: false
  1514. });
  1515.  
  1516. }
  1517.  
  1518.  
  1519.  
  1520.  
  1521. let showUnreadMsg = function() {
  1522.  
  1523. var html = '';
  1524. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1525. html += ' <ul>';
  1526. html += ` <p style="color: #FFF;">用户消息</p>`;
  1527. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1528. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1529. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1530. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1531. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1532. html += ' <hr class="javaex-divider"></hr>';
  1533. html += ' </ul>';
  1534. html += '</div>';
  1535.  
  1536.  
  1537. javaex.panel(document.getElementById("getUnread"), {
  1538. position: "right",
  1539. content: html
  1540. });
  1541.  
  1542. javaex.tip({
  1543. content: "查询用户通知成功!",
  1544. type: "success"
  1545. });
  1546.  
  1547. }
  1548.  
  1549. /**
  1550. * 检查 艾特信息
  1551. * @returns {Promise<void>}
  1552. */
  1553. let chackAtMsg = async function(items) {
  1554.  
  1555. await HNTOOL.Sleep(500);
  1556.  
  1557. if (items != false && typeof(items) != "undefined") {
  1558.  
  1559.  
  1560. var html = '';
  1561. html += '<div class="javaex-panel-box" style="width: auto;">';
  1562. html += ' <ul>';
  1563. html += ` <p style="color: #FFF;">@信息</p>`;
  1564. items.forEach(function(item) {
  1565.  
  1566. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1567. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1568. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1569.  
  1570. html +=
  1571. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1572. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1573. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1574. html += ' <hr class="javaex-divider"></hr>';
  1575. });
  1576. html += ' </ul>';
  1577. html += '</div>';
  1578.  
  1579.  
  1580. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1581. javaex.panel(document.getElementById("getAtMsg"), {
  1582. position: "right",
  1583. content: html
  1584. });
  1585. } else {
  1586. javaex.panel(document.getElementById("chackList"), {
  1587. position: "right",
  1588. content: html
  1589. });
  1590. }
  1591.  
  1592.  
  1593. }
  1594.  
  1595. }
  1596.  
  1597.  
  1598. let addStyle = function() {
  1599. const animate = GM_getResourceText('animate');
  1600. const common = GM_getResourceText('common');
  1601. const defaultCss = GM_getResourceText('defaultCss');
  1602. //const icomoonex = GM_getResourceText('icomoonex');
  1603. //const AllCss = animate + common + defaultCss + icomoonex;
  1604. const AllCss = animate + common + defaultCss;
  1605. const style = document.createElement('style');
  1606. style.innerHTML = AllCss;
  1607. return document.getElementsByTagName('head')[0].appendChild(style);
  1608. }
  1609.  
  1610. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1611.  
  1612.  
  1613. /*-----------------------------------------------常用API--------------------------------------------------*/
  1614.  
  1615. let HNAPI = {
  1616.  
  1617. getAllFollow: async function() {
  1618. return new Promise((resolve) => {
  1619. Ajax.get({
  1620.  
  1621. url: BILIBLI_PATH.vcapi + '/feed/v1/feed/get_attention_list',
  1622. queryStringsObj: {
  1623. "uid": Live_info.uid
  1624. },
  1625. hasCookies: true,
  1626. success: responseText => {
  1627. let res = HNTOOL.strToJson(responseText);
  1628. if (res.code === 0) {
  1629.  
  1630. resolve(res.data.list);
  1631.  
  1632. } else {
  1633. console.log("查询失败!" + res.message);
  1634. resolve(false);
  1635. }
  1636. }
  1637. })
  1638. });
  1639. },
  1640.  
  1641. getCardByUID: async function(UID) {
  1642. return new Promise((resolve) => {
  1643. Ajax.get({
  1644.  
  1645. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1646. queryStringsObj: {
  1647. "mid": UID
  1648. },
  1649. hasCookies: true,
  1650. success: responseText => {
  1651. let res = HNTOOL.strToJson(responseText);
  1652. if (res.code === 0) {
  1653.  
  1654. resolve(res.data.card);
  1655.  
  1656. } else {
  1657. console.log("查询失败!" + res.message);
  1658. resolve(false);
  1659. }
  1660. }
  1661. })
  1662. });
  1663. },
  1664.  
  1665.  
  1666. /**
  1667. *
  1668. *
  1669. */
  1670.  
  1671. getTodayDynamicList: async function() {
  1672. return new Promise((resolve) => {
  1673. Ajax.get({
  1674.  
  1675. url: BILIBLI_PATH.api + '/x/space/article',
  1676. queryStringsObj: {
  1677. "mid": 226257459,
  1678. "pn": 1,
  1679. "ps": 12,
  1680. "sort": 'publish_time'
  1681. },
  1682. hasCookies: true,
  1683. success: responseText => {
  1684. let res = HNTOOL.strToJson(responseText);
  1685. if (res.code === 0) {
  1686. let artlist = [];
  1687. for (let art of res.data.articles) {
  1688.  
  1689. if (art.title.indexOf("抽奖合集") > -1) {
  1690.  
  1691. resolve(art);
  1692. break;
  1693. }
  1694. }
  1695. } else {
  1696.  
  1697.  
  1698. console.log("查询失败!" + res.message);
  1699. resolve(false);
  1700. }
  1701. }
  1702. })
  1703. });
  1704. },
  1705.  
  1706. getDataByLiveSid: async function(ids) {
  1707. return new Promise((resolve) => {
  1708. Ajax.get({
  1709.  
  1710. url: BILIBLI_PATH.api + '/x/activity/up/reserve/relation/info',
  1711. queryStringsObj: {
  1712. "ids": ids
  1713. },
  1714. hasCookies: true,
  1715. success: responseText => {
  1716. let res = HNTOOL.strToJson(responseText);
  1717. if (res.code === 0 && Object.keys(res.data.list).length != 0) {
  1718.  
  1719. resolve(res.data.list);
  1720. } else {
  1721.  
  1722. /* javaex.tip({
  1723. content: "查询失败!" + res.message,
  1724. type: "error"
  1725. }); */
  1726. console.log("查询失败!" + res.message);
  1727.  
  1728. resolve(false);
  1729. }
  1730. }
  1731. })
  1732. });
  1733. },
  1734.  
  1735. /**
  1736. * 每日登录 https://api.bilibili.com/x/report/click/now : "jsonp"
  1737. */
  1738. clickNow: async function() {
  1739. return new Promise((resolve) => {
  1740. Ajax.get({
  1741.  
  1742. url: BILIBLI_PATH.api + '/x/report/click/now',
  1743. queryStringsObj: {
  1744. jsonp: "jsonp"
  1745. },
  1746. hasCookies: true,
  1747. success: responseText => {
  1748. let res = HNTOOL.strToJson(responseText);
  1749. if (res.code === 0) {
  1750.  
  1751. javaex.tip({
  1752. content: "每日登录" + res.data.text,
  1753. type: "success"
  1754. });
  1755. resolve(true);
  1756.  
  1757. } else {
  1758.  
  1759. javaex.tip({
  1760. content: res.message,
  1761. type: "error"
  1762. });
  1763.  
  1764. resolve(false);
  1765. }
  1766. }
  1767. })
  1768. });
  1769. },
  1770.  
  1771. /**
  1772. * 每日分享视频(客户端) psot https://api.bilibili.com/x/web-interface/share/add aid csrf
  1773. * @param {number} videoAid
  1774. */
  1775. addShare: async function(videoAid) {
  1776. return new Promise((resolve) => {
  1777. Ajax.post({
  1778. url: BILIBLI_PATH.api + '/x/web-interface/share/add',
  1779. hasCookies: true,
  1780. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1781. data: {
  1782. aid: videoAid,
  1783. csrf: Live_info.csrf_token
  1784. },
  1785. success: responseText => {
  1786. let res = HNTOOL.strToJson(responseText);
  1787. if (res.code === 0) {
  1788.  
  1789. javaex.tip({
  1790. content: "每日分享视频成功",
  1791. type: "success"
  1792. });
  1793.  
  1794. resolve(true);
  1795. } else {
  1796.  
  1797. javaex.tip({
  1798. content: res.message,
  1799. type: "error"
  1800. });
  1801.  
  1802. resolve(false);
  1803. }
  1804. }
  1805. })
  1806. });
  1807. },
  1808.  
  1809.  
  1810.  
  1811. /**
  1812. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  1813. * @param {number} videoAid
  1814. */
  1815. addArticleCoin: async function(cvID, mid) {
  1816. return new Promise((resolve) => {
  1817. Ajax.post({
  1818. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  1819. hasCookies: true,
  1820. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1821. data: {
  1822. aid: cvID,
  1823. upid: mid,
  1824. multiply: 2,
  1825. avtype: 2,
  1826. csrf: Live_info.csrf_token
  1827. },
  1828. success: responseText => {
  1829. let res = HNTOOL.strToJson(responseText);
  1830. if (res.code === 0) {
  1831.  
  1832. javaex.tip({
  1833. content: '专栏:' + cvID + "投币成功",
  1834. type: "success"
  1835. });
  1836.  
  1837. resolve(true);
  1838. } else {
  1839.  
  1840. javaex.tip({
  1841. content: res.message,
  1842. type: "error"
  1843. });
  1844.  
  1845. console.log('专栏投币失败:' + cvID + res.message);
  1846.  
  1847. resolve(false);
  1848. }
  1849. }
  1850. })
  1851. });
  1852. },
  1853.  
  1854. /**
  1855. * 每日视频投币 post https://api.bilibili.com/x/web-interface/coin/add
  1856. * @param {number} videoAid
  1857. */
  1858. addVideoCoin: async function(videoAid) {
  1859. return new Promise((resolve) => {
  1860. Ajax.post({
  1861. url: BILIBLI_PATH.api + '/x/web-interface/coin/add',
  1862. hasCookies: true,
  1863. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1864. data: {
  1865. aid: videoAid,
  1866. multiply: 2,
  1867. select_like: 0,
  1868. cross_domain: true,
  1869. csrf: Live_info.csrf_token
  1870. },
  1871. success: responseText => {
  1872. let res = HNTOOL.strToJson(responseText);
  1873. if (res.code === 0) {
  1874.  
  1875. javaex.tip({
  1876. content: "投币成功",
  1877. type: "success"
  1878. });
  1879.  
  1880. resolve(true);
  1881. } else {
  1882.  
  1883. javaex.tip({
  1884. content: res.message,
  1885. type: "error"
  1886. });
  1887.  
  1888. resolve(false);
  1889. }
  1890. }
  1891. })
  1892. });
  1893. },
  1894.  
  1895.  
  1896. //1.直播签到 https://api.live.bilibili.com/xlive/web-ucenter/v1/sign/DoSign
  1897.  
  1898. DoSign: async function() {
  1899. return new Promise((resolve) => {
  1900. Ajax.get({
  1901.  
  1902. url: BILIBLI_PATH.live + '/xlive/web-ucenter/v1/sign/DoSign',
  1903. queryStringsObj: {
  1904.  
  1905. },
  1906. hasCookies: true,
  1907. success: responseText => {
  1908. let res = HNTOOL.strToJson(responseText);
  1909. if (res.code === 0) {
  1910.  
  1911. javaex.tip({
  1912. content: "签到成功:" + res.data.text,
  1913. type: "success"
  1914. });
  1915. resolve(true);
  1916.  
  1917. } else if (res.code === 1011040) {
  1918.  
  1919. javaex.tip({
  1920. content: res.message,
  1921. type: "success"
  1922. });
  1923.  
  1924. resolve(true);
  1925. } else {
  1926.  
  1927. javaex.tip({
  1928. content: res.message,
  1929. type: "error"
  1930. });
  1931.  
  1932. resolve(false);
  1933. }
  1934. }
  1935. })
  1936. });
  1937. },
  1938.  
  1939.  
  1940. /**
  1941. * // 获取分区最新专栏列表 https://api.bilibili.com/x/article/recommends?cid=0&pn=1
  1942. */
  1943. getArticleRecommends: async function() {
  1944. return new Promise((resolve) => {
  1945. Ajax.get({
  1946.  
  1947. url: BILIBLI_PATH.api + '/x/article/recommends',
  1948. queryStringsObj: {
  1949. "cid": 0,
  1950. "pn": 1
  1951. },
  1952. hasCookies: true,
  1953. success: responseText => {
  1954. let res = HNTOOL.strToJson(responseText);
  1955. if (res.code === 0) {
  1956.  
  1957. javaex.tip({
  1958. content: "获取最新专栏成功!",
  1959. type: "success"
  1960. });
  1961. resolve(res.data);
  1962.  
  1963. } else {
  1964.  
  1965. javaex.tip({
  1966. content: "获取最新专栏失败!" + res.message,
  1967. type: "error"
  1968. });
  1969.  
  1970. console.log(res.message);
  1971.  
  1972. resolve(false);
  1973. }
  1974. }
  1975. })
  1976. });
  1977. },
  1978. /**
  1979. * // 获取分区最新视频列表
  1980. */
  1981. getDynamicRegion: async function() {
  1982. return new Promise((resolve) => {
  1983. Ajax.get({
  1984.  
  1985. url: BILIBLI_PATH.api + '/x/web-interface/dynamic/region',
  1986. queryStringsObj: {
  1987. "pn": 1,
  1988. "ps": 20,
  1989. "rid": 21
  1990. },
  1991. hasCookies: true,
  1992. success: responseText => {
  1993. let res = HNTOOL.strToJson(responseText);
  1994. if (res.code === 0) {
  1995.  
  1996. javaex.tip({
  1997. content: "获取分区最新视频成功",
  1998. type: "success"
  1999. });
  2000. resolve(res.data.archives);
  2001.  
  2002. } else {
  2003.  
  2004. javaex.tip({
  2005. content: "获取分区最新视频失败" + res.message,
  2006. type: "error"
  2007. });
  2008.  
  2009. resolve(false);
  2010. }
  2011. }
  2012. })
  2013. });
  2014. },
  2015.  
  2016. /*
  2017. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  2018. * @param {Object} sid
  2019. */
  2020. reserveActivity: async function(sid) {
  2021. return new Promise((resolve) => {
  2022. Ajax.post({
  2023. url: BILIBLI_PATH.api + '/x/space/reserve',
  2024. hasCookies: true,
  2025. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2026. data: {
  2027. sid: sid, //当前用户
  2028. jsonp: "jsonp",
  2029. csrf: Live_info.csrf_token
  2030. },
  2031. success: responseText => {
  2032. let res = HNTOOL.strToJson(responseText);
  2033. if (res.code === 0) {
  2034.  
  2035. resolve(true);
  2036. } else {
  2037. javaex.tip({
  2038. content: res.message,
  2039. type: "error"
  2040. });
  2041. resolve(false);
  2042. }
  2043. }
  2044. })
  2045. });
  2046. },
  2047. /**
  2048. reserveActivity: async function(sid, reserve_total) {
  2049. return new Promise((resolve) => {
  2050. Ajax.post({
  2051. url: BILIBLI_PATH.vcapi + '/dynamic_mix/v1/dynamic_mix/reserve_attach_card_button',
  2052. hasCookies: true,
  2053. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2054. data: {
  2055. reserve_id: sid,
  2056. cur_btn_status: 1,
  2057. reserve_total: reserve_total,
  2058. csrf: Live_info.csrf_token
  2059. },
  2060. success: responseText => {
  2061. let res = HNTOOL.strToJson(responseText);
  2062. if (res.code === 0) {
  2063.  
  2064. resolve(res.data);
  2065. } else {
  2066.  
  2067. javaex.tip({
  2068. content: res.message,
  2069. type: "error"
  2070. });
  2071.  
  2072. resolve(false);
  2073. }
  2074. }
  2075. })
  2076. });
  2077. }, */
  2078.  
  2079. getGiftList: async function(room) {
  2080. return new Promise((resolve) => {
  2081. Ajax.get({
  2082.  
  2083. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  2084. queryStringsObj: {
  2085. "room_id": room
  2086. },
  2087. hasCookies: true,
  2088. success: responseText => {
  2089. let res = HNTOOL.strToJson(responseText);
  2090. if (res.code === 0) {
  2091.  
  2092. resolve(res.data.list);
  2093. } else {
  2094.  
  2095. javaex.tip({
  2096. content: "查询包裹失败!" + res.message,
  2097. type: "error"
  2098. });
  2099.  
  2100. resolve(false)
  2101. }
  2102. }
  2103. })
  2104. });
  2105. },
  2106.  
  2107. /**
  2108. * 送银B克拉
  2109. * @param {Object} ruid
  2110. * @param {Object} roomid
  2111. */
  2112. bagSendGift: async function(ruid, roomid, bag_id) {
  2113. return new Promise((resolve) => {
  2114. Ajax.post({
  2115. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  2116. hasCookies: true,
  2117. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2118. data: {
  2119. uid: Live_info.uid, //当前用户
  2120. gift_id: 3,
  2121. ruid: ruid,
  2122. send_ruid: 0,
  2123. gift_num: 1,
  2124. bag_id: bag_id,
  2125. //rnd: Math.round(new Date() / 1000); //时间戳,
  2126. platform: 'pc',
  2127. biz_code: 'Live',
  2128. biz_id: roomid,
  2129. storm_beat_id: 0,
  2130. price: 0,
  2131. csrf_token: Live_info.csrf_token,
  2132. csrf: Live_info.csrf_token
  2133.  
  2134. },
  2135. success: responseText => {
  2136. let res = HNTOOL.strToJson(responseText);
  2137. if (res.code === 0) {
  2138.  
  2139. javaex.tip({
  2140. content: roomid + "赠送b克拉成功!" + res.message,
  2141. type: "success"
  2142. });
  2143.  
  2144. resolve(true);
  2145. } else {
  2146.  
  2147. javaex.tip({
  2148. content: res.message,
  2149. type: "error"
  2150. });
  2151.  
  2152. resolve(false);
  2153. }
  2154. }
  2155. })
  2156. });
  2157. },
  2158.  
  2159.  
  2160. /**
  2161. * 判断是否有勋章
  2162. * @param {Object} uid
  2163. * @param {Object} room
  2164. */
  2165.  
  2166. getFansMedalInfo: async function(uid, room) {
  2167. return new Promise((resolve) => {
  2168. Ajax.get({
  2169.  
  2170. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  2171. queryStringsObj: {
  2172. "target_id": uid,
  2173. "room_id": room
  2174. },
  2175. //dataType:'application/json, text/plain, */*',
  2176. hasCookies: true,
  2177. success: responseText => {
  2178. let res = HNTOOL.strToJson(responseText);
  2179. if (res.code === 0) {
  2180.  
  2181. if (res.data.my_fans_medal.level == 0) {
  2182. resolve(false)
  2183. } else {
  2184. resolve(true)
  2185. }
  2186.  
  2187. } else {
  2188.  
  2189. javaex.tip({
  2190. content: "查询勋章失败!" + res.message,
  2191. type: "error"
  2192. });
  2193.  
  2194. resolve(false)
  2195. }
  2196. }
  2197. })
  2198. });
  2199. },
  2200.  
  2201.  
  2202.  
  2203.  
  2204. getDisuidList: async function(re_version, pn) {
  2205. return new Promise((resolve) => {
  2206. Ajax.get({
  2207.  
  2208. url: BILIBLI_PATH.api + '/x/relation/blacks',
  2209. queryStringsObj: {
  2210. "re_version": re_version,
  2211. "pn": pn
  2212. },
  2213. hasCookies: true,
  2214. success: responseText => {
  2215. let res = HNTOOL.strToJson(responseText);
  2216. if (res.code === 0) {
  2217. resolve(res.data.list)
  2218. } else {
  2219.  
  2220. javaex.tip({
  2221. content: "查询黑名单失败!" + res.message,
  2222. type: "error"
  2223. });
  2224.  
  2225. resolve(null)
  2226. }
  2227. }
  2228. })
  2229. });
  2230. },
  2231.  
  2232. /**
  2233. * @param {Object} uid
  2234. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  2235. */
  2236. cancelAtt: async function(uid, act, re_src) {
  2237. return new Promise((resolve) => {
  2238. Ajax.post({
  2239. url: BILIBLI_PATH.api + '/x/relation/modify',
  2240. hasCookies: true,
  2241. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2242. data: {
  2243. fid: uid,
  2244. act: act,
  2245. re_src: re_src == undefined ? 11 : 116,
  2246. jsonp: "jsonp",
  2247. csrf: Live_info.csrf_token,
  2248. },
  2249. success: responseText => {
  2250. let res = HNTOOL.strToJson(responseText);
  2251. if (res.code === 0) {
  2252.  
  2253. //HNAPI.cancelAtt(uid, 6);
  2254.  
  2255. javaex.tip({
  2256. content: "取关成功!" + res.message,
  2257. type: "success"
  2258. });
  2259.  
  2260. resolve(true);
  2261. } else if (res.code === 22003) {
  2262.  
  2263. HNAPI.cancelAtt(uid, 6);
  2264.  
  2265. javaex.tip({
  2266. content: "取消拉黑" + res.message,
  2267. type: "success"
  2268. });
  2269. resolve(true);
  2270. } else {
  2271.  
  2272. javaex.tip({
  2273. content: res.message,
  2274. type: "error"
  2275. });
  2276.  
  2277. resolve(false);
  2278. }
  2279. }
  2280. })
  2281. });
  2282. },
  2283.  
  2284. getRoomMsg: async function(roomid) {
  2285. return new Promise((resolve) => {
  2286. Ajax.get({
  2287.  
  2288. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  2289. queryStringsObj: {
  2290. "roomid": roomid
  2291. },
  2292. hasCookies: true,
  2293. success: responseText => {
  2294. let res = HNTOOL.strToJson(responseText);
  2295. if (res.code === 0) {
  2296. resolve(res.data.info.uid)
  2297. } else {
  2298. resolve(false)
  2299. }
  2300. }
  2301. })
  2302. });
  2303. },
  2304.  
  2305. /**
  2306. *
  2307. * @param sid
  2308. * @returns {Promise<unknown>}
  2309. */
  2310. lotteryDo: async function(sid) {
  2311. return new Promise((resolve) => {
  2312. Ajax.post({
  2313. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  2314. hasCookies: true,
  2315. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2316. data: {
  2317.  
  2318. sid: sid,
  2319. type: 1,
  2320. csrf: Live_info.csrf_token,
  2321. },
  2322. success: responseText => {
  2323. let res = HNTOOL.strToJson(responseText);
  2324. if (res.code === 0) {
  2325. resolve((res.data)[0].gift_name);
  2326.  
  2327. } else if (res.code === 75400) {
  2328.  
  2329. resolve(true);
  2330. } else {
  2331. javaex.tip({
  2332. content: "本次抽奖失败!" + res.message,
  2333. type: "error"
  2334. });
  2335. resolve(false);
  2336. }
  2337. }
  2338. })
  2339. });
  2340. },
  2341.  
  2342.  
  2343. getLotteryMytimes: async function(sid) {
  2344. return new Promise((resolve) => {
  2345. Ajax.get({
  2346. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  2347. queryStringsObj: {
  2348. sid: sid
  2349. },
  2350. hasCookies: true,
  2351. success: responseText => {
  2352. let res = HNTOOL.strToJson(responseText);
  2353. if (res.code === 0) {
  2354. resolve(res.data.times)
  2355. } else {
  2356. resolve(0)
  2357. }
  2358. }
  2359. })
  2360. });
  2361. },
  2362.  
  2363. /**
  2364. * 增加抽奖次数一般是分享
  2365. * @param sid 活动sid
  2366. * @returns {Promise<unknown>} 0 成功 1:活动结束
  2367. */
  2368. addLotteryTimes: async function(sid) {
  2369. return new Promise((resolve) => {
  2370. Ajax.post({
  2371. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  2372. hasCookies: true,
  2373. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2374. data: {
  2375.  
  2376. sid: sid,
  2377. action_type: 3,
  2378. csrf: Live_info.csrf_token,
  2379. },
  2380. success: responseText => {
  2381. let res = HNTOOL.strToJson(responseText);
  2382. if (res.code === 0) {
  2383.  
  2384. resolve(0)
  2385. } else if (res.code === 75003) {
  2386.  
  2387. resolve(1)
  2388.  
  2389. } else {
  2390.  
  2391. resolve(res.message);
  2392. }
  2393. }
  2394. })
  2395. });
  2396. },
  2397. /**
  2398. * 查询用户关注 默认一次查询50
  2399. * @param vmid 用户uid
  2400. * @param pn 页码
  2401. * @returns {Promise<unknown>}
  2402. */
  2403. getMyFollow: async function(vmid, pn) {
  2404. return new Promise((resolve) => {
  2405. Ajax.get({
  2406. url: BILIBLI_PATH.api + '/x/relation/followings',
  2407. queryStringsObj: {
  2408. vmid: vmid,
  2409. pn: pn
  2410. },
  2411. hasCookies: true,
  2412. success: responseText => {
  2413. let res = HNTOOL.strToJson(responseText);
  2414. if (res.code === 0) {
  2415. resolve(res.data)
  2416. } else {
  2417. resolve(null)
  2418. }
  2419. }
  2420. })
  2421. });
  2422. },
  2423.  
  2424.  
  2425. getMyinfo: function() {
  2426. return new Promise((resolve) => {
  2427. Ajax.get({
  2428. url: BILIBLI_PATH.api + '/x/space/myinfo',
  2429. queryStringsObj: {},
  2430. hasCookies: true,
  2431. success: responseText => {
  2432. let res = HNTOOL.strToJson(responseText);
  2433. if (res.code === 0) {
  2434. resolve(res.data)
  2435. } else {
  2436. resolve(null)
  2437. }
  2438. }
  2439. })
  2440. });
  2441. },
  2442.  
  2443. getMyJson: function(url) {
  2444. return new Promise((resolve) => {
  2445. GM_xmlhttpRequest({
  2446. method: "GET",
  2447. url: url,
  2448. onload: function(response) {
  2449. const res = HNTOOL.strToJson((response || {}).responseText)
  2450. resolve(res);
  2451. }
  2452. });
  2453. })
  2454. },
  2455.  
  2456.  
  2457. userInfo: function(mid) {
  2458.  
  2459. Ajax.get({
  2460. url: BILIBLI_PATH.api + '/x/space/acc/info',
  2461. queryStringsObj: {
  2462. mid: mid
  2463. },
  2464. hasCookies: true,
  2465. success: responseText => {
  2466.  
  2467. var json = JSON.parse(responseText);
  2468.  
  2469. if (json.code != 0) {
  2470.  
  2471.  
  2472. }
  2473. }
  2474. });
  2475.  
  2476. },
  2477.  
  2478. sendQmsg: async function(key, msg) {
  2479.  
  2480. $.ajax({
  2481. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  2482.  
  2483. success: function(result) {
  2484.  
  2485. }
  2486. });
  2487.  
  2488.  
  2489. /*GM_xmlhttpRequest({
  2490. method: "GET",
  2491. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  2492. onload: function (response) {
  2493.  
  2494. let json = JSON.parse(response.response);
  2495. if (json.code == 0) {
  2496.  
  2497. javaex.tip({
  2498. content: "自动动态中奖提醒成功!" + json.reason,
  2499. type: "success"
  2500. });
  2501. } else {
  2502. console.log("自动动态中奖提醒失败!" + json.reason);
  2503. javaex.tip({
  2504. content: "自动动态中奖提醒失败!" + json.reason,
  2505. type: "error"
  2506. });
  2507. }
  2508.  
  2509. }
  2510. });*/
  2511.  
  2512. },
  2513.  
  2514. /**
  2515. * 批量关注和拉黑 batchModify
  2516. *
  2517. * https://api.bilibili.com/x/relation/batch/modify
  2518. * @param uid
  2519. */
  2520.  
  2521. batchModify: function(uids, act) {
  2522.  
  2523.  
  2524. Ajax.post({
  2525. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  2526. hasCookies: true,
  2527. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2528. data: {
  2529.  
  2530. "fids": uids,
  2531. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  2532. "re_src": 151,
  2533. csrf: Live_info.csrf_token,
  2534. },
  2535. success: responseText => {
  2536.  
  2537. let json = JSON.parse(responseText);
  2538.  
  2539. if (/^{"code":0/.test(responseText)) {
  2540.  
  2541. javaex.tip({
  2542. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  2543. type: "success"
  2544. });
  2545.  
  2546. } else {
  2547. javaex.tip({
  2548. content: "关注失败!" + json.message,
  2549. type: "error"
  2550. });
  2551. }
  2552. }
  2553. })
  2554. },
  2555.  
  2556.  
  2557. /**
  2558. * //https://api.bilibili.com/x/relation/modify
  2559. *
  2560. * @param UID
  2561. */
  2562. disUserByUid: function(vmid) {
  2563.  
  2564. Ajax.post({
  2565. url: BILIBLI_PATH.api + '/x/relation/modify',
  2566. data: {
  2567. fid: parseInt(vmid),
  2568. re_src: 11,
  2569. act: 5,
  2570. jsonp: "jsonp",
  2571. csrf: Live_info.csrf_token,
  2572. },
  2573. hasCookies: true,
  2574. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2575. success: responseText => {
  2576.  
  2577. var json = JSON.parse(responseText);
  2578.  
  2579. if (json.code != 0) {
  2580.  
  2581. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2582. javaex.tip({
  2583. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2584. type: "error"
  2585. });
  2586.  
  2587. } else {
  2588. console.log("拉黑用户成功 uid:" + vmid);
  2589. javaex.tip({
  2590. content: "拉黑用户成功 uid:" + vmid,
  2591. type: "success"
  2592. });
  2593. }
  2594. }
  2595. });
  2596.  
  2597. },
  2598. /**
  2599. * http://api.bilibili.com/x/web-interface/view
  2600. * @param BV
  2601. * 心跳间隔15秒
  2602. */
  2603. playOneVideo: function(BV, MID) {
  2604.  
  2605. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2606. Ajax.post({
  2607. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2608. hasCookies: true,
  2609. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2610. data: {
  2611.  
  2612. "bvid": BV,
  2613. "part": 1,
  2614. "mid": Live_info.uid,
  2615. "lv": 2,
  2616. "jsonp": "jsonp",
  2617. "type": 3,
  2618. "sub_type": 0
  2619. },
  2620. success: responseText => {
  2621.  
  2622. let json = JSON.parse(responseText);
  2623.  
  2624. if (/^{"code":0/.test(responseText)) {
  2625. //发送一次心跳
  2626. HNAPI.sendHeartbeat(BV, MID);
  2627.  
  2628. } else {
  2629. javaex.tip({
  2630. content: "视频" + data.bvid + "播放失败!" + json.message,
  2631. type: "error"
  2632. });
  2633. }
  2634. }
  2635. })
  2636.  
  2637.  
  2638. },
  2639.  
  2640. //上报视频播放心跳(web端)
  2641. /**
  2642. * http://api.bilibili.com/x/click-interface/web/heartbeat
  2643. * @param json
  2644. */
  2645. sendHeartbeat: function(bvid, MID) {
  2646.  
  2647. Ajax.post({
  2648. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  2649. hasCookies: true,
  2650. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2651. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  2652. data: {
  2653. "bvid": bvid,
  2654. "type": 3,
  2655. "dt": 2,
  2656. "played_time": HNTOOL.random(12, 40),
  2657. "realtime": HNTOOL.random(12, 40),
  2658. "play_type": 0
  2659. },
  2660. success: responseText => {
  2661.  
  2662. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  2663.  
  2664. javaex.tip({
  2665. content: "视频BV" + bvid + "播放一次!",
  2666. type: "success"
  2667. });
  2668. }
  2669. }
  2670. })
  2671.  
  2672. },
  2673.  
  2674. //获取up所有投稿视频
  2675. /**
  2676. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  2677. * @param mid
  2678. */
  2679. getUpAllBV: function(mid, pn, ps) {
  2680. ps = (ps === undefined ? 30 : ps); // a默认值为1
  2681. Ajax.get({
  2682. url: BILIBLI_PATH.api + '/x/space/arc/search',
  2683. queryStringsObj: {
  2684. mid: mid,
  2685. tid: 0,
  2686. order: 'pubdate',
  2687. jsonp: 'jsonp',
  2688. pn: pn,
  2689. ps: ps
  2690. },
  2691. hasCookies: true,
  2692. success: responseText => {
  2693.  
  2694. var json = JSON.parse(responseText);
  2695.  
  2696. if (json.code != 0) {
  2697.  
  2698. javaex.tip({
  2699. content: "获取up所有投稿视频失败!" + json.message,
  2700. type: "success"
  2701. });
  2702.  
  2703. } else {
  2704. BiliData.BVList = json.data.list.vlist;
  2705.  
  2706. }
  2707. }
  2708. });
  2709.  
  2710. },
  2711.  
  2712.  
  2713. /**
  2714. *
  2715. * @param path
  2716. * @param data
  2717. * @param saveObj
  2718. * @param Func
  2719. */
  2720. publicGet: function(path, queryStringsObj) {
  2721.  
  2722. if (typeof(queryStringsObj) != "undefined") {
  2723. queryStringsObj = {};
  2724. }
  2725. Ajax.get({
  2726. url: BILIBLI_PATH.api + path,
  2727. queryStringsObj: queryStringsObj,
  2728. hasCookies: true,
  2729. success: responseText => {
  2730.  
  2731. let json = JSON.parse(responseText);
  2732. if (chackCode(json.code) && json.code == 0) {
  2733.  
  2734. return json.data;
  2735. }
  2736.  
  2737. return false;
  2738.  
  2739. }
  2740. })
  2741.  
  2742. },
  2743.  
  2744. /**
  2745. * 导航栏用户信息
  2746. */
  2747. getUserNav: async function() {
  2748.  
  2749. GM_xmlhttpRequest({
  2750. method: "GET",
  2751. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  2752. //timeout:3000,
  2753. onload: function(response) {
  2754.  
  2755. let json = JSON.parse(response.response);
  2756. console.log(json);
  2757. BiliData.login_code = json.code;
  2758. BiliData.login_message = json.message;
  2759. BiliData.LoginData = json.data;
  2760.  
  2761. }
  2762. });
  2763.  
  2764. },
  2765.  
  2766. /**
  2767. * 获取某up详细信息
  2768. * http://api.bilibili.com/x/web-interface/card
  2769. */
  2770. getUpCard: function(mid) {
  2771.  
  2772. Ajax.get({
  2773. url: BILIBLI_PATH.api + '/x/web-interface/card',
  2774. queryStringsObj: {
  2775. mid: mid,
  2776. photo: false
  2777. },
  2778. hasCookies: true,
  2779. success: responseText => {
  2780.  
  2781. var json = JSON.parse(responseText);
  2782.  
  2783. if (json.code != 0) {
  2784.  
  2785. javaex.tip({
  2786. content: "查询失败!" + json.message,
  2787. type: "success"
  2788. });
  2789. return false;
  2790. } else {
  2791. BiliData.upCard = json;
  2792.  
  2793. }
  2794.  
  2795.  
  2796. }
  2797. })
  2798.  
  2799. },
  2800.  
  2801. /**
  2802. *
  2803. * @param uid 用户uid
  2804. * @param ps 每页视频个数 默认30个
  2805. * @param pn 第几页
  2806. */
  2807. getUpAllVideo: function(uid, ps, pn) {
  2808.  
  2809. },
  2810. getChallenge: async function() {
  2811.  
  2812.  
  2813. },
  2814. /**
  2815. * 硬币记录
  2816. * @returns {Promise<void>}
  2817. */
  2818. getCoinLog: async function() {
  2819.  
  2820. GM_xmlhttpRequest({
  2821. method: "GET",
  2822. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  2823. //url: "http://api.bilibili.com/x/member/web/coin/log",
  2824. onload: function(response) {
  2825.  
  2826. let json = JSON.parse(response.response);
  2827. if (json.code == 0) {
  2828.  
  2829. console.log("硬币记录" + json);
  2830. BiliData.CoinLog = json.data;
  2831.  
  2832. return true;
  2833. }
  2834.  
  2835. }
  2836. });
  2837. },
  2838. /**
  2839. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  2840. * @returns {Promise<void>}
  2841. */
  2842. getUnread: async function() {
  2843.  
  2844. Ajax.get({
  2845. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  2846. hasCookies: true,
  2847. success: responseText => {
  2848.  
  2849. let json = JSON.parse(responseText);
  2850. if (chackCode(json.code) && json.code == 0) {
  2851.  
  2852. BiliData.Unread = json.data;
  2853. showUnreadMsg();
  2854. }
  2855.  
  2856. return false;
  2857.  
  2858. }
  2859. })
  2860.  
  2861. /* GM_xmlhttpRequest({
  2862. method: "GET",
  2863. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  2864. onload: function (response) {
  2865.  
  2866. let json = JSON.parse(response.response);
  2867.  
  2868. if (chackCode(json.code) && json.code == 0) {
  2869.  
  2870. BiliData.Unread = json.code;
  2871. showUnreadMsg();
  2872.  
  2873. }
  2874.  
  2875. }
  2876. });*/
  2877. },
  2878. /**
  2879. *
  2880. * @param type reply:回复我的 at @我的
  2881. */
  2882. getMsgfeed: function(type) {
  2883. Ajax.get({
  2884. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  2885. queryStringsObj: {
  2886. build: 0,
  2887. mobi_app: 'web'
  2888. },
  2889. hasCookies: true,
  2890. success: responseText => {
  2891.  
  2892. var json = JSON.parse(responseText);
  2893.  
  2894. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  2895. return false;
  2896. } else {
  2897. chackAtMsg(json.data.items);
  2898.  
  2899. return true;
  2900. }
  2901.  
  2902.  
  2903. }
  2904. })
  2905.  
  2906. },
  2907.  
  2908. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  2909. * @returns {Promise<void>}
  2910. */
  2911. getUnrewad: async function() {
  2912.  
  2913. GM_xmlhttpRequest({
  2914. method: "GET",
  2915. data: {
  2916. "mid": 99439379,
  2917. "pn": 1,
  2918. "ps": 5,
  2919. },
  2920. url: BILIBLI_PATH.api + "/x/space/arc/search",
  2921. onload: function(response) {
  2922.  
  2923. let json = JSON.parse(response.response);
  2924. if (json.code == 0) {
  2925.  
  2926. BiliData.Video = json.data;
  2927. console.log("未读消息数" + json);
  2928. }
  2929.  
  2930. }
  2931. });
  2932. },
  2933.  
  2934. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  2935. * @param {number} oid
  2936. * @param {nbumber} rpid
  2937. * @param {number} action
  2938. * @returns {Promise<void>}
  2939. * type: 11
  2940. * ordering: heat
  2941. * jsonp: jsonp
  2942. * csrf: 54a******* CSRF Token(位于cookie)
  2943. */
  2944.  
  2945. likeInDynamicComments: async function(oid, rpid, action) {
  2946.  
  2947.  
  2948. Ajax.post({
  2949. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  2950. hasCookies: true,
  2951. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2952. data: {
  2953. "oid": oid,
  2954. "type": 11,
  2955. "rpid": rpid,
  2956. "action": action,
  2957. "ordering": "heat",
  2958. "jsonp": "jsonp",
  2959. "csrf": Live_info.csrf_token,
  2960. },
  2961. success: responseText => {
  2962.  
  2963. if (/^{"code":0/.test(responseText)) {
  2964.  
  2965. BiliData.replyAction = JSON.parse(responseText);
  2966. console.log("点赞成功!" + responseText);
  2967. }
  2968. }
  2969. })
  2970.  
  2971. }
  2972.  
  2973.  
  2974. }
  2975.  
  2976. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  2977. var http_request = null;
  2978.  
  2979. function send_request(url, method) {}
  2980.  
  2981. let HNTOOL = {
  2982.  
  2983.  
  2984. getDynamicIdList: async function() {
  2985.  
  2986.  
  2987. let latestDynamic = await HNAPI.getTodayDynamicList();
  2988.  
  2989. $.ajax({
  2990. url: "https://www.bilibili.com/read/cv" + latestDynamic.id,
  2991. dataType: "html",
  2992. success: function(data) {
  2993. let datalist = HNTOOL.httpString(data);
  2994. let returnlist = [];
  2995. let dls;
  2996. for (let dl of datalist) {
  2997. let len = dl.indexOf("?");
  2998. if (len > -1) {
  2999. dls = dl.substring(len - 18, len);
  3000. }
  3001.  
  3002. if (dl.indexOf("tab") == -1 || returnlist.indexOf(dls) > -1 || dls == null) {
  3003. continue;
  3004. }
  3005. //https://t.bilibili.com/552091391342505523?tab=22
  3006. returnlist.push(dls);
  3007.  
  3008. }
  3009.  
  3010. return returnlist;
  3011. }
  3012. });
  3013.  
  3014. },
  3015.  
  3016.  
  3017.  
  3018. httpString: function(s) {
  3019. //var reg = /(http:\/\/|https:\/\/)((\w|=|\?|\.|\/|&|-)+)/g;
  3020. //var reg = /^(https?:\/\/)?([\da-z\.-]+)\.([a-z\.]{2,6})([\/\w \.-]*)*\/?$/;
  3021. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3022. //var reg=/(http(s)?\:\/\/)?(www\.)?(\w+\:\d+)?(\/\w+)+\.(swf|gif|jpg|bmp|jpeg)/gi;
  3023. var reg = /(https?|http|ftp|file):\/\/[-A-Za-z0-9+&@#/%?=~_|!:,.;]+[-A-Za-z0-9+&@#/%=~_|]/g;
  3024. //var reg= /^((ht|f)tps?):\/\/[\w\-]+(\.[\w\-]+)+([\w\-\.,@?^=%&:\/~\+#]*[\w\-\@?^=%&\/~\+#])?$/;
  3025. //v = v.replace(reg, "<a href='$1$2'>$1$2</a>"); //这里的reg就是上面的正则表达式
  3026. //s = s.replace(reg, "$1$2"); //这里的reg就是上面的正则表达式
  3027. s = s.match(reg);
  3028. console.log(s)
  3029. return (s)
  3030. },
  3031.  
  3032. saveConfig: function() {
  3033.  
  3034. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  3035. javaex.tip({
  3036. content: "配置保存成功!",
  3037. type: "success"
  3038. });
  3039.  
  3040. },
  3041.  
  3042. copyText: function(domId) {
  3043. let btn = document.getElementById(domId);
  3044. btn.select();
  3045. if (document.execCommand('copy')) {
  3046. document.execCommand('copy');
  3047. javaex.tip({
  3048. content: "复制成功!",
  3049. type: "success"
  3050. });
  3051. }
  3052.  
  3053. },
  3054. /**
  3055. * s数组去重并排序
  3056. */
  3057.  
  3058. arrUnique: function(ary) {
  3059.  
  3060. let obj = {};
  3061. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  3062. let item = ary[i]
  3063. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  3064. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  3065. // 如果没有 将这个元素添加到对象中
  3066. ary.sort((a, b) => {
  3067. return a - b
  3068. }) // 数组去重后 按升序排列
  3069. obj = null;
  3070.  
  3071. javaex.tip({
  3072. content: "已去重!",
  3073. type: "success"
  3074. });
  3075. return ary;
  3076.  
  3077. },
  3078.  
  3079. split_array: function(arr, len) {
  3080.  
  3081. let arr_length = arr.length;
  3082. let newArr = [];
  3083. for (let i = 0; i < arr_length; i += len) {
  3084. newArr.push(arr.slice(i, i + len));
  3085. }
  3086. return newArr;
  3087. },
  3088. strToJson: function(params) {
  3089. const isJSON = (str => {
  3090. if (typeof str === 'string') {
  3091. try {
  3092. const obj = JSON.parse(str);
  3093. return typeof obj === 'object' ? obj : false
  3094. } catch (_) {
  3095. console.log(str);
  3096. return false;
  3097. }
  3098. } else {
  3099. console.log(`${str}\nIt is not a string!`);
  3100. return false;
  3101. }
  3102. })(params);
  3103. return isJSON ? isJSON : {}
  3104. },
  3105.  
  3106. chackAtMsg: function() {
  3107.  
  3108. let config = HNTOOL.getConfig();
  3109. if (config.qmsg_checked == true && config.qmsg_key) {
  3110.  
  3111. document.getElementById("getAtMsg").click();
  3112.  
  3113. }
  3114.  
  3115. },
  3116.  
  3117. cssChecked: function(id, dom) {
  3118.  
  3119. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  3120.  
  3121.  
  3122. },
  3123. getConfig: function() {
  3124.  
  3125. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  3126.  
  3127. if (CONFIG == null) {
  3128. CONFIG = HN_SETUP_CONFIG;
  3129. }
  3130.  
  3131. return CONFIG;
  3132. },
  3133.  
  3134. /**
  3135. * 获取cookie 中某个键对应的值
  3136. * @param name
  3137. */
  3138.  
  3139. getCookie: function(name) {
  3140. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  3141. if (arr != null) return escape(arr[2]);
  3142. return false;
  3143. },
  3144. /**
  3145. * 得到一个字符串数组的中随机一个
  3146. * @param {List} list
  3147. */
  3148. getRandomWordOfList: function(list) {
  3149. var L = list.length;
  3150. var i = Math.ceil(Math.random() * L);
  3151.  
  3152. return list[i];
  3153. },
  3154. random: function(min, max) {
  3155.  
  3156. return Math.floor(Math.random() * (max - min)) + min;
  3157. },
  3158.  
  3159. Sleep: function(ms) {
  3160. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  3161. }
  3162.  
  3163. }
  3164.  
  3165. let errorMsg = {
  3166. "-1": "应用程序不存在或已被封禁!",
  3167. "-2": "Access Key错误!",
  3168. "-3": "API校验密匙错误!",
  3169. "-4": "调用方对该Method没有权限!",
  3170. "-101": "账号未登录!",
  3171. "-102": "账号被封停!",
  3172. "-103": "积分不足!",
  3173. "-104": "硬币不足!",
  3174. "-105": "验证码错误!",
  3175. "-106": "账号非正式会员或在适应期!",
  3176. "-107": "应用不存在或者被封禁!",
  3177. "-108": "未绑定手机!",
  3178. "-109": "未知!",
  3179. "-110": "未绑定手机!",
  3180. "-111": "csrf 校验失败!",
  3181. "-112": "系统升级中!",
  3182. "-113": "账号尚未实名认证!",
  3183. "-114": "请先绑定手机!",
  3184. "-115": "请先完成实名认证!",
  3185. "-304": "木有改动!",
  3186. "-307": "撞车跳转!",
  3187. "-400": "请求错误!",
  3188. "-401": "未认证!",
  3189. "-403": "访问权限不足!",
  3190. "-404": "啥都木有!",
  3191. }
  3192.  
  3193. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  3194. /**
  3195. *
  3196. * @param code
  3197. * @constructor
  3198. */
  3199. let chackCode = function(code) {
  3200.  
  3201. let emsg = errorMsg[code + ""];
  3202. if (emsg != null) {
  3203. javaex.tip({
  3204. content: emsg,
  3205. type: "error"
  3206. });
  3207.  
  3208. return false;
  3209. }
  3210.  
  3211. return true;
  3212. }
  3213.  
  3214.  
  3215. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  3216. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  3217.  
  3218. /*window.onbeforeunload = function() {
  3219. if (!canLeavePage()) {
  3220. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  3221. }
  3222. };*/
  3223.  
  3224.  
  3225. /**
  3226. * Ajax请求对象
  3227. */
  3228. const Ajax = (() => {
  3229. /**
  3230. * 检查options是否符合要求
  3231. * @param {object} options
  3232. * @returns {boolean}
  3233. */
  3234. function checkOptions(options) {
  3235. let result = false;
  3236. if (typeof options !== 'object') {
  3237. console.warn('类型错误: typeof Options !== Object');
  3238. return result;
  3239. } else {
  3240. if (typeof options.url !== 'string') {
  3241. console.warn('类型错误: typeof Link !== Strings');
  3242. return result;
  3243. } else {
  3244. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  3245. if (!reg.test(options.url)) {
  3246. console.warn('url字符串须为完整http链接');
  3247. return result;
  3248. }
  3249. result = true;
  3250. }
  3251. }
  3252. return result;
  3253. }
  3254.  
  3255. /**
  3256. * 对象转URL编码
  3257. * @param {object} data
  3258. */
  3259. function objToURLCode(data) {
  3260. var _result = [];
  3261. for (var key in data) {
  3262. var value = data[key];
  3263. if (value instanceof Array) {
  3264. value.forEach(function(_value) {
  3265. _result.push(key + "=" + _value);
  3266. });
  3267. } else {
  3268. _result.push(key + '=' + value);
  3269. }
  3270. }
  3271. return _result.join('&');
  3272. }
  3273.  
  3274. /**
  3275. * 请求
  3276. * @param {string} method
  3277. * @param {object} options
  3278. */
  3279. function request(method, options) {
  3280. if (checkOptions(options)) {
  3281. let xhr = new XMLHttpRequest();
  3282. const {
  3283. url: _url,
  3284. queryStringsObj,
  3285. data,
  3286. dataType,
  3287. hasCookies
  3288. } = options, url = typeof queryStringsObj === 'object' ?
  3289. _url + '?' + objToURLCode(queryStringsObj) : _url;
  3290. switch (method) {
  3291. case 'GET':
  3292. xhr.open("GET", url);
  3293. break;
  3294. case 'POST':
  3295. xhr.open("POST", url);
  3296. xhr.setRequestHeader('Content-Type', dataType);
  3297. break;
  3298. default:
  3299. break;
  3300. }
  3301. if (hasCookies) xhr.withCredentials = true;
  3302. xhr.timeout = 3000;
  3303. xhr.addEventListener('load', () => {
  3304. if (xhr.status === 200) {
  3305. options.success(xhr.responseText)
  3306. } else {
  3307. console.error(`status:${xhr.status}`);
  3308. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  3309. }
  3310. })
  3311. xhr.addEventListener('error', () => {
  3312. console.error('ajax请求出错')
  3313. options.success('{"code":-1,"msg":"ajax请求出错"}');
  3314. })
  3315. xhr.addEventListener('timeout', () => {
  3316. console.error('请求超时')
  3317. options.success('{"code":-1,"msg":"请求超时"}');
  3318. })
  3319. switch (method) {
  3320. case 'GET':
  3321. xhr.send()
  3322. break;
  3323. case 'POST':
  3324. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  3325. break;
  3326. default:
  3327. break;
  3328. }
  3329. }
  3330. }
  3331.  
  3332. return {
  3333. /**
  3334. * 发送Get请求
  3335. * @param {Object} options
  3336. */
  3337. get(options) {
  3338. request("GET", options);
  3339. },
  3340. /**
  3341. * 发送Post请求
  3342. * @param {object} options
  3343. */
  3344. post(options) {
  3345. request("POST", options);
  3346. }
  3347. }
  3348. })()