-哔哩猫-(试用版)

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

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

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/919362/-%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.5.75
  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. GM_addStyle(`
  35.  
  36. #switch-qsmg:before {
  37. content: "开关";
  38. letter-spacing: 16px;
  39. top: 4px;
  40. left: 10px;
  41. }
  42. #left_navbar{
  43. z-index: 1000;
  44. position: absolute;
  45. top: 100px;
  46. left: 5px;
  47. }
  48. button[hnBtn="btn_open"] {
  49. z-index: 1001;
  50. z-index: 1000px;
  51. position: absolute;
  52. top: 58px;
  53. left: 220px;
  54. }
  55. .javaex-panel.javaex-panel-right.javaex-animated-zoom-in {
  56. top: 60px;
  57. }
  58. .javaex-menu-container {
  59. border: 1px solid #eee;
  60. }
  61. .javaex-panel-box p {
  62. text-align: center;
  63. background: #fb7299;
  64. }
  65. .fontbold{
  66. color: #00a1d6;
  67. font-weight: bold;
  68. cursor: pointer;
  69. }
  70. `);
  71.  
  72.  
  73. let HN_SETUP_CONFIG = {
  74.  
  75. qmsg_key: null, //后期改为kull 存储到本地
  76. qmsg_checked: false,
  77.  
  78.  
  79. }
  80.  
  81. let Live_info = {
  82. room_id: undefined,
  83. uid: undefined,
  84. blocked: undefined,
  85. csrf_token: undefined,
  86. visit_id: undefined,
  87. rnd: undefined,
  88. ruid: undefined,
  89. uname: undefined,
  90. user_level: undefined,
  91. ruid: undefined,
  92. };
  93.  
  94. let BILIBLI_PATH = {
  95.  
  96. "passport": "https://passport.bilibili.com",
  97. "api": "https://api.bilibili.com",
  98. "video": "https://www.bilibili.com/video/",
  99. "single_unread": "http://api.vc.bilibili.com/"
  100. }
  101.  
  102. let BILIBILI_URL = {
  103. // 导航栏用户信息
  104. "nav": BILIBLI_PATH.api + "/x/web-interface/nav",
  105. }
  106.  
  107. let BiliData = {
  108.  
  109. this_uid: window.location.href.split("/")[3], //当前页面uid
  110. author_uid: 99439379,
  111. login_code: null,
  112. login_message: "",
  113. LoginData: {},
  114. CoinLog: {},
  115. Unread: null,
  116. Video: {},
  117. replyAction: {},
  118. upCard: {},
  119. BVList: [],
  120. }
  121.  
  122. window.onload = function () {
  123.  
  124.  
  125. //界面显示
  126. init();
  127.  
  128.  
  129. }
  130.  
  131.  
  132. function init() {
  133.  
  134. Live_info.csrf_token = HNTOOL.getCookie("bili_jct");
  135. Live_info.uid = HNTOOL.getCookie("DedeUserID");
  136.  
  137. addStyle();
  138. addSetPage();
  139.  
  140. HNTOOL.chackAtMsg();
  141.  
  142. $("#getCoinLog").bind("click", async function () {
  143.  
  144.  
  145. if (HNAPI.getCoinLog()) {
  146.  
  147. await HNTOOL.Sleep(500);
  148. let html = '';
  149. html += '<div class="javaex-panel-box" style="width: 250px;">';
  150. html += ' <ul>';
  151. html += ` <p style="color: #FFF;">硬币使用记录</p>`;
  152.  
  153. BiliData.CoinLog.list.forEach(function (item) {
  154.  
  155. let BV = item.reason.replace(/[^a-z0-9]+/ig, "");
  156. if (BV.indexOf("BV") != -1) {
  157. html += `<li><a href="${BILIBLI_PATH.video}${BV}">${item.reason}${item.delta}币 ${item.time}</a> </li> `;
  158. }
  159. html += `<li>${item.reason}${item.delta}币 ${item.time}</li> `;
  160.  
  161.  
  162. });
  163. html += ' <hr class="javaex-divider"></hr>';
  164. html += ' </ul>';
  165. html += '</div>';
  166.  
  167. javaex.panel(this, {
  168. position: "right",
  169. //offsetTop: "104",
  170. content: html
  171. });
  172. javaex.tip({
  173. content: "获取用户成功!",
  174. type: "success"
  175. });
  176.  
  177. } else {
  178. javaex.tip({
  179. content: "获取硬币记录失败,请稍后重试!",
  180. type: "error"
  181. });
  182. }
  183.  
  184.  
  185. });
  186.  
  187. $("#getUnread").bind("click", async function () {
  188.  
  189. javaex.tip({
  190. content: "获取中,请稍候...",
  191. type: "submit"
  192. });
  193. HNAPI.getUnread();
  194.  
  195.  
  196. });
  197.  
  198.  
  199. $("#likeInDynamicComments").bind("click", async function () {
  200.  
  201. let prid = LocalData.get("likeInDynamic_PRID") == null ? "4015599048" : LocalData.get("likeInDynamic_PRID");
  202. let oid = LocalData.get("likeInDynamic_OID") == null ? "108928314" : LocalData.get("likeInDynamic_OID");
  203.  
  204. let html = '';
  205.  
  206. html += '<div style="padding: 10px 10px 10px 0px;">'
  207. html += '<form id="likeInDynamic_form">'
  208. html += ' <div class="javaex-unit clear">'
  209. html += ' <div class="javaex-unit-left"><p class="subtitle required">评论RPID</p></div>'
  210. html += ' <div class="javaex-unit-right">'
  211. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="评论RPID格式错误"'
  212. html += ` id="likeInDynamic_PRID" value=${prid} placeholder="请输入评论RPID"/>`
  213. html += ' </div>'
  214. html += ' </div>'
  215. html += ' <div class="javaex-unit clear">'
  216. html += ' <div class="javaex-unit-left"><p class="subtitle required">OID</p></div>'
  217. html += ' <div class="javaex-unit-right">'
  218. html += ' <input type="text" class="javaex-text" data-type="positive_int" error-msg="OID格式错误"'
  219. html += ` id="likeInDynamic_OID" value=${oid} placeholder="请输入OID"/>`
  220. html += ' </div>'
  221. html += ' </div>'
  222. html += ' <div class="javaex-unit clear tc">'
  223. html += ' <input type="button" id="likeInDynamic_no" class="javaex-hover-pulse javaex-btn no " value="取消赞"/>'
  224. html += ' <input type="button" id="likeInDynamic_yes" class="javaex-hover-pulse javaex-btn yes" value="点赞"/>'
  225. html += ' </div>'
  226. html += '</form>';
  227. html += '<hr class="javaex-divider"></hr>';
  228. html += '</div>';
  229.  
  230.  
  231. javaex.panel(this, {
  232. position: "right",
  233. content: html
  234. });
  235.  
  236.  
  237. // 监听点击保存按钮事件
  238. $("#likeInDynamic_yes").click(async function () {
  239. // 表单验证函数
  240. if (javaexVerify()) {
  241.  
  242. HNAPI.likeInDynamicComments(+javaex.getSelectVal("#likeInDynamic_OID"), +javaex.getSelectVal("#likeInDynamic_PRID"), 1);
  243. await HNTOOL.Sleep(1000);
  244.  
  245. if (BiliData.replyAction.code == 0) {
  246.  
  247. LocalData.set("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  248. LocalData.set("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  249.  
  250. javaex.tip({content: "评论区点赞成功!", type: "success"});
  251. } else {
  252. javaex.tip({content: "评论区点赞失败!", type: "error"});
  253. }
  254. if (BiliData.replyAction.code == 65006) {
  255. javaex.tip({content: "请勿重复点赞!", type: "error"});
  256. }
  257. }
  258. });
  259.  
  260. // 监听点击返回按钮事件
  261. $("#likeInDynamic_no").click(async function () {
  262.  
  263. if (javaexVerify()) {
  264.  
  265. HNAPI.likeInDynamicComments(+javaex.getLocalStorage("#likeInDynamic_OID"), +javaex.getLocalStorage("#likeInDynamic_PRID"), 0);
  266. await HNTOOL.Sleep(500);
  267.  
  268. if (BiliData.replyAction.code == 0) {
  269.  
  270. javaex.setLocalStorage("likeInDynamic_PRID", javaex.getSelectVal("#likeInDynamic_PRID"));
  271. javaex.setLocalStorage("likeInDynamic_OID", javaex.getSelectVal("#likeInDynamic_OID"));
  272.  
  273. javaex.tip({content: "评论区取消点赞成功!", type: "success"});
  274. } else {
  275. javaex.tip({content: "评论区取消点赞失败!", type: "error"});
  276. }
  277. if (BiliData.replyAction.code == 65006) {
  278. javaex.tip({content: "请勿重复取消点赞!", type: "error"});
  279. }
  280. }
  281. });
  282.  
  283. });
  284.  
  285. $("#biliUserMsg").bind("click", async function () {
  286.  
  287.  
  288. //刷新信息
  289. HNAPI.getUserNav();
  290. await HNTOOL.Sleep(500);
  291.  
  292. let isLogin = "未登录";
  293. let vipType = "无";
  294. //判断是否成功
  295. if (BiliData.login_code == 0) {
  296.  
  297.  
  298. if (BiliData.LoginData.isLogin) {
  299. isLogin = "已登录";
  300. }
  301.  
  302. if (BiliData.LoginData.vipType == 1) {
  303. vipType = "月度大会员";
  304. } else if (BiliData.LoginData.vipType == 2) {
  305. vipType = "年度大会员";
  306. }
  307.  
  308. let html = '';
  309. html += '<div class="javaex-panel-box" style="width: 250px;">';
  310. html += ' <ul>';
  311. html += ` <p style="color: #FFF;">用户信息</p>`;
  312. html += ` <li><a href="https://account.bilibili.com/account/home">当前用户:${BiliData.LoginData.uname}</a> </li> `;
  313. html += ` <li>用户状态:${isLogin} </li> `;
  314. html += ` <li>用户等级:${BiliData.LoginData.level_info.current_level}</li> `;
  315. html += ` <li>升级下一等级需:${BiliData.LoginData.level_info.next_exp - BiliData.LoginData.level_info.current_exp} 经验</li> `;
  316. html += ` <li>UID${BiliData.LoginData.mid} </li> `;
  317. html += ` <li><a href="https://account.bilibili.com/account/coin">硬币:${BiliData.LoginData.money}</a> </li> `;
  318. html += ` <li>节操值:${BiliData.LoginData.moral} </li> `;
  319. html += ` <li>会员:${vipType} </li> `;
  320. html += ' <hr class="javaex-divider"></hr>';
  321. html += ' </ul>';
  322. html += '</div>';
  323.  
  324.  
  325. javaex.panel(this, {
  326. position: "right",
  327. content: html
  328. });
  329.  
  330. javaex.tip({
  331. content: "获取用户成功!",
  332. type: "success"
  333. });
  334.  
  335. } else {
  336. javaex.tip({
  337. content: "获取用户信息失败!",
  338. type: "error"
  339. });
  340. }
  341.  
  342.  
  343. });
  344.  
  345. $("#getAtMsg").bind("click", async function () {
  346.  
  347. if (HNAPI.getMsgfeed("at") && typeof (HNAPI.getMsgfeed("at")) != "undefined") {
  348.  
  349. javaex.tip({
  350. content: "可能中奖了!!!",
  351. type: "success"
  352. });
  353. }
  354. });
  355.  
  356.  
  357. $("#disUser").bind("click", async function () {
  358.  
  359. let html = '';
  360. html += '<div class="javaex-panel-box" style="width: 500px;">';
  361. html += ' <div class="javaex-unit clear">';
  362. html += ' <div class="javaex-unit-left ml-10 mt-10">*拉黑列表</div>';
  363. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  364. html += ' <textarea id="disUser_uidList" class="javaex-desc" placeholder="请填写用户UID,多个用英文逗号,隔开"></textarea>';
  365. html += ' </div>';
  366. html += ' </div>';
  367. html += ' <div class="javaex-unit clear tc">';
  368. html += ' <input type="button" id="disUser_beg" class="javaex-btn yes" value="开始" />';
  369. html += ' </div>';
  370. html += '</div>';
  371.  
  372. javaex.panel(this, {
  373. position: "right",
  374. content: html
  375. });
  376.  
  377. $("#disUser_beg").bind("click", async function () {
  378.  
  379. let disUser_str = javaex.getSelectVal("#disUser_uidList");
  380. disUser_uidList = disUser_str.split(",");
  381.  
  382. let disUserStr = HNTOOL.split_array(disUser_uidList, 10);
  383. for (const vmid of disUserStr) {
  384.  
  385. HNAPI.batchModify(vmid.toString(), 5);
  386. await HNTOOL.Sleep(6000);
  387. }
  388. });
  389.  
  390. });
  391.  
  392. $("#arrUnique").bind("click", async function () {
  393.  
  394. let html = '';
  395. html += '<div class="javaex-panel-box" style="width: 500px;">';
  396. html += ' <div class="javaex-unit clear">';
  397. html += ' <div id="arrNub" class="javaex-unit-left ml-10 mt-10">*数组0</div>';
  398. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  399. html += ' <textarea id="arrUnique_str" class="javaex-desc" placeholder="请填写,多个用英文逗号,隔开"></textarea>';
  400. html += ' </div>';
  401. html += ' </div>';
  402. html += ' <div class="javaex-unit clear tc">';
  403. html += ' <input type="button" id="arrUnique_beg" class="javaex-btn yes" value="开始" />';
  404. html += ' </div>';
  405. html += '</div>';
  406.  
  407. javaex.panel(this, {
  408. position: "right",
  409. content: html
  410. });
  411.  
  412. $('#arrUnique_str').bind('input propertychange', function () {
  413.  
  414. $('#arrNub').text("*数组" + $(this).val().split(",").length);
  415.  
  416. });
  417.  
  418. $("#arrUnique_beg").bind("click", async function () {
  419.  
  420. let arrUnique_str = javaex.getSelectVal("#arrUnique_str");
  421. let arrUnique_uidList = arrUnique_str.split(",");
  422.  
  423. let arrUniqueStr = HNTOOL.arrUnique(arrUnique_uidList).toString();
  424.  
  425. document.getElementById("arrUnique_str").value = arrUniqueStr;
  426.  
  427. });
  428.  
  429. });
  430.  
  431. $("#batchFollow").bind("click", async function () {
  432.  
  433. var thisUPName = $("#h-name").text();
  434.  
  435.  
  436. let html = '';
  437. html += '<div class="javaex-panel-box" style="width: 600px;">';
  438. html += ' <div class="javaex-unit clear">';
  439. html += ' <div id="followNub" class="javaex-unit-left ml-10 mt-10">*关注列表0</div>';
  440. html += ' <div class="javaex-unit-right mr-10 mt-10">';
  441. html += ' <textarea id="batchFollow_uidList" class="javaex-desc" placeholder="1.请填写用户UID,多个用英文逗号,隔开,此功能会强制关注,解决账号异常不能关注问题!!!2.爬取当前用户的高质量关注"></textarea>';
  442. html += ' </div>';
  443. html += ' </div>';
  444. html += ' <div class="javaex-unit clear tc" >';
  445. html += ' <input type="button" id="batchFollow_beg" class="javaex-btn yes" value="开始" />';
  446. html += ' <input type="button" id="crawler_follow" class="javaex-btn yes tc" value="爬取关注" />';
  447. html += ` <input type="button" id="Follow_thisUp" class="javaex-btn yes tc" value="关注${thisUPName}" />`;
  448. html += ` <input type="button" id="disFollow_thisUp" class="javaex-btn yes tc" value="拉黑${thisUPName}" /> `;
  449. html += ' </div>';
  450. html += '</div>';
  451.  
  452. javaex.panel(this, {
  453. position: "right",
  454. content: html
  455. });
  456.  
  457. $('#batchFollow_uidList').bind('input propertychange', function () {
  458.  
  459. $('#followNub').text("*关注列表" + $(this).val().split(",").length);
  460.  
  461. });
  462.  
  463. $("#disFollow_thisUp").bind("click", async function () {
  464.  
  465. HNAPI.batchModify(BiliData.this_uid, 5);
  466.  
  467. });
  468.  
  469. $("#Follow_thisUp").bind("click", async function () {
  470.  
  471. HNAPI.batchModify(BiliData.this_uid);
  472.  
  473. });
  474.  
  475. $("#batchFollow_beg").bind("click", async function () {
  476.  
  477. let mid_str = javaex.getSelectVal("#batchFollow_uidList");
  478. mid_list = mid_str.split(",");
  479.  
  480. let mid_Lists = HNTOOL.split_array(mid_list, 15);
  481. for (const mids of mid_Lists) {
  482.  
  483. HNAPI.batchModify(mids.toString());
  484. await HNTOOL.Sleep(8000);
  485. }
  486.  
  487.  
  488. });
  489.  
  490. $("#crawler_follow").bind("click", async function () {
  491.  
  492. //x/space/myinfo
  493. let myinfoData = await HNAPI.getMyinfo();
  494. await HNAPI.getUpCard(myinfoData.mid);
  495. await HNTOOL.Sleep(1000);
  496. let len = parseInt(BiliData.upCard.data.card.attention / 20);
  497. let followData = [];
  498.  
  499. for (let i = 0; i < len; i++) {
  500. if (BiliData.upCard.code != 0) {
  501. javaex.tip({
  502. content: `爬取关注出现异常 终止爬取!{BiliData.upCard.message}`,
  503. type: "error"
  504. });
  505. break;
  506. }
  507.  
  508. javaex.tip({
  509. content: `正在爬取` + myinfoData.mid + `的` + i + `页的关注!!!`,
  510. type: "success"
  511. });
  512.  
  513. let followList = await HNAPI.getMyFollow(myinfoData.mid, i);
  514. if (followList != null) {
  515. for (const fl of followList.list) {
  516.  
  517. if (fl.official_verify.type != 1 || fl.vip.vipType == 0) {
  518. //continue;
  519. }
  520.  
  521. followData.push(fl.mid);
  522.  
  523. }
  524. }
  525.  
  526.  
  527. await HNTOOL.Sleep(3000);
  528. }
  529.  
  530. document.getElementById("batchFollow_uidList").value = followData.toString();
  531.  
  532. });
  533.  
  534.  
  535. });
  536.  
  537.  
  538. $("#HNSetup").bind("click", async function () {
  539.  
  540. var CONFIG = HNTOOL.getConfig();
  541.  
  542.  
  543. let html = '';
  544.  
  545. html += '<div style="padding: 10px 10px 10px 0px;width:400px; ">'
  546. html += '<form id="HNGG_SETUP">'
  547. html += ' <div class="javaex-unit clear">'
  548. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">Qmsg-key</p></div>'
  549. html += ' <div class="javaex-unit-left mr-10" style="width:200px">'
  550. html += ' <input type="text" class="javaex-text" data-type="english_number" error-msg="Q酱key不正确" ;'
  551. html += ` id="HNSetup_Qmsg_key" value="${CONFIG.qmsg_key}" placeholder="请输入Q酱key"/>`
  552. html += ' </div>'
  553. html += ' <div class="javaex-unit-left mr-10">'
  554. html += ` <input type="checkbox" class="javaex-switch" id="switch-qsmg" /> `
  555. html += ' </div>'
  556. html += ' </div>'
  557. html += '</form>';
  558. html += '<div class="javaex-unit clear tc">';
  559. html += ' <input type="button" id="HNSetup_save" class="javaex-btn yes" value="保存" />';
  560. html += '</div>';
  561. html += '<hr class="javaex-divider"></hr>';
  562. html += '</div>';
  563.  
  564. javaex.panel(this, {
  565. position: "right",
  566. content: html
  567. });
  568.  
  569.  
  570. HNTOOL.cssChecked("#switch-qsmg", CONFIG.qmsg_checked, HN_SETUP_CONFIG.qmsg_checked);
  571.  
  572. $("#switch-qsmg").bind("click", function () {
  573.  
  574. HN_SETUP_CONFIG.qmsg_checked = CONFIG.qmsg_checked == true ? false : true;
  575.  
  576. })
  577.  
  578.  
  579. $("#HNSetup_save").bind("click", async function () {
  580.  
  581.  
  582. HN_SETUP_CONFIG.qmsg_key = javaex.getSelectVal("#HNSetup_Qmsg_key");
  583.  
  584. localStorage.setItem(`HN_SETUP_CONFIG`, JSON.stringify(HN_SETUP_CONFIG));
  585.  
  586. javaex.tip({
  587. content: "设置成功!",
  588. type: "success"
  589. });
  590.  
  591. });
  592.  
  593. });
  594.  
  595. //
  596. $("#getUpMassage").bind("click", async function () {
  597.  
  598.  
  599. let html = '';
  600.  
  601. html += '<div style="padding: 10px 10px 10px 0px;">'
  602. html += '<form id="getUpMassage_form">'
  603. html += ' <div class="javaex-unit clear">'
  604. html += ' <div class="javaex-unit-left mr-10"><p class="subtitle required">用户uid</p></div>'
  605. html += ' <div class="javaex-unit-left mr-10">'
  606. html += ' <input type="text" class="javaex-text javaex-grid-4" data-type="positive_int" error-msg="用户uid"'
  607. html += ` id="up_uid" value="${BiliData.this_uid}" placeholder="请输入评论uid"/>`
  608. html += ' </div>'
  609. html += ' <div class="javaex-unit-right mr-10">'
  610. html += ' <input type="button" id="getUpMsg" class="javaex-btn blue" value="查询"/>'
  611. html += ' </div>'
  612. html += ' </div>'
  613. html += ' <div class="javaex-unit clear tc" style="width: 500px;">'
  614. html += ' <table id="upMsgTable" class="javaex-table td-c-1">'
  615. html += ' <thead>'
  616. html += ' <tr><th>内容</th><th>详情</th></tr>'
  617. html += ' </thead>'
  618. html += ' <tbody id="upMsgTbody">'
  619.  
  620. html += ' </tbody>'
  621. html += '</table> '
  622. html += '</div>'
  623. html += '</form>';
  624. html += '<hr class="javaex-divider"></hr>';
  625. html += '</div>';
  626.  
  627.  
  628. javaex.panel(this, {
  629. position: "right",
  630. content: html
  631. });
  632.  
  633. javaex.table({
  634. id: "upMsgTable",
  635. isDragColWidth: true, // 是否允许拖动改变列宽
  636. mode: "overflow", // overflow表示允许使用父容器溢出来调整列的大小
  637. leftFixedColNum: 2, // 左侧固定列数
  638. rightFixedColNum: 1, // 右侧固定列数
  639. sort: {
  640. "1": "create_time", // 4表示第几列(从1开始计)。create_time表示排序字段,回调函数会返回该值
  641. "2": "update_time"
  642. },
  643. sortCallback: function (rtn) {
  644. //console.log(rtn.sortArr);
  645. }
  646. });
  647.  
  648. //
  649. $("#getUpMsg").click(async function () {
  650.  
  651. let thismid = javaex.getSelectVal("#up_uid");
  652. await HNAPI.userInfo(thismid)
  653.  
  654. let temp = await HNAPI.getUpCard(thismid);
  655.  
  656.  
  657. await HNTOOL.Sleep(500);
  658.  
  659.  
  660. if (temp != false) {
  661. let data = BiliData.upCard.data;
  662.  
  663. let html = ``;
  664. html += `<tr><td>用户UID</td><td>${data.card.mid}</td></tr> `
  665. html += `<tr><td>用户等级</td><td>lv${data.card.level_info.current_level}</td></tr> `
  666. html += `<tr><td>用户昵称</td><td>${data.card.name}</td></tr> `
  667. html += `<tr><td>用户性别</td><td>${data.card.sex}</td></tr> `
  668. html += `<tr><td>用户头像</td><td><a href="javascript:;"><img src= ${data.card.face} width="50%"></a></td></tr> `
  669. html += `<tr><td>粉丝数</td><td>${data.follower}</td></tr> `
  670. html += `<tr><td>关注数</td><td>${data.card.friend}</td></tr> `
  671. html += `<tr><td>是否关注此用户</td><td>${data.following}</td></tr> `
  672. html += `<tr><td>用户稿件数</td><td>${data.archive_count}</td></tr> `
  673. html += `<tr><td>用户勋章</td><td>${data.card.nameplate.name}<a href="javascript:;"><img src= ${data.card.nameplate.image} width="50%"></a> </td></tr> `
  674. html += `<tr><td>用户勋章等级</td><td>${data.card.nameplate.level}</td></tr> `
  675. html += `<tr><td>认证信息</td><td>${data.card.Official.title}</td></tr> `
  676.  
  677.  
  678. $("#upMsgTbody").empty();
  679. $("#upMsgTbody").append(html);
  680. }
  681.  
  682.  
  683. });
  684. //点击放大
  685. /* $("img").click(function() {
  686. javaex.dialog({
  687. type : "image", // 弹出层类型
  688. url : $(this).attr("src") // 图片地址
  689. });
  690. });*/
  691.  
  692. });
  693.  
  694.  
  695. $("#plateActivity").bind("click", async function () {
  696.  
  697. //获取轮盘数据
  698.  
  699. let url = "https://gitee.com/java_cn/BILIBLI_RES/raw/master/HNPLATE/plateActivity.json";
  700. let myjson = await HNAPI.getMyJson(url);
  701. let lmt = 0;
  702. let giftArr = [];
  703.  
  704. javaex.tip({
  705. content: "开始参加轮盘!!!",
  706. type: "success"
  707. });
  708.  
  709. await HNAPI.getUserNav();
  710. await HNTOOL.Sleep(2000);
  711. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `【哔哩猫转盘推送】:用户(` + BiliData.LoginData.uname + `)中奖详情---` + (giftArr.length == 0 ? "未中奖" : giftArr.toString()));
  712.  
  713. for (const json of myjson) {
  714. //let x = json.name;
  715. for (let i = 0; i < 20; i++) {
  716. //结果为true 表示增加次数完成 终止增加
  717. let resout = await HNAPI.addLotteryTimes(json.sid);
  718. await HNTOOL.Sleep(200);
  719. if( resout == true){
  720.  
  721. lmt = await HNAPI.getLotteryMytimes(json.sid);
  722.  
  723. javaex.tip({
  724. content: "可参加"+lmt+"次("+json.name+")抽奖!!!",
  725. type: "success"
  726. });
  727. break;
  728. }
  729.  
  730. }
  731. await HNTOOL.Sleep(1000);
  732.  
  733. for (let i = 0; i < lmt; i++) {
  734.  
  735. let gift = await HNAPI.lotteryDo(json.sid);
  736.  
  737. if(gift == false){
  738. break;
  739. }
  740.  
  741. if(gift != "未中奖0"){
  742. giftArr.push(json.name+"奖品为:"+gift);
  743. break;
  744. }else{
  745. javaex.tip({
  746. content: "未中奖---8秒后执行下一次("+json.name+")抽奖!!!",
  747. type: "success"
  748. });
  749. }
  750. await HNTOOL.Sleep(8000);
  751.  
  752. }
  753.  
  754.  
  755. }
  756.  
  757.  
  758. //HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, `!【哔哩猫转盘推送】:用户{BiliData.LoginData.uname}中奖详情---` + (giftArr.length == 0 ? "未中奖": giftArr.toString()));
  759.  
  760. alert("轮盘抽奖完成!!!中奖名单为:" + giftArr.toString());
  761.  
  762.  
  763. });
  764.  
  765. $("#addPlay").bind("click", async function () {
  766.  
  767.  
  768. let html = '';
  769.  
  770. html += '<div style="padding: 10px 10px 10px 0px;">'
  771. html += '<form id="getUpMassage_form">'
  772.  
  773. html += ' <div class="javaex-unit clear">'
  774. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  775. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  776. html += ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  777. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  778. html += ' </div>'
  779. html += ' </div>'
  780. html += ' <div class="javaex-unit clear">'
  781. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  782. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  783. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  784. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  785. html += ' </div>'
  786. html += ' </div>'
  787. html += '</form>';
  788. html += ' <div class="javaex-unit clear tc">'
  789. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  790. html += ' </div>'
  791. html += '<hr class="javaex-divider"></hr>';
  792. html += '</div>';
  793.  
  794.  
  795. javaex.panel(this, {
  796. position: "right",
  797. content: html
  798. });
  799.  
  800. $("#addPlay_bgn").click(async function () {
  801.  
  802. let MID = javaex.getSelectVal("#addPlay_uid")
  803. let BV = javaex.getSelectVal("#addPlay_bv");
  804. let bvArr = [];
  805. let bvArr2 = [];
  806.  
  807. MID = javaex.ifnull(MID, BiliData.author_uid);
  808.  
  809.  
  810. if (BV == "0") {
  811.  
  812. //1.查询up所有视频BV号 2.发送心跳间隔2s
  813. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  814. await HNTOOL.Sleep(500);
  815. bvArr2 = BiliData.BVList;
  816.  
  817. for (let i = 1; i > 0; i++) {
  818.  
  819. HNAPI.getUpAllBV(MID, i);
  820.  
  821. await HNTOOL.Sleep(500);
  822.  
  823. if (BiliData.BVList.length == 0) {
  824. if (bvArr.length == 0) {
  825. javaex.tip({
  826. content: "该用户无投稿视频,请确认是否有误!",
  827. type: "success"
  828. });
  829. await HNTOOL.Sleep(2000);
  830. }
  831. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  832. bvArr = bvArr.concat(bvArr2);
  833. break;
  834. }
  835.  
  836. bvArr = bvArr.concat(BiliData.BVList);
  837. }
  838.  
  839.  
  840. if (bvArr.length != 0) {
  841.  
  842. for (const emt of bvArr) {
  843.  
  844. HNAPI.playOneVideo(emt.bvid, MID);
  845.  
  846. await HNTOOL.Sleep(2000);
  847.  
  848. }
  849.  
  850. alert("播放完成!!!");
  851.  
  852. }
  853.  
  854.  
  855. } else {
  856. //1.调用点击播放接口
  857. //2.发送心跳
  858.  
  859. await HNTOOL.Sleep(500);
  860.  
  861. HNAPI.playOneVideo(BV);
  862. }
  863.  
  864.  
  865. });
  866.  
  867.  
  868. });
  869.  
  870. }
  871.  
  872. let showUnreadMsg = function () {
  873.  
  874. var html = '';
  875. html += '<div class="javaex-panel-box" style="width: 250px;">';
  876. html += ' <ul>';
  877. html += ` <p style="color: #FFF;">用户消息</p>`;
  878. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  879. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  880. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  881. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  882. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  883. html += ' <hr class="javaex-divider"></hr>';
  884. html += ' </ul>';
  885. html += '</div>';
  886.  
  887.  
  888. javaex.panel(document.getElementById("getUnread"), {
  889. position: "right",
  890. content: html
  891. });
  892.  
  893. javaex.tip({
  894. content: "查询用户通知成功!",
  895. type: "success"
  896. });
  897.  
  898. }
  899.  
  900. /**
  901. * 检查 艾特信息
  902. * @returns {Promise<void>}
  903. */
  904. let chackAtMsg = async function (items) {
  905.  
  906. await HNTOOL.Sleep(500);
  907.  
  908. if (items != false && typeof (items) != "undefined") {
  909.  
  910.  
  911. var html = '';
  912. html += '<div class="javaex-panel-box" style="width: auto;">';
  913. html += ' <ul>';
  914. html += ` <p style="color: #FFF;">@信息</p>`;
  915. items.forEach(function (item) {
  916.  
  917. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  918. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" + `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  919.  
  920. html += ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  921. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  922. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  923. html += ' <hr class="javaex-divider"></hr>';
  924. });
  925. html += ' </ul>';
  926. html += '</div>';
  927.  
  928.  
  929. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  930. javaex.panel(document.getElementById("getAtMsg"), {
  931. position: "right",
  932. content: html
  933. });
  934. } else {
  935. javaex.panel(document.getElementById("chackList"), {
  936. position: "right",
  937. content: html
  938. });
  939. }
  940.  
  941.  
  942. }
  943.  
  944. }
  945.  
  946.  
  947. let addSetPage = async function () {
  948.  
  949. HNTOOL.Sleep(1000);
  950.  
  951. $('body').append('' +
  952. '<div id="left_navbar">' +
  953. '<div class="javaex-menu-container"> ' +
  954. ' <div id="menu" class="javaex-menu"> ' +
  955. ' <ul> ' +
  956. ' <li class="javaex-menu-item alone hover" > ' +
  957. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  958. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  959. ' </li> ' +
  960. ' </ul> ' +
  961. ' <ul> ' +
  962. ' <li class="javaex-menu-item"> ' +
  963. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  964. ' <ul> ' +
  965. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  966. ' </ul> ' +
  967. ' </li> ' +
  968. ' <li id="chackList" class="javaex-menu-item"> ' +
  969. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  970. ' <ul> ' +
  971. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  972. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  973. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  974. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  975. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  976. ' </ul> ' +
  977. ' </li> ' +
  978. ' <li class="javaex-menu-item"> ' +
  979. ' <a href="javascript:;">工具<i class="icon-angle-down"></i></a> ' +
  980. ' <ul> ' +
  981. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  982. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  983. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  984. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  985. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  986. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑</a></li> ' +
  987. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  988. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  989. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  990. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' +//likeInDynamicComments
  991. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  992. ' </ul> ' +
  993. ' </li> ' +
  994. ' <li class="javaex-menu-item"> ' +
  995. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  996. ' <ul> ' +
  997. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  998. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  999. ' </ul> ' +
  1000. ' </li> ' +
  1001.  
  1002. ' </ul> ' +
  1003. ' </div> ' +
  1004. '</div>' +
  1005. '</div>');
  1006. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  1007.  
  1008. javaex.menu({
  1009. id: "menu",
  1010. isShowAll: false
  1011. });
  1012.  
  1013. }
  1014.  
  1015.  
  1016. let addStyle = function () {
  1017. const animate = GM_getResourceText('animate');
  1018. const common = GM_getResourceText('common');
  1019. const defaultCss = GM_getResourceText('defaultCss');
  1020. //const icomoonex = GM_getResourceText('icomoonex');
  1021. //const AllCss = animate + common + defaultCss + icomoonex;
  1022. const AllCss = animate + common + defaultCss;
  1023. const style = document.createElement('style');
  1024. style.innerHTML = AllCss;
  1025. return document.getElementsByTagName('head')[0].appendChild(style);
  1026. }
  1027.  
  1028. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1029.  
  1030.  
  1031. /*-----------------------------------------------常用API--------------------------------------------------*/
  1032.  
  1033. let HNAPI = {
  1034.  
  1035. /**
  1036. *
  1037. * @param sid
  1038. * @returns {Promise<unknown>}
  1039. */
  1040. lotteryDo: async function (sid) {
  1041. return new Promise((resolve) => {
  1042. Ajax.post({
  1043. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  1044. hasCookies: true,
  1045. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1046. data: {
  1047.  
  1048. sid: sid,
  1049. type: 1,
  1050. csrf: Live_info.csrf_token,
  1051. },
  1052. success: responseText => {
  1053. let res = HNTOOL.strToJson(responseText);
  1054. if (res.code === 0) {
  1055. resolve((res.data)[0].gift_name);
  1056. } else {
  1057. javaex.tip({
  1058. content: "本次抽奖失败!" + res.message,
  1059. type: "error"
  1060. });
  1061. resolve(false);
  1062. }
  1063. }
  1064. })
  1065. });
  1066. },
  1067.  
  1068.  
  1069. getLotteryMytimes: async function (sid) {
  1070. return new Promise((resolve) => {
  1071. Ajax.get({
  1072. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  1073. queryStringsObj: {
  1074. sid: sid
  1075. },
  1076. hasCookies: true,
  1077. success: responseText => {
  1078. let res = HNTOOL.strToJson(responseText);
  1079. if (res.code === 0) {
  1080. resolve(res.data.times)
  1081. } else {
  1082. resolve(0)
  1083. }
  1084. }
  1085. })
  1086. });
  1087. },
  1088.  
  1089. /**
  1090. * 增加抽奖次数一般是分享
  1091. * @param sid 活动sid
  1092. * @returns {Promise<unknown>}
  1093. */
  1094. addLotteryTimes: async function (sid) {
  1095. return new Promise((resolve) => {
  1096. Ajax.post({
  1097. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  1098. hasCookies: true,
  1099. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1100. data: {
  1101.  
  1102. sid: sid,
  1103. action_type: 3,
  1104. csrf: Live_info.csrf_token,
  1105. },
  1106. success: responseText => {
  1107. let res = HNTOOL.strToJson(responseText);
  1108. if (res.code === 0) {
  1109. resolve(false)
  1110. } else {
  1111. resolve(true)
  1112. }
  1113. }
  1114. })
  1115. });
  1116. },
  1117. /**
  1118. * 查询用户关注 默认一次查询50
  1119. * @param vmid 用户uid
  1120. * @param pn 页码
  1121. * @returns {Promise<unknown>}
  1122. */
  1123. getMyFollow: async function (vmid, pn) {
  1124. return new Promise((resolve) => {
  1125. Ajax.get({
  1126. url: BILIBLI_PATH.api + '/x/relation/followings',
  1127. queryStringsObj: {
  1128. vmid: vmid,
  1129. pn: pn
  1130. },
  1131. hasCookies: true,
  1132. success: responseText => {
  1133. let res = HNTOOL.strToJson(responseText);
  1134. if (res.code === 0) {
  1135. resolve(res.data)
  1136. } else {
  1137. resolve(null)
  1138. }
  1139. }
  1140. })
  1141. });
  1142. },
  1143.  
  1144.  
  1145. getMyinfo: function () {
  1146. return new Promise((resolve) => {
  1147. Ajax.get({
  1148. url: BILIBLI_PATH.api + '/x/space/myinfo',
  1149. queryStringsObj: {},
  1150. hasCookies: true,
  1151. success: responseText => {
  1152. let res = HNTOOL.strToJson(responseText);
  1153. if (res.code === 0) {
  1154. resolve(res.data)
  1155. } else {
  1156. resolve(null)
  1157. }
  1158. }
  1159. })
  1160. });
  1161. },
  1162.  
  1163. getMyJson: function (url) {
  1164. return new Promise((resolve) => {
  1165. GM_xmlhttpRequest({
  1166. method: "GET",
  1167. url: url,
  1168. onload: function (response) {
  1169. const res = HNTOOL.strToJson((response || {}).responseText)
  1170. resolve(res);
  1171. }
  1172. });
  1173. })
  1174. },
  1175.  
  1176.  
  1177. userInfo: function (mid) {
  1178.  
  1179. Ajax.get({
  1180. url: BILIBLI_PATH.api + '/x/space/acc/info',
  1181. queryStringsObj: {
  1182. mid: mid
  1183. },
  1184. hasCookies: true,
  1185. success: responseText => {
  1186.  
  1187. var json = JSON.parse(responseText);
  1188.  
  1189. if (json.code != 0) {
  1190.  
  1191.  
  1192. }
  1193. }
  1194. });
  1195.  
  1196. },
  1197.  
  1198. sendQmsg: async function (key, msg) {
  1199.  
  1200. $.ajax({
  1201. url: "https://qmsg.zendee.cn/send/" + key + "?msg=" + msg,
  1202.  
  1203. success: function (result) {
  1204.  
  1205. }
  1206. });
  1207.  
  1208.  
  1209. /*GM_xmlhttpRequest({
  1210. method: "GET",
  1211. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  1212. onload: function (response) {
  1213.  
  1214. let json = JSON.parse(response.response);
  1215. if (json.code == 0) {
  1216.  
  1217. javaex.tip({
  1218. content: "自动动态中奖提醒成功!" + json.reason,
  1219. type: "success"
  1220. });
  1221. } else {
  1222. console.log("自动动态中奖提醒失败!" + json.reason);
  1223. javaex.tip({
  1224. content: "自动动态中奖提醒失败!" + json.reason,
  1225. type: "error"
  1226. });
  1227. }
  1228.  
  1229. }
  1230. });*/
  1231.  
  1232. },
  1233.  
  1234. /**
  1235. * 批量关注和拉黑 batchModify
  1236. *
  1237. * https://api.bilibili.com/x/relation/batch/modify
  1238. * @param uid
  1239. */
  1240.  
  1241. batchModify: function (uids, act) {
  1242.  
  1243.  
  1244. Ajax.post({
  1245. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1246. hasCookies: true,
  1247. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1248. data: {
  1249.  
  1250. "fids": uids,
  1251. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1252. "re_src": 151,
  1253. csrf: Live_info.csrf_token,
  1254. },
  1255. success: responseText => {
  1256.  
  1257. let json = JSON.parse(responseText);
  1258.  
  1259. if (/^{"code":0/.test(responseText)) {
  1260.  
  1261. javaex.tip({
  1262. content: `执行成功!---失败(` + json.data.failed_fids.length + `/15)名单:` + json.data.failed_fids,
  1263. type: "success"
  1264. });
  1265.  
  1266. } else {
  1267. javaex.tip({
  1268. content: "关注失败!" + json.message,
  1269. type: "error"
  1270. });
  1271. }
  1272. }
  1273. })
  1274. },
  1275.  
  1276.  
  1277. /**
  1278. * //https://api.bilibili.com/x/relation/modify
  1279. *
  1280. * @param UID
  1281. */
  1282. disUserByUid: function (vmid) {
  1283.  
  1284. Ajax.post({
  1285. url: BILIBLI_PATH.api + '/x/relation/modify',
  1286. data: {
  1287. fid: parseInt(vmid),
  1288. re_src: 11,
  1289. act: 5,
  1290. jsonp: "jsonp",
  1291. csrf: Live_info.csrf_token,
  1292. },
  1293. hasCookies: true,
  1294. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1295. success: responseText => {
  1296.  
  1297. var json = JSON.parse(responseText);
  1298.  
  1299. if (json.code != 0) {
  1300.  
  1301. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  1302. javaex.tip({
  1303. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  1304. type: "error"
  1305. });
  1306.  
  1307. } else {
  1308. console.log("拉黑用户成功 uid:" + vmid);
  1309. javaex.tip({
  1310. content: "拉黑用户成功 uid:" + vmid,
  1311. type: "success"
  1312. });
  1313. }
  1314. }
  1315. });
  1316.  
  1317. },
  1318. /**
  1319. * http://api.bilibili.com/x/web-interface/view
  1320. * @param BV
  1321. * 心跳间隔15秒
  1322. */
  1323. playOneVideo: function (BV, MID) {
  1324.  
  1325. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  1326. Ajax.post({
  1327. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  1328. hasCookies: true,
  1329. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1330. data: {
  1331.  
  1332. "bvid": BV,
  1333. "part": 1,
  1334. "mid": Live_info.uid,
  1335. "lv": 2,
  1336. "jsonp": "jsonp",
  1337. "type": 3,
  1338. "sub_type": 0
  1339. },
  1340. success: responseText => {
  1341.  
  1342. let json = JSON.parse(responseText);
  1343.  
  1344. if (/^{"code":0/.test(responseText)) {
  1345. //发送一次心跳
  1346. HNAPI.sendHeartbeat(BV, MID);
  1347.  
  1348. } else {
  1349. javaex.tip({
  1350. content: "视频" + data.bvid + "播放失败!" + json.message,
  1351. type: "error"
  1352. });
  1353. }
  1354. }
  1355. })
  1356.  
  1357.  
  1358. },
  1359.  
  1360. //上报视频播放心跳(web端)
  1361. /**
  1362. * http://api.bilibili.com/x/click-interface/web/heartbeat
  1363. * @param json
  1364. */
  1365. sendHeartbeat: function (bvid, MID) {
  1366.  
  1367. Ajax.post({
  1368. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  1369. hasCookies: true,
  1370. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1371. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  1372. data: {
  1373. "bvid": bvid,
  1374. "type": 3,
  1375. "dt": 2,
  1376. "played_time": HNTOOL.random(12, 40),
  1377. "realtime": HNTOOL.random(12, 40),
  1378. "play_type": 0
  1379. },
  1380. success: responseText => {
  1381.  
  1382. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  1383.  
  1384. javaex.tip({
  1385. content: "视频BV" + bvid + "播放一次!",
  1386. type: "success"
  1387. });
  1388. }
  1389. }
  1390. })
  1391.  
  1392. },
  1393.  
  1394. //获取up所有投稿视频
  1395. /**
  1396. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  1397. * @param mid
  1398. */
  1399. getUpAllBV: function (mid, pn, ps) {
  1400. ps = (ps === undefined ? 30 : ps); // a默认值为1
  1401. Ajax.get({
  1402. url: BILIBLI_PATH.api + '/x/space/arc/search',
  1403. queryStringsObj: {
  1404. mid: mid,
  1405. tid: 0,
  1406. order: 'pubdate',
  1407. jsonp: 'jsonp',
  1408. pn: pn,
  1409. ps: ps
  1410. },
  1411. hasCookies: true,
  1412. success: responseText => {
  1413.  
  1414. var json = JSON.parse(responseText);
  1415.  
  1416. if (json.code != 0) {
  1417.  
  1418. javaex.tip({
  1419. content: "获取up所有投稿视频失败!" + json.message,
  1420. type: "success"
  1421. });
  1422.  
  1423. } else {
  1424. BiliData.BVList = json.data.list.vlist;
  1425.  
  1426. }
  1427. }
  1428. });
  1429.  
  1430. },
  1431.  
  1432.  
  1433. /**
  1434. *
  1435. * @param path
  1436. * @param data
  1437. * @param saveObj
  1438. * @param Func
  1439. */
  1440. publicGet: function (path, queryStringsObj) {
  1441.  
  1442. if (typeof (queryStringsObj) != "undefined") {
  1443. queryStringsObj = {};
  1444. }
  1445. Ajax.get({
  1446. url: BILIBLI_PATH.api + path,
  1447. queryStringsObj: queryStringsObj,
  1448. hasCookies: true,
  1449. success: responseText => {
  1450.  
  1451. let json = JSON.parse(responseText);
  1452. if (chackCode(json.code) && json.code == 0) {
  1453.  
  1454. return json.data;
  1455. }
  1456.  
  1457. return false;
  1458.  
  1459. }
  1460. })
  1461.  
  1462. },
  1463.  
  1464. /**
  1465. * 导航栏用户信息
  1466. */
  1467. getUserNav: async function () {
  1468.  
  1469. GM_xmlhttpRequest({
  1470. method: "GET",
  1471. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  1472. //timeout:3000,
  1473. onload: function (response) {
  1474.  
  1475. let json = JSON.parse(response.response);
  1476. console.log(json);
  1477. BiliData.login_code = json.code;
  1478. BiliData.login_message = json.message;
  1479. BiliData.LoginData = json.data;
  1480.  
  1481. }
  1482. });
  1483.  
  1484. },
  1485.  
  1486. /**
  1487. * 获取某up详细信息
  1488. * http://api.bilibili.com/x/web-interface/card
  1489. */
  1490. getUpCard: function (mid) {
  1491.  
  1492. Ajax.get({
  1493. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1494. queryStringsObj: {
  1495. mid: mid,
  1496. photo: false
  1497. },
  1498. hasCookies: true,
  1499. success: responseText => {
  1500.  
  1501. var json = JSON.parse(responseText);
  1502.  
  1503. if (json.code != 0) {
  1504.  
  1505. javaex.tip({
  1506. content: "查询失败!" + json.message,
  1507. type: "success"
  1508. });
  1509. return false;
  1510. } else {
  1511. BiliData.upCard = json;
  1512.  
  1513. }
  1514.  
  1515.  
  1516. }
  1517. })
  1518.  
  1519. },
  1520.  
  1521. /**
  1522. *
  1523. * @param uid 用户uid
  1524. * @param ps 每页视频个数 默认30个
  1525. * @param pn 第几页
  1526. */
  1527. getUpAllVideo: function (uid, ps, pn) {
  1528.  
  1529. },
  1530. getChallenge: async function () {
  1531.  
  1532.  
  1533. },
  1534. /**
  1535. * 硬币记录
  1536. * @returns {Promise<void>}
  1537. */
  1538. getCoinLog: async function () {
  1539.  
  1540. GM_xmlhttpRequest({
  1541. method: "GET",
  1542. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  1543. //url: "http://api.bilibili.com/x/member/web/coin/log",
  1544. onload: function (response) {
  1545.  
  1546. let json = JSON.parse(response.response);
  1547. if (json.code == 0) {
  1548.  
  1549. console.log("硬币记录" + json);
  1550. BiliData.CoinLog = json.data;
  1551.  
  1552. return true;
  1553. }
  1554.  
  1555. }
  1556. });
  1557. },
  1558. /**
  1559. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  1560. * @returns {Promise<void>}
  1561. */
  1562. getUnread: async function () {
  1563.  
  1564. Ajax.get({
  1565. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1566. hasCookies: true,
  1567. success: responseText => {
  1568.  
  1569. let json = JSON.parse(responseText);
  1570. if (chackCode(json.code) && json.code == 0) {
  1571.  
  1572. BiliData.Unread = json.data;
  1573. showUnreadMsg();
  1574. }
  1575.  
  1576. return false;
  1577.  
  1578. }
  1579. })
  1580.  
  1581. /* GM_xmlhttpRequest({
  1582. method: "GET",
  1583. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1584. onload: function (response) {
  1585.  
  1586. let json = JSON.parse(response.response);
  1587.  
  1588. if (chackCode(json.code) && json.code == 0) {
  1589.  
  1590. BiliData.Unread = json.code;
  1591. showUnreadMsg();
  1592.  
  1593. }
  1594.  
  1595. }
  1596. });*/
  1597. },
  1598. /**
  1599. *
  1600. * @param type reply:回复我的 at @我的
  1601. */
  1602. getMsgfeed: function (type) {
  1603. Ajax.get({
  1604. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  1605. queryStringsObj: {
  1606. build: 0,
  1607. mobi_app: 'web'
  1608. },
  1609. hasCookies: true,
  1610. success: responseText => {
  1611.  
  1612. var json = JSON.parse(responseText);
  1613.  
  1614. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  1615. return false;
  1616. } else {
  1617. chackAtMsg(json.data.items);
  1618.  
  1619. return true;
  1620. }
  1621.  
  1622.  
  1623. }
  1624. })
  1625.  
  1626. },
  1627.  
  1628. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  1629. * @returns {Promise<void>}
  1630. */
  1631. getUnrewad: async function () {
  1632.  
  1633. GM_xmlhttpRequest({
  1634. method: "GET",
  1635. data: {
  1636. "mid": 99439379,
  1637. "pn": 1,
  1638. "ps": 5,
  1639. },
  1640. url: BILIBLI_PATH.api + "/x/space/arc/search",
  1641. onload: function (response) {
  1642.  
  1643. let json = JSON.parse(response.response);
  1644. if (json.code == 0) {
  1645.  
  1646. BiliData.Video = json.data;
  1647. console.log("未读消息数" + json);
  1648. }
  1649.  
  1650. }
  1651. });
  1652. },
  1653.  
  1654. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  1655. * @param {number} oid
  1656. * @param {nbumber} rpid
  1657. * @param {number} action
  1658. * @returns {Promise<void>}
  1659. * type: 11
  1660. * ordering: heat
  1661. * jsonp: jsonp
  1662. * csrf: 54a******* CSRF Token(位于cookie)
  1663. */
  1664.  
  1665. likeInDynamicComments: async function (oid, rpid, action) {
  1666.  
  1667.  
  1668. Ajax.post({
  1669. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  1670. hasCookies: true,
  1671. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1672. data: {
  1673. "oid": oid,
  1674. "type": 11,
  1675. "rpid": rpid,
  1676. "action": action,
  1677. "ordering": "heat",
  1678. "jsonp": "jsonp",
  1679. "csrf": Live_info.csrf_token,
  1680. },
  1681. success: responseText => {
  1682.  
  1683. if (/^{"code":0/.test(responseText)) {
  1684.  
  1685. BiliData.replyAction = JSON.parse(responseText);
  1686. console.log("点赞成功!" + responseText);
  1687. }
  1688. }
  1689. })
  1690.  
  1691. }
  1692.  
  1693.  
  1694. }
  1695.  
  1696. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  1697.  
  1698.  
  1699. let HNTOOL = {
  1700. /**
  1701. * s数组去重并排序
  1702. */
  1703.  
  1704. arrUnique: function (ary) {
  1705.  
  1706. let obj = {};
  1707. for (let i = 0; i < ary.length; i++) {//this 指向方法.前的对象ary
  1708. let item = ary[i]
  1709. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  1710. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  1711. // 如果没有 将这个元素添加到对象中
  1712. ary.sort((a, b) => {
  1713. return a - b
  1714. })// 数组去重后 按升序排列
  1715. obj = null;
  1716. return ary;
  1717.  
  1718. },
  1719.  
  1720. split_array: function (arr, len) {
  1721.  
  1722. let arr_length = arr.length;
  1723. let newArr = [];
  1724. for (let i = 0; i < arr_length; i += len) {
  1725. newArr.push(arr.slice(i, i + len));
  1726. }
  1727. return newArr;
  1728. },
  1729. strToJson: function (params) {
  1730. const isJSON = (str => {
  1731. if (typeof str === 'string') {
  1732. try {
  1733. const obj = JSON.parse(str);
  1734. return typeof obj === 'object' ? obj : false
  1735. } catch (_) {
  1736. console.log(str);
  1737. return false;
  1738. }
  1739. } else {
  1740. console.log(`${str}\nIt is not a string!`);
  1741. return false;
  1742. }
  1743. })(params);
  1744. return isJSON ? isJSON : {}
  1745. },
  1746.  
  1747. chackAtMsg: function () {
  1748.  
  1749. let config = HNTOOL.getConfig();
  1750. if (config.qmsg_checked == true && config.qmsg_key) {
  1751.  
  1752. document.getElementById("getAtMsg").click();
  1753.  
  1754. }
  1755.  
  1756. },
  1757.  
  1758. cssChecked: function (id, dom) {
  1759.  
  1760. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  1761.  
  1762.  
  1763. },
  1764. getConfig: function () {
  1765.  
  1766. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  1767.  
  1768. if (CONFIG == null) {
  1769. CONFIG = HN_SETUP_CONFIG;
  1770. }
  1771.  
  1772. return CONFIG;
  1773. },
  1774.  
  1775. /**
  1776. * 获取cookie 中某个键对应的值
  1777. * @param name
  1778. */
  1779.  
  1780. getCookie: function (name) {
  1781. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  1782. if (arr != null) return unescape(arr[2]);
  1783. return false;
  1784. },
  1785. /**
  1786. * 得到一个字符串数组的中随机一个
  1787. * @param {List} list
  1788. */
  1789. getRandomWordOfList: function (list) {
  1790. var L = list.length;
  1791. var i = Math.ceil(Math.random() * L);
  1792.  
  1793. return list[i];
  1794. },
  1795. random: function (min, max) {
  1796.  
  1797. return Math.floor(Math.random() * (max - min)) + min;
  1798. },
  1799.  
  1800. Sleep: function (ms) {
  1801. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  1802. }
  1803.  
  1804. }
  1805.  
  1806. let errorMsg = {
  1807. "-1": "应用程序不存在或已被封禁!",
  1808. "-2": "Access Key错误!",
  1809. "-3": "API校验密匙错误!",
  1810. "-4": "调用方对该Method没有权限!",
  1811. "-101": "账号未登录!",
  1812. "-102": "账号被封停!",
  1813. "-103": "积分不足!",
  1814. "-104": "硬币不足!",
  1815. "-105": "验证码错误!",
  1816. "-106": "账号非正式会员或在适应期!",
  1817. "-107": "应用不存在或者被封禁!",
  1818. "-108": "未绑定手机!",
  1819. "-109": "未知!",
  1820. "-110": "未绑定手机!",
  1821. "-111": "csrf 校验失败!",
  1822. "-112": "系统升级中!",
  1823. "-113": "账号尚未实名认证!",
  1824. "-114": "请先绑定手机!",
  1825. "-115": "请先完成实名认证!",
  1826. "-304": "木有改动!",
  1827. "-307": "撞车跳转!",
  1828. "-400": "请求错误!",
  1829. "-401": "未认证!",
  1830. "-403": "访问权限不足!",
  1831. "-404": "啥都木有!",
  1832. }
  1833.  
  1834. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  1835. /**
  1836. *
  1837. * @param code
  1838. * @constructor
  1839. */
  1840. let chackCode = function (code) {
  1841.  
  1842. let emsg = errorMsg[code + ""];
  1843. if (emsg != null) {
  1844. javaex.tip({content: emsg, type: "error"});
  1845.  
  1846. return false;
  1847. }
  1848.  
  1849. return true;
  1850. }
  1851.  
  1852.  
  1853. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  1854. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  1855.  
  1856. /*window.onbeforeunload = function() {
  1857. if (!canLeavePage()) {
  1858. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  1859. }
  1860. };*/
  1861.  
  1862.  
  1863. /**
  1864. * Ajax请求对象
  1865. */
  1866. const Ajax = (() => {
  1867. /**
  1868. * 检查options是否符合要求
  1869. * @param {object} options
  1870. * @returns {boolean}
  1871. */
  1872. function checkOptions(options) {
  1873. let result = false;
  1874. if (typeof options !== 'object') {
  1875. console.warn('类型错误: typeof Options !== Object');
  1876. return result;
  1877. } else {
  1878. if (typeof options.url !== 'string') {
  1879. console.warn('类型错误: typeof Link !== Strings');
  1880. return result;
  1881. } else {
  1882. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  1883. if (!reg.test(options.url)) {
  1884. console.warn('url字符串须为完整http链接');
  1885. return result;
  1886. }
  1887. result = true;
  1888. }
  1889. }
  1890. return result;
  1891. }
  1892.  
  1893. /**
  1894. * 对象转URL编码
  1895. * @param {object} data
  1896. */
  1897. function objToURLCode(data) {
  1898. var _result = [];
  1899. for (var key in data) {
  1900. var value = data[key];
  1901. if (value instanceof Array) {
  1902. value.forEach(function (_value) {
  1903. _result.push(key + "=" + _value);
  1904. });
  1905. } else {
  1906. _result.push(key + '=' + value);
  1907. }
  1908. }
  1909. return _result.join('&');
  1910. }
  1911.  
  1912. /**
  1913. * 请求
  1914. * @param {string} method
  1915. * @param {object} options
  1916. */
  1917. function request(method, options) {
  1918. if (checkOptions(options)) {
  1919. let xhr = new XMLHttpRequest();
  1920. const {url: _url, queryStringsObj, data, dataType, hasCookies} = options
  1921. , url = typeof queryStringsObj === 'object' ?
  1922. _url + '?' + objToURLCode(queryStringsObj) : _url;
  1923. switch (method) {
  1924. case 'GET':
  1925. xhr.open("GET", url);
  1926. break;
  1927. case 'POST':
  1928. xhr.open("POST", url);
  1929. xhr.setRequestHeader('Content-Type', dataType);
  1930. break;
  1931. default:
  1932. break;
  1933. }
  1934. if (hasCookies) xhr.withCredentials = true;
  1935. xhr.timeout = 3000;
  1936. xhr.addEventListener('load', () => {
  1937. if (xhr.status === 200) {
  1938. options.success(xhr.responseText)
  1939. } else {
  1940. console.error(`status:${xhr.status}`);
  1941. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  1942. }
  1943. })
  1944. xhr.addEventListener('error', () => {
  1945. console.error('ajax请求出错')
  1946. options.success('{"code":-1,"msg":"ajax请求出错"}');
  1947. })
  1948. xhr.addEventListener('timeout', () => {
  1949. console.error('请求超时')
  1950. options.success('{"code":-1,"msg":"请求超时"}');
  1951. })
  1952. switch (method) {
  1953. case 'GET':
  1954. xhr.send()
  1955. break;
  1956. case 'POST':
  1957. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  1958. break;
  1959. default:
  1960. break;
  1961. }
  1962. }
  1963. }
  1964.  
  1965. return {
  1966. /**
  1967. * 发送Get请求
  1968. * @param {Object} options
  1969. */
  1970. get(options) {
  1971. request("GET", options);
  1972. },
  1973. /**
  1974. * 发送Post请求
  1975. * @param {object} options
  1976. */
  1977. post(options) {
  1978. request("POST", options);
  1979. }
  1980. }
  1981. })()