-哔哩猫-(试用版)

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

目前为 2021-07-18 提交的版本。查看 最新版本

此脚本不应直接安装,它是一个供其他脚本使用的外部库。如果您需要使用该库,请在脚本元属性加入:// @require https://update.cn-greasyfork.org/scripts/422731/951854/-%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.8.1
  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.  
  1060. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/reserveSid.json";
  1061. let myjson = await HNAPI.getMyJson(url);
  1062. for (const sid in myjson) {
  1063. let siddata = myjson[sid];
  1064. console.log("时间:"+ javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') + "---upUID:" +siddata.upmid + "---奖品:" +siddata.prizeInfo.text );
  1065. await HNAPI.reserveActivity(sid);
  1066. await HNTOOL.Sleep(3000);
  1067. javaex.tip({
  1068. content: "时间:"+ javaex.dateFormat(siddata.livePlanStartTime, 'yyyy-MM-dd HH:mm:ss') + "--upUID:" +siddata.upmid + "--奖品:" +siddata.prizeInfo.text ,
  1069. type: "success"
  1070. });
  1071. }
  1072. alert("预约抽奖结束");
  1073. });
  1074.  
  1075. $("#plateActivity").bind("click", async function() {
  1076.  
  1077. //获取轮盘数据
  1078.  
  1079. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/activities.json";
  1080. let myjson = await HNAPI.getMyJson(url);
  1081. let lmt = 0;
  1082. let k = 20; //重试次数 防止卡主
  1083. let giftArr = [];
  1084. let endAtion = [];
  1085.  
  1086. javaex.tip({
  1087. content: "开始参加轮盘!!!",
  1088. type: "success"
  1089. });
  1090.  
  1091. await HNAPI.getUserNav();
  1092. await HNTOOL.Sleep(1500);
  1093.  
  1094.  
  1095. for (const json of myjson) {
  1096. //let x = json.name;
  1097. for (let i = 0; i < 20; i++) {
  1098. //结果为true 表示增加次数完成 终止增加 0 成功 1:活动结束 2 发生错误
  1099. let resout = await HNAPI.addLotteryTimes(json.sid);
  1100.  
  1101. await HNTOOL.Sleep(200);
  1102. if (resout == 1) {
  1103.  
  1104. endAtion.push(json.name + ":活动已结束!");
  1105. javaex.tip({
  1106. content: json.name + "活动已结束!",
  1107. type: "success"
  1108. });
  1109.  
  1110. break;
  1111. }
  1112. if (resout != 0 && resout != 1) {
  1113.  
  1114. javaex.tip({
  1115. content: json.name + resout,
  1116. type: "error"
  1117. });
  1118.  
  1119. break;
  1120. }
  1121.  
  1122. if (resout == 0) {
  1123.  
  1124. lmt = await HNAPI.getLotteryMytimes(json.sid);
  1125. continue;
  1126. }
  1127.  
  1128. }
  1129.  
  1130. javaex.tip({
  1131. content: "可参加" + lmt + "次(" + json.name + ")抽奖!!!",
  1132. type: "success"
  1133. });
  1134.  
  1135. await HNTOOL.Sleep(1500);
  1136.  
  1137. for (let i = 0; i < lmt; i++) {
  1138.  
  1139. let gift = await HNAPI.lotteryDo(json.sid);
  1140.  
  1141.  
  1142. if (gift == true) {
  1143.  
  1144. javaex.tip({
  1145. content: "点击过快,9秒后自动重试!!!",
  1146. type: "error"
  1147. });
  1148.  
  1149. i--;
  1150. k--;
  1151. }
  1152.  
  1153. if (gift == false || k == 0) {
  1154. break;
  1155. }
  1156.  
  1157. if (gift != "未中奖0" && gift != true) {
  1158. giftArr.push(json.name + "奖品为:" + gift);
  1159. break;
  1160. } else {
  1161. javaex.tip({
  1162. content: "未中奖---8秒后执行下一次(" + json.name + ")抽奖!!!",
  1163. type: "success"
  1164. });
  1165. }
  1166. await HNTOOL.Sleep(9000);
  1167.  
  1168. }
  1169.  
  1170.  
  1171. }
  1172.  
  1173.  
  1174. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1175. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1176.  
  1177. alert(`【哔哩猫转盘推送】:` + BiliData.LoginData.uname + `中奖详情:` + (giftArr.length ==
  1178. 0 ? "未中奖" : giftArr.toString()) + endAtion.toString());
  1179.  
  1180.  
  1181. });
  1182.  
  1183. $("#addPlay").bind("click", async function() {
  1184.  
  1185.  
  1186. let html = '';
  1187.  
  1188. html += '<div style="padding: 10px 10px 10px 0px;">'
  1189. html += '<form id="getUpMassage_form">'
  1190.  
  1191. html += ' <div class="javaex-unit clear">'
  1192. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  1193. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  1194. html +=
  1195. ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  1196. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  1197. html += ' </div>'
  1198. html += ' </div>'
  1199. html += ' <div class="javaex-unit clear">'
  1200. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  1201. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  1202. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  1203. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  1204. html += ' </div>'
  1205. html += ' </div>'
  1206. html += '</form>';
  1207. html += ' <div class="javaex-unit clear tc">'
  1208. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  1209. html += ' </div>'
  1210. html += '<hr class="javaex-divider"></hr>';
  1211. html += '</div>';
  1212.  
  1213.  
  1214. javaex.panel(this, {
  1215. position: "right",
  1216. content: html
  1217. });
  1218.  
  1219. $("#addPlay_bgn").click(async function() {
  1220.  
  1221. let MID = javaex.getSelectVal("#addPlay_uid")
  1222. let BV = javaex.getSelectVal("#addPlay_bv");
  1223. let bvArr = [];
  1224. let bvArr2 = [];
  1225.  
  1226. MID = javaex.ifnull(MID, BiliData.author_uid);
  1227.  
  1228.  
  1229. if (BV == "0") {
  1230.  
  1231. //1.查询up所有视频BV号 2.发送心跳间隔2s
  1232. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  1233. await HNTOOL.Sleep(500);
  1234. bvArr2 = BiliData.BVList;
  1235.  
  1236. for (let i = 1; i > 0; i++) {
  1237.  
  1238. HNAPI.getUpAllBV(MID, i);
  1239.  
  1240. await HNTOOL.Sleep(500);
  1241.  
  1242. if (BiliData.BVList.length == 0) {
  1243. if (bvArr.length == 0) {
  1244. javaex.tip({
  1245. content: "该用户无投稿视频,请确认是否有误!",
  1246. type: "success"
  1247. });
  1248. await HNTOOL.Sleep(2000);
  1249. }
  1250. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  1251. bvArr = bvArr.concat(bvArr2);
  1252. break;
  1253. }
  1254.  
  1255. bvArr = bvArr.concat(BiliData.BVList);
  1256. }
  1257.  
  1258.  
  1259. if (bvArr.length != 0) {
  1260.  
  1261. for (const emt of bvArr) {
  1262.  
  1263. HNAPI.playOneVideo(emt.bvid, MID);
  1264.  
  1265. await HNTOOL.Sleep(2000);
  1266.  
  1267. }
  1268.  
  1269. alert("播放完成!!!");
  1270.  
  1271. }
  1272.  
  1273.  
  1274. } else {
  1275. //1.调用点击播放接口
  1276. //2.发送心跳
  1277.  
  1278. await HNTOOL.Sleep(500);
  1279.  
  1280. HNAPI.playOneVideo(BV);
  1281. }
  1282.  
  1283.  
  1284. });
  1285.  
  1286.  
  1287. });
  1288.  
  1289. }
  1290.  
  1291.  
  1292. let addSetPage = async function() {
  1293.  
  1294. HNTOOL.Sleep(1000);
  1295.  
  1296. $('body').append('' +
  1297. '<div id="left_navbar">' +
  1298. '<div class="javaex-menu-container"> ' +
  1299. ' <div id="menu" class="javaex-menu"> ' +
  1300. ' <ul> ' +
  1301. ' <li class="javaex-menu-item alone hover" > ' +
  1302. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  1303. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  1304. ' </li> ' +
  1305. ' </ul> ' +
  1306. ' <ul> ' +
  1307. ' <li class="javaex-menu-item"> ' +
  1308. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  1309. ' <ul> ' +
  1310. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  1311. ' </ul> ' +
  1312. ' </li> ' +
  1313. ' <li id="chackList" class="javaex-menu-item"> ' +
  1314. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  1315. ' <ul> ' +
  1316. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  1317. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  1318. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  1319. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  1320. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  1321. ' </ul> ' +
  1322. ' </li> ' +
  1323. ' <li class="javaex-menu-item"> ' +
  1324. ' <a href="javascript:;">批量操作工具<i class="icon-angle-down"></i></a> ' +
  1325. ' <ul> ' +
  1326. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  1327. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑&取关</a></li> ' +
  1328. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  1329. ' <li id="batchTargetMedal" class="javaex-hover-pulse"><a href="javaScript:;" >批量勋章</a></li> ' +
  1330. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  1331. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  1332. ' </ul> ' +
  1333. ' </li> ' +
  1334. ' <li class="javaex-menu-item"> ' +
  1335. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  1336. ' <ul> ' +
  1337. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  1338. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  1339. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  1340. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  1341. ' <li id="reserveActivity" class="javaex-hover-pulse"><a href="javaScript:;" >预约抽奖</a></li> ' +
  1342. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' + //likeInDynamicComments
  1343. ' <li id="getNeetCookie" class="javaex-hover-pulse"><a href="javaScript:;">获取Cookie</a></li> ' +
  1344. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  1345. ' </ul> ' +
  1346. ' </li> ' +
  1347. ' <li class="javaex-menu-item"> ' +
  1348. ' <a href="javascript:;">设置及更新<i class="icon-angle-down"></i></a> ' +
  1349. ' <ul> ' +
  1350. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  1351. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  1352. ' </ul> ' +
  1353. ' </li> ' +
  1354.  
  1355. ' </ul> ' +
  1356. ' </div> ' +
  1357. '</div>' +
  1358. '</div>');
  1359. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1360.  
  1361. javaex.menu({
  1362. id: "menu",
  1363. isShowAll: false
  1364. });
  1365.  
  1366. }
  1367.  
  1368.  
  1369.  
  1370.  
  1371. let showUnreadMsg = function() {
  1372.  
  1373. var html = '';
  1374. html += '<div class="javaex-panel-box" style="width: 250px;">';
  1375. html += ' <ul>';
  1376. html += ` <p style="color: #FFF;">用户消息</p>`;
  1377. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  1378. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  1379. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  1380. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  1381. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  1382. html += ' <hr class="javaex-divider"></hr>';
  1383. html += ' </ul>';
  1384. html += '</div>';
  1385.  
  1386.  
  1387. javaex.panel(document.getElementById("getUnread"), {
  1388. position: "right",
  1389. content: html
  1390. });
  1391.  
  1392. javaex.tip({
  1393. content: "查询用户通知成功!",
  1394. type: "success"
  1395. });
  1396.  
  1397. }
  1398.  
  1399. /**
  1400. * 检查 艾特信息
  1401. * @returns {Promise<void>}
  1402. */
  1403. let chackAtMsg = async function(items) {
  1404.  
  1405. await HNTOOL.Sleep(500);
  1406.  
  1407. if (items != false && typeof(items) != "undefined") {
  1408.  
  1409.  
  1410. var html = '';
  1411. html += '<div class="javaex-panel-box" style="width: auto;">';
  1412. html += ' <ul>';
  1413. html += ` <p style="color: #FFF;">@信息</p>`;
  1414. items.forEach(function(item) {
  1415.  
  1416. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  1417. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" +
  1418. `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  1419.  
  1420. html +=
  1421. ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  1422. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  1423. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  1424. html += ' <hr class="javaex-divider"></hr>';
  1425. });
  1426. html += ' </ul>';
  1427. html += '</div>';
  1428.  
  1429.  
  1430. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  1431. javaex.panel(document.getElementById("getAtMsg"), {
  1432. position: "right",
  1433. content: html
  1434. });
  1435. } else {
  1436. javaex.panel(document.getElementById("chackList"), {
  1437. position: "right",
  1438. content: html
  1439. });
  1440. }
  1441.  
  1442.  
  1443. }
  1444.  
  1445. }
  1446.  
  1447.  
  1448. let addStyle = function() {
  1449. const animate = GM_getResourceText('animate');
  1450. const common = GM_getResourceText('common');
  1451. const defaultCss = GM_getResourceText('defaultCss');
  1452. //const icomoonex = GM_getResourceText('icomoonex');
  1453. //const AllCss = animate + common + defaultCss + icomoonex;
  1454. const AllCss = animate + common + defaultCss;
  1455. const style = document.createElement('style');
  1456. style.innerHTML = AllCss;
  1457. return document.getElementsByTagName('head')[0].appendChild(style);
  1458. }
  1459.  
  1460. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1461.  
  1462.  
  1463. /*-----------------------------------------------常用API--------------------------------------------------*/
  1464.  
  1465. let HNAPI = {
  1466. //https://api.live.bilibili.com?t=1622034774765&room_id=5238625
  1467. /**
  1468. * 预约抽奖 https://api.bilibili.com/x/space/reserve sid jsonp=jsonp csrf
  1469. * @param {Object} sid
  1470. */
  1471. reserveActivity: async function(sid) {
  1472. return new Promise((resolve) => {
  1473. Ajax.post({
  1474. url: BILIBLI_PATH.api + '/x/space/reserve',
  1475. hasCookies: true,
  1476. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1477. data: {
  1478. sid: sid, //当前用户
  1479. jsonp: "jsonp",
  1480. csrf: Live_info.csrf_token
  1481. },
  1482. success: responseText => {
  1483. let res = HNTOOL.strToJson(responseText);
  1484. if (res.code === 0) {
  1485.  
  1486. javaex.tip({
  1487. content: sid + "参加成功!" + res.message,
  1488. type: "success"
  1489. });
  1490.  
  1491. resolve(true);
  1492. } else {
  1493.  
  1494. javaex.tip({
  1495. content: res.message,
  1496. type: "error"
  1497. });
  1498.  
  1499. resolve(false);
  1500. }
  1501. }
  1502. })
  1503. });
  1504. },
  1505.  
  1506. getGiftList: async function(room) {
  1507. return new Promise((resolve) => {
  1508. Ajax.get({
  1509.  
  1510. url: BILIBLI_PATH.live + '/xlive/web-room/v1/gift/bag_list',
  1511. queryStringsObj: {
  1512. "room_id": room
  1513. },
  1514. hasCookies: true,
  1515. success: responseText => {
  1516. let res = HNTOOL.strToJson(responseText);
  1517. if (res.code === 0) {
  1518.  
  1519. resolve(res.data.list);
  1520. } else {
  1521.  
  1522. javaex.tip({
  1523. content: "查询包裹失败!" + res.message,
  1524. type: "error"
  1525. });
  1526.  
  1527. resolve(false)
  1528. }
  1529. }
  1530. })
  1531. });
  1532. },
  1533.  
  1534. /**
  1535. * 送银B克拉
  1536. * @param {Object} ruid
  1537. * @param {Object} roomid
  1538. */
  1539. bagSendGift: async function(ruid, roomid, bag_id) {
  1540. return new Promise((resolve) => {
  1541. Ajax.post({
  1542. url: BILIBLI_PATH.live + '/gift/v2/live/bag_send',
  1543. hasCookies: true,
  1544. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1545. data: {
  1546. uid: Live_info.uid, //当前用户
  1547. gift_id: 3,
  1548. ruid: ruid,
  1549. send_ruid: 0,
  1550. gift_num: 1,
  1551. bag_id: bag_id,
  1552. //rnd: Math.round(new Date() / 1000); //时间戳,
  1553. platform: 'pc',
  1554. biz_code: 'Live',
  1555. biz_id: roomid,
  1556. storm_beat_id: 0,
  1557. price: 0,
  1558. csrf_token: Live_info.csrf_token,
  1559. csrf: Live_info.csrf_token
  1560.  
  1561. },
  1562. success: responseText => {
  1563. let res = HNTOOL.strToJson(responseText);
  1564. if (res.code === 0) {
  1565.  
  1566. javaex.tip({
  1567. content: roomid + "赠送b克拉成功!" + res.message,
  1568. type: "success"
  1569. });
  1570.  
  1571. resolve(true);
  1572. } else {
  1573.  
  1574. javaex.tip({
  1575. content: res.message,
  1576. type: "error"
  1577. });
  1578.  
  1579. resolve(false);
  1580. }
  1581. }
  1582. })
  1583. });
  1584. },
  1585.  
  1586.  
  1587. /**
  1588. * 判断是否有勋章
  1589. * @param {Object} uid
  1590. * @param {Object} room
  1591. */
  1592.  
  1593. getFansMedalInfo: async function(uid, room) {
  1594. return new Promise((resolve) => {
  1595. Ajax.get({
  1596.  
  1597. url: BILIBLI_PATH.live + '/xlive/app-ucenter/v1/fansMedal/fans_medal_info',
  1598. queryStringsObj: {
  1599. "target_id": uid,
  1600. "room_id": room
  1601. },
  1602. //dataType:'application/json, text/plain, */*',
  1603. hasCookies: true,
  1604. success: responseText => {
  1605. let res = HNTOOL.strToJson(responseText);
  1606. if (res.code === 0) {
  1607.  
  1608. if (res.data.my_fans_medal.level == 0) {
  1609. resolve(false)
  1610. } else {
  1611. resolve(true)
  1612. }
  1613.  
  1614. } else {
  1615.  
  1616. javaex.tip({
  1617. content: "查询勋章失败!" + res.message,
  1618. type: "error"
  1619. });
  1620.  
  1621. resolve(false)
  1622. }
  1623. }
  1624. })
  1625. });
  1626. },
  1627.  
  1628.  
  1629.  
  1630.  
  1631. getDisuidList: async function(re_version, pn) {
  1632. return new Promise((resolve) => {
  1633. Ajax.get({
  1634.  
  1635. url: BILIBLI_PATH.api + '/x/relation/blacks',
  1636. queryStringsObj: {
  1637. "re_version": re_version,
  1638. "pn": pn
  1639. },
  1640. hasCookies: true,
  1641. success: responseText => {
  1642. let res = HNTOOL.strToJson(responseText);
  1643. if (res.code === 0) {
  1644. resolve(res.data.list)
  1645. } else {
  1646.  
  1647. javaex.tip({
  1648. content: "查询黑名单失败!" + res.message,
  1649. type: "error"
  1650. });
  1651.  
  1652. resolve(null)
  1653. }
  1654. }
  1655. })
  1656. });
  1657. },
  1658.  
  1659. /**
  1660. * @param {Object} uid
  1661. * @param {Object} act 1关注,2取关,3悄悄关注,4取消悄悄关注,5拉黑,6取消拉黑,7踢出粉丝;
  1662. */
  1663. cancelAtt: async function(uid, act, re_src) {
  1664. return new Promise((resolve) => {
  1665. Ajax.post({
  1666. url: BILIBLI_PATH.api + '/x/relation/modify',
  1667. hasCookies: true,
  1668. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1669. data: {
  1670. fid: uid,
  1671. act: act,
  1672. re_src: re_src == undefined ? 11 : 116,
  1673. jsonp: "jsonp",
  1674. csrf: Live_info.csrf_token,
  1675. },
  1676. success: responseText => {
  1677. let res = HNTOOL.strToJson(responseText);
  1678. if (res.code === 0) {
  1679.  
  1680. //HNAPI.cancelAtt(uid, 6);
  1681.  
  1682. javaex.tip({
  1683. content: "取关成功!" + res.message,
  1684. type: "success"
  1685. });
  1686.  
  1687. resolve(true);
  1688. } else if (res.code === 22003) {
  1689.  
  1690. HNAPI.cancelAtt(uid, 6);
  1691.  
  1692. javaex.tip({
  1693. content: "取消拉黑" + res.message,
  1694. type: "success"
  1695. });
  1696. resolve(true);
  1697. } else {
  1698.  
  1699. javaex.tip({
  1700. content: res.message,
  1701. type: "error"
  1702. });
  1703.  
  1704. resolve(false);
  1705. }
  1706. }
  1707. })
  1708. });
  1709. },
  1710.  
  1711. getRoomMsg: async function(roomid) {
  1712. return new Promise((resolve) => {
  1713. Ajax.get({
  1714.  
  1715. url: BILIBLI_PATH.live + '/live_user/v1/UserInfo/get_anchor_in_room',
  1716. queryStringsObj: {
  1717. "roomid": roomid
  1718. },
  1719. hasCookies: true,
  1720. success: responseText => {
  1721. let res = HNTOOL.strToJson(responseText);
  1722. if (res.code === 0) {
  1723. resolve(res.data.info.uid)
  1724. } else {
  1725. resolve(false)
  1726. }
  1727. }
  1728. })
  1729. });
  1730. },
  1731.  
  1732. /**
  1733. *
  1734. * @param sid
  1735. * @returns {Promise<unknown>}
  1736. */
  1737. lotteryDo: async function(sid) {
  1738. return new Promise((resolve) => {
  1739. Ajax.post({
  1740. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  1741. hasCookies: true,
  1742. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1743. data: {
  1744.  
  1745. sid: sid,
  1746. type: 1,
  1747. csrf: Live_info.csrf_token,
  1748. },
  1749. success: responseText => {
  1750. let res = HNTOOL.strToJson(responseText);
  1751. if (res.code === 0) {
  1752. resolve((res.data)[0].gift_name);
  1753.  
  1754. } else if (res.code === 75400) {
  1755.  
  1756. resolve(true);
  1757. } else {
  1758. javaex.tip({
  1759. content: "本次抽奖失败!" + res.message,
  1760. type: "error"
  1761. });
  1762. resolve(false);
  1763. }
  1764. }
  1765. })
  1766. });
  1767. },
  1768.  
  1769.  
  1770. getLotteryMytimes: async function(sid) {
  1771. return new Promise((resolve) => {
  1772. Ajax.get({
  1773. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  1774. queryStringsObj: {
  1775. sid: sid
  1776. },
  1777. hasCookies: true,
  1778. success: responseText => {
  1779. let res = HNTOOL.strToJson(responseText);
  1780. if (res.code === 0) {
  1781. resolve(res.data.times)
  1782. } else {
  1783. resolve(0)
  1784. }
  1785. }
  1786. })
  1787. });
  1788. },
  1789.  
  1790. /**
  1791. * 增加抽奖次数一般是分享
  1792. * @param sid 活动sid
  1793. * @returns {Promise<unknown>} 0 成功 1:活动结束
  1794. */
  1795. addLotteryTimes: async function(sid) {
  1796. return new Promise((resolve) => {
  1797. Ajax.post({
  1798. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  1799. hasCookies: true,
  1800. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1801. data: {
  1802.  
  1803. sid: sid,
  1804. action_type: 3,
  1805. csrf: Live_info.csrf_token,
  1806. },
  1807. success: responseText => {
  1808. let res = HNTOOL.strToJson(responseText);
  1809. if (res.code === 0) {
  1810.  
  1811. resolve(0)
  1812. } else if (res.code === 75003) {
  1813.  
  1814. resolve(1)
  1815.  
  1816. } else {
  1817.  
  1818. resolve(res.message);
  1819. }
  1820. }
  1821. })
  1822. });
  1823. },
  1824. /**
  1825. * 查询用户关注 默认一次查询50
  1826. * @param vmid 用户uid
  1827. * @param pn 页码
  1828. * @returns {Promise<unknown>}
  1829. */
  1830. getMyFollow: async function(vmid, pn) {
  1831. return new Promise((resolve) => {
  1832. Ajax.get({
  1833. url: BILIBLI_PATH.api + '/x/relation/followings',
  1834. queryStringsObj: {
  1835. vmid: vmid,
  1836. pn: pn
  1837. },
  1838. hasCookies: true,
  1839. success: responseText => {
  1840. let res = HNTOOL.strToJson(responseText);
  1841. if (res.code === 0) {
  1842. resolve(res.data)
  1843. } else {
  1844. resolve(null)
  1845. }
  1846. }
  1847. })
  1848. });
  1849. },
  1850.  
  1851.  
  1852. getMyinfo: function() {
  1853. return new Promise((resolve) => {
  1854. Ajax.get({
  1855. url: BILIBLI_PATH.api + '/x/space/myinfo',
  1856. queryStringsObj: {},
  1857. hasCookies: true,
  1858. success: responseText => {
  1859. let res = HNTOOL.strToJson(responseText);
  1860. if (res.code === 0) {
  1861. resolve(res.data)
  1862. } else {
  1863. resolve(null)
  1864. }
  1865. }
  1866. })
  1867. });
  1868. },
  1869.  
  1870. getMyJson: function(url) {
  1871. return new Promise((resolve) => {
  1872. GM_xmlhttpRequest({
  1873. method: "GET",
  1874. url: url,
  1875. onload: function(response) {
  1876. const res = HNTOOL.strToJson((response || {}).responseText)
  1877. resolve(res);
  1878. }
  1879. });
  1880. })
  1881. },
  1882.  
  1883.  
  1884. userInfo: function(mid) {
  1885.  
  1886. Ajax.get({
  1887. url: BILIBLI_PATH.api + '/x/space/acc/info',
  1888. queryStringsObj: {
  1889. mid: mid
  1890. },
  1891. hasCookies: true,
  1892. success: responseText => {
  1893.  
  1894. var json = JSON.parse(responseText);
  1895.  
  1896. if (json.code != 0) {
  1897.  
  1898.  
  1899. }
  1900. }
  1901. });
  1902.  
  1903. },
  1904.  
  1905. sendQmsg: async function(key, msg) {
  1906.  
  1907. $.ajax({
  1908. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  1909.  
  1910. success: function(result) {
  1911.  
  1912. }
  1913. });
  1914.  
  1915.  
  1916. /*GM_xmlhttpRequest({
  1917. method: "GET",
  1918. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  1919. onload: function (response) {
  1920.  
  1921. let json = JSON.parse(response.response);
  1922. if (json.code == 0) {
  1923.  
  1924. javaex.tip({
  1925. content: "自动动态中奖提醒成功!" + json.reason,
  1926. type: "success"
  1927. });
  1928. } else {
  1929. console.log("自动动态中奖提醒失败!" + json.reason);
  1930. javaex.tip({
  1931. content: "自动动态中奖提醒失败!" + json.reason,
  1932. type: "error"
  1933. });
  1934. }
  1935.  
  1936. }
  1937. });*/
  1938.  
  1939. },
  1940.  
  1941. /**
  1942. * 批量关注和拉黑 batchModify
  1943. *
  1944. * https://api.bilibili.com/x/relation/batch/modify
  1945. * @param uid
  1946. */
  1947.  
  1948. batchModify: function(uids, act) {
  1949.  
  1950.  
  1951. Ajax.post({
  1952. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1953. hasCookies: true,
  1954. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1955. data: {
  1956.  
  1957. "fids": uids,
  1958. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1959. "re_src": 151,
  1960. csrf: Live_info.csrf_token,
  1961. },
  1962. success: responseText => {
  1963.  
  1964. let json = JSON.parse(responseText);
  1965.  
  1966. if (/^{"code":0/.test(responseText)) {
  1967.  
  1968. javaex.tip({
  1969. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  1970. type: "success"
  1971. });
  1972.  
  1973. } else {
  1974. javaex.tip({
  1975. content: "关注失败!" + json.message,
  1976. type: "error"
  1977. });
  1978. }
  1979. }
  1980. })
  1981. },
  1982.  
  1983.  
  1984. /**
  1985. * //https://api.bilibili.com/x/relation/modify
  1986. *
  1987. * @param UID
  1988. */
  1989. disUserByUid: function(vmid) {
  1990.  
  1991. Ajax.post({
  1992. url: BILIBLI_PATH.api + '/x/relation/modify',
  1993. data: {
  1994. fid: parseInt(vmid),
  1995. re_src: 11,
  1996. act: 5,
  1997. jsonp: "jsonp",
  1998. csrf: Live_info.csrf_token,
  1999. },
  2000. hasCookies: true,
  2001. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2002. success: responseText => {
  2003.  
  2004. var json = JSON.parse(responseText);
  2005.  
  2006. if (json.code != 0) {
  2007.  
  2008. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  2009. javaex.tip({
  2010. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  2011. type: "error"
  2012. });
  2013.  
  2014. } else {
  2015. console.log("拉黑用户成功 uid:" + vmid);
  2016. javaex.tip({
  2017. content: "拉黑用户成功 uid:" + vmid,
  2018. type: "success"
  2019. });
  2020. }
  2021. }
  2022. });
  2023.  
  2024. },
  2025. /**
  2026. * http://api.bilibili.com/x/web-interface/view
  2027. * @param BV
  2028. * 心跳间隔15秒
  2029. */
  2030. playOneVideo: function(BV, MID) {
  2031.  
  2032. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  2033. Ajax.post({
  2034. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  2035. hasCookies: true,
  2036. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2037. data: {
  2038.  
  2039. "bvid": BV,
  2040. "part": 1,
  2041. "mid": Live_info.uid,
  2042. "lv": 2,
  2043. "jsonp": "jsonp",
  2044. "type": 3,
  2045. "sub_type": 0
  2046. },
  2047. success: responseText => {
  2048.  
  2049. let json = JSON.parse(responseText);
  2050.  
  2051. if (/^{"code":0/.test(responseText)) {
  2052. //发送一次心跳
  2053. HNAPI.sendHeartbeat(BV, MID);
  2054.  
  2055. } else {
  2056. javaex.tip({
  2057. content: "视频" + data.bvid + "播放失败!" + json.message,
  2058. type: "error"
  2059. });
  2060. }
  2061. }
  2062. })
  2063.  
  2064.  
  2065. },
  2066.  
  2067. //上报视频播放心跳(web端)
  2068. /**
  2069. * http://api.bilibili.com/x/click-interface/web/heartbeat
  2070. * @param json
  2071. */
  2072. sendHeartbeat: function(bvid, MID) {
  2073.  
  2074. Ajax.post({
  2075. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  2076. hasCookies: true,
  2077. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2078. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  2079. data: {
  2080. "bvid": bvid,
  2081. "type": 3,
  2082. "dt": 2,
  2083. "played_time": HNTOOL.random(12, 40),
  2084. "realtime": HNTOOL.random(12, 40),
  2085. "play_type": 0
  2086. },
  2087. success: responseText => {
  2088.  
  2089. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  2090.  
  2091. javaex.tip({
  2092. content: "视频BV" + bvid + "播放一次!",
  2093. type: "success"
  2094. });
  2095. }
  2096. }
  2097. })
  2098.  
  2099. },
  2100.  
  2101. //获取up所有投稿视频
  2102. /**
  2103. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  2104. * @param mid
  2105. */
  2106. getUpAllBV: function(mid, pn, ps) {
  2107. ps = (ps === undefined ? 30 : ps); // a默认值为1
  2108. Ajax.get({
  2109. url: BILIBLI_PATH.api + '/x/space/arc/search',
  2110. queryStringsObj: {
  2111. mid: mid,
  2112. tid: 0,
  2113. order: 'pubdate',
  2114. jsonp: 'jsonp',
  2115. pn: pn,
  2116. ps: ps
  2117. },
  2118. hasCookies: true,
  2119. success: responseText => {
  2120.  
  2121. var json = JSON.parse(responseText);
  2122.  
  2123. if (json.code != 0) {
  2124.  
  2125. javaex.tip({
  2126. content: "获取up所有投稿视频失败!" + json.message,
  2127. type: "success"
  2128. });
  2129.  
  2130. } else {
  2131. BiliData.BVList = json.data.list.vlist;
  2132.  
  2133. }
  2134. }
  2135. });
  2136.  
  2137. },
  2138.  
  2139.  
  2140. /**
  2141. *
  2142. * @param path
  2143. * @param data
  2144. * @param saveObj
  2145. * @param Func
  2146. */
  2147. publicGet: function(path, queryStringsObj) {
  2148.  
  2149. if (typeof(queryStringsObj) != "undefined") {
  2150. queryStringsObj = {};
  2151. }
  2152. Ajax.get({
  2153. url: BILIBLI_PATH.api + path,
  2154. queryStringsObj: queryStringsObj,
  2155. hasCookies: true,
  2156. success: responseText => {
  2157.  
  2158. let json = JSON.parse(responseText);
  2159. if (chackCode(json.code) && json.code == 0) {
  2160.  
  2161. return json.data;
  2162. }
  2163.  
  2164. return false;
  2165.  
  2166. }
  2167. })
  2168.  
  2169. },
  2170.  
  2171. /**
  2172. * 导航栏用户信息
  2173. */
  2174. getUserNav: async function() {
  2175.  
  2176. GM_xmlhttpRequest({
  2177. method: "GET",
  2178. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  2179. //timeout:3000,
  2180. onload: function(response) {
  2181.  
  2182. let json = JSON.parse(response.response);
  2183. console.log(json);
  2184. BiliData.login_code = json.code;
  2185. BiliData.login_message = json.message;
  2186. BiliData.LoginData = json.data;
  2187.  
  2188. }
  2189. });
  2190.  
  2191. },
  2192.  
  2193. /**
  2194. * 获取某up详细信息
  2195. * http://api.bilibili.com/x/web-interface/card
  2196. */
  2197. getUpCard: function(mid) {
  2198.  
  2199. Ajax.get({
  2200. url: BILIBLI_PATH.api + '/x/web-interface/card',
  2201. queryStringsObj: {
  2202. mid: mid,
  2203. photo: false
  2204. },
  2205. hasCookies: true,
  2206. success: responseText => {
  2207.  
  2208. var json = JSON.parse(responseText);
  2209.  
  2210. if (json.code != 0) {
  2211.  
  2212. javaex.tip({
  2213. content: "查询失败!" + json.message,
  2214. type: "success"
  2215. });
  2216. return false;
  2217. } else {
  2218. BiliData.upCard = json;
  2219.  
  2220. }
  2221.  
  2222.  
  2223. }
  2224. })
  2225.  
  2226. },
  2227.  
  2228. /**
  2229. *
  2230. * @param uid 用户uid
  2231. * @param ps 每页视频个数 默认30个
  2232. * @param pn 第几页
  2233. */
  2234. getUpAllVideo: function(uid, ps, pn) {
  2235.  
  2236. },
  2237. getChallenge: async function() {
  2238.  
  2239.  
  2240. },
  2241. /**
  2242. * 硬币记录
  2243. * @returns {Promise<void>}
  2244. */
  2245. getCoinLog: async function() {
  2246.  
  2247. GM_xmlhttpRequest({
  2248. method: "GET",
  2249. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  2250. //url: "http://api.bilibili.com/x/member/web/coin/log",
  2251. onload: function(response) {
  2252.  
  2253. let json = JSON.parse(response.response);
  2254. if (json.code == 0) {
  2255.  
  2256. console.log("硬币记录" + json);
  2257. BiliData.CoinLog = json.data;
  2258.  
  2259. return true;
  2260. }
  2261.  
  2262. }
  2263. });
  2264. },
  2265. /**
  2266. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  2267. * @returns {Promise<void>}
  2268. */
  2269. getUnread: async function() {
  2270.  
  2271. Ajax.get({
  2272. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  2273. hasCookies: true,
  2274. success: responseText => {
  2275.  
  2276. let json = JSON.parse(responseText);
  2277. if (chackCode(json.code) && json.code == 0) {
  2278.  
  2279. BiliData.Unread = json.data;
  2280. showUnreadMsg();
  2281. }
  2282.  
  2283. return false;
  2284.  
  2285. }
  2286. })
  2287.  
  2288. /* GM_xmlhttpRequest({
  2289. method: "GET",
  2290. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  2291. onload: function (response) {
  2292.  
  2293. let json = JSON.parse(response.response);
  2294.  
  2295. if (chackCode(json.code) && json.code == 0) {
  2296.  
  2297. BiliData.Unread = json.code;
  2298. showUnreadMsg();
  2299.  
  2300. }
  2301.  
  2302. }
  2303. });*/
  2304. },
  2305. /**
  2306. *
  2307. * @param type reply:回复我的 at @我的
  2308. */
  2309. getMsgfeed: function(type) {
  2310. Ajax.get({
  2311. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  2312. queryStringsObj: {
  2313. build: 0,
  2314. mobi_app: 'web'
  2315. },
  2316. hasCookies: true,
  2317. success: responseText => {
  2318.  
  2319. var json = JSON.parse(responseText);
  2320.  
  2321. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  2322. return false;
  2323. } else {
  2324. chackAtMsg(json.data.items);
  2325.  
  2326. return true;
  2327. }
  2328.  
  2329.  
  2330. }
  2331. })
  2332.  
  2333. },
  2334.  
  2335. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  2336. * @returns {Promise<void>}
  2337. */
  2338. getUnrewad: async function() {
  2339.  
  2340. GM_xmlhttpRequest({
  2341. method: "GET",
  2342. data: {
  2343. "mid": 99439379,
  2344. "pn": 1,
  2345. "ps": 5,
  2346. },
  2347. url: BILIBLI_PATH.api + "/x/space/arc/search",
  2348. onload: function(response) {
  2349.  
  2350. let json = JSON.parse(response.response);
  2351. if (json.code == 0) {
  2352.  
  2353. BiliData.Video = json.data;
  2354. console.log("未读消息数" + json);
  2355. }
  2356.  
  2357. }
  2358. });
  2359. },
  2360.  
  2361. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  2362. * @param {number} oid
  2363. * @param {nbumber} rpid
  2364. * @param {number} action
  2365. * @returns {Promise<void>}
  2366. * type: 11
  2367. * ordering: heat
  2368. * jsonp: jsonp
  2369. * csrf: 54a******* CSRF Token(位于cookie)
  2370. */
  2371.  
  2372. likeInDynamicComments: async function(oid, rpid, action) {
  2373.  
  2374.  
  2375. Ajax.post({
  2376. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  2377. hasCookies: true,
  2378. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  2379. data: {
  2380. "oid": oid,
  2381. "type": 11,
  2382. "rpid": rpid,
  2383. "action": action,
  2384. "ordering": "heat",
  2385. "jsonp": "jsonp",
  2386. "csrf": Live_info.csrf_token,
  2387. },
  2388. success: responseText => {
  2389.  
  2390. if (/^{"code":0/.test(responseText)) {
  2391.  
  2392. BiliData.replyAction = JSON.parse(responseText);
  2393. console.log("点赞成功!" + responseText);
  2394. }
  2395. }
  2396. })
  2397.  
  2398. }
  2399.  
  2400.  
  2401. }
  2402.  
  2403. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  2404.  
  2405.  
  2406. let HNTOOL = {
  2407.  
  2408.  
  2409. copyText: function(domId) {
  2410. let btn = document.getElementById(domId);
  2411. btn.select();
  2412. if (document.execCommand('copy')) {
  2413. document.execCommand('copy');
  2414. javaex.tip({
  2415. content: "复制成功!",
  2416. type: "success"
  2417. });
  2418. }
  2419.  
  2420. },
  2421. /**
  2422. * s数组去重并排序
  2423. */
  2424.  
  2425. arrUnique: function(ary) {
  2426.  
  2427. let obj = {};
  2428. for (let i = 0; i < ary.length; i++) { //this 指向方法.前的对象ary
  2429. let item = ary[i]
  2430. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  2431. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  2432. // 如果没有 将这个元素添加到对象中
  2433. ary.sort((a, b) => {
  2434. return a - b
  2435. }) // 数组去重后 按升序排列
  2436. obj = null;
  2437.  
  2438. javaex.tip({
  2439. content: "已去重!",
  2440. type: "success"
  2441. });
  2442. return ary;
  2443.  
  2444. },
  2445.  
  2446. split_array: function(arr, len) {
  2447.  
  2448. let arr_length = arr.length;
  2449. let newArr = [];
  2450. for (let i = 0; i < arr_length; i += len) {
  2451. newArr.push(arr.slice(i, i + len));
  2452. }
  2453. return newArr;
  2454. },
  2455. strToJson: function(params) {
  2456. const isJSON = (str => {
  2457. if (typeof str === 'string') {
  2458. try {
  2459. const obj = JSON.parse(str);
  2460. return typeof obj === 'object' ? obj : false
  2461. } catch (_) {
  2462. console.log(str);
  2463. return false;
  2464. }
  2465. } else {
  2466. console.log(`${str}\nIt is not a string!`);
  2467. return false;
  2468. }
  2469. })(params);
  2470. return isJSON ? isJSON : {}
  2471. },
  2472.  
  2473. chackAtMsg: function() {
  2474.  
  2475. let config = HNTOOL.getConfig();
  2476. if (config.qmsg_checked == true && config.qmsg_key) {
  2477.  
  2478. document.getElementById("getAtMsg").click();
  2479.  
  2480. }
  2481.  
  2482. },
  2483.  
  2484. cssChecked: function(id, dom) {
  2485.  
  2486. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  2487.  
  2488.  
  2489. },
  2490. getConfig: function() {
  2491.  
  2492. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  2493.  
  2494. if (CONFIG == null) {
  2495. CONFIG = HN_SETUP_CONFIG;
  2496. }
  2497.  
  2498. return CONFIG;
  2499. },
  2500.  
  2501. /**
  2502. * 获取cookie 中某个键对应的值
  2503. * @param name
  2504. */
  2505.  
  2506. getCookie: function(name) {
  2507. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  2508. if (arr != null) return escape(arr[2]);
  2509. return false;
  2510. },
  2511. /**
  2512. * 得到一个字符串数组的中随机一个
  2513. * @param {List} list
  2514. */
  2515. getRandomWordOfList: function(list) {
  2516. var L = list.length;
  2517. var i = Math.ceil(Math.random() * L);
  2518.  
  2519. return list[i];
  2520. },
  2521. random: function(min, max) {
  2522.  
  2523. return Math.floor(Math.random() * (max - min)) + min;
  2524. },
  2525.  
  2526. Sleep: function(ms) {
  2527. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  2528. }
  2529.  
  2530. }
  2531.  
  2532. let errorMsg = {
  2533. "-1": "应用程序不存在或已被封禁!",
  2534. "-2": "Access Key错误!",
  2535. "-3": "API校验密匙错误!",
  2536. "-4": "调用方对该Method没有权限!",
  2537. "-101": "账号未登录!",
  2538. "-102": "账号被封停!",
  2539. "-103": "积分不足!",
  2540. "-104": "硬币不足!",
  2541. "-105": "验证码错误!",
  2542. "-106": "账号非正式会员或在适应期!",
  2543. "-107": "应用不存在或者被封禁!",
  2544. "-108": "未绑定手机!",
  2545. "-109": "未知!",
  2546. "-110": "未绑定手机!",
  2547. "-111": "csrf 校验失败!",
  2548. "-112": "系统升级中!",
  2549. "-113": "账号尚未实名认证!",
  2550. "-114": "请先绑定手机!",
  2551. "-115": "请先完成实名认证!",
  2552. "-304": "木有改动!",
  2553. "-307": "撞车跳转!",
  2554. "-400": "请求错误!",
  2555. "-401": "未认证!",
  2556. "-403": "访问权限不足!",
  2557. "-404": "啥都木有!",
  2558. }
  2559.  
  2560. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  2561. /**
  2562. *
  2563. * @param code
  2564. * @constructor
  2565. */
  2566. let chackCode = function(code) {
  2567.  
  2568. let emsg = errorMsg[code + ""];
  2569. if (emsg != null) {
  2570. javaex.tip({
  2571. content: emsg,
  2572. type: "error"
  2573. });
  2574.  
  2575. return false;
  2576. }
  2577.  
  2578. return true;
  2579. }
  2580.  
  2581.  
  2582. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  2583. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  2584.  
  2585. /*window.onbeforeunload = function() {
  2586. if (!canLeavePage()) {
  2587. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  2588. }
  2589. };*/
  2590.  
  2591.  
  2592. /**
  2593. * Ajax请求对象
  2594. */
  2595. const Ajax = (() => {
  2596. /**
  2597. * 检查options是否符合要求
  2598. * @param {object} options
  2599. * @returns {boolean}
  2600. */
  2601. function checkOptions(options) {
  2602. let result = false;
  2603. if (typeof options !== 'object') {
  2604. console.warn('类型错误: typeof Options !== Object');
  2605. return result;
  2606. } else {
  2607. if (typeof options.url !== 'string') {
  2608. console.warn('类型错误: typeof Link !== Strings');
  2609. return result;
  2610. } else {
  2611. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  2612. if (!reg.test(options.url)) {
  2613. console.warn('url字符串须为完整http链接');
  2614. return result;
  2615. }
  2616. result = true;
  2617. }
  2618. }
  2619. return result;
  2620. }
  2621.  
  2622. /**
  2623. * 对象转URL编码
  2624. * @param {object} data
  2625. */
  2626. function objToURLCode(data) {
  2627. var _result = [];
  2628. for (var key in data) {
  2629. var value = data[key];
  2630. if (value instanceof Array) {
  2631. value.forEach(function(_value) {
  2632. _result.push(key + "=" + _value);
  2633. });
  2634. } else {
  2635. _result.push(key + '=' + value);
  2636. }
  2637. }
  2638. return _result.join('&');
  2639. }
  2640.  
  2641. /**
  2642. * 请求
  2643. * @param {string} method
  2644. * @param {object} options
  2645. */
  2646. function request(method, options) {
  2647. if (checkOptions(options)) {
  2648. let xhr = new XMLHttpRequest();
  2649. const {
  2650. url: _url,
  2651. queryStringsObj,
  2652. data,
  2653. dataType,
  2654. hasCookies
  2655. } = options, url = typeof queryStringsObj === 'object' ?
  2656. _url + '?' + objToURLCode(queryStringsObj) : _url;
  2657. switch (method) {
  2658. case 'GET':
  2659. xhr.open("GET", url);
  2660. break;
  2661. case 'POST':
  2662. xhr.open("POST", url);
  2663. xhr.setRequestHeader('Content-Type', dataType);
  2664. break;
  2665. default:
  2666. break;
  2667. }
  2668. if (hasCookies) xhr.withCredentials = true;
  2669. xhr.timeout = 3000;
  2670. xhr.addEventListener('load', () => {
  2671. if (xhr.status === 200) {
  2672. options.success(xhr.responseText)
  2673. } else {
  2674. console.error(`status:${xhr.status}`);
  2675. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  2676. }
  2677. })
  2678. xhr.addEventListener('error', () => {
  2679. console.error('ajax请求出错')
  2680. options.success('{"code":-1,"msg":"ajax请求出错"}');
  2681. })
  2682. xhr.addEventListener('timeout', () => {
  2683. console.error('请求超时')
  2684. options.success('{"code":-1,"msg":"请求超时"}');
  2685. })
  2686. switch (method) {
  2687. case 'GET':
  2688. xhr.send()
  2689. break;
  2690. case 'POST':
  2691. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  2692. break;
  2693. default:
  2694. break;
  2695. }
  2696. }
  2697. }
  2698.  
  2699. return {
  2700. /**
  2701. * 发送Get请求
  2702. * @param {Object} options
  2703. */
  2704. get(options) {
  2705. request("GET", options);
  2706. },
  2707. /**
  2708. * 发送Post请求
  2709. * @param {object} options
  2710. */
  2711. post(options) {
  2712. request("POST", options);
  2713. }
  2714. }
  2715. })()