-哔哩猫-(试用版)

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

当前为 2021-05-26 提交的版本,查看 最新版本

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