-哔哩猫-(试用版)

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

当前为 2021-07-16 提交的版本,查看 最新版本

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