-哔哩猫-(试用版)

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

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

此脚本不应直接安装。它是供其他脚本使用的外部库,要使用该库请加入元指令 // @require https://update.cn-greasyfork.org/scripts/422731/918995/-%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.70
  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">Q酱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. for (const json of myjson) {
  704. //let x = json.name;
  705. for (let i = 0; i < 20; i++) {
  706. //结果为true 表示增加次数完成 终止增加
  707. let resout = await HNAPI.addLotteryTimes(json.sid);
  708. await HNTOOL.Sleep(500);
  709. if( resout == true){
  710.  
  711. lmt = await HNAPI.getLotteryMytimes(json.sid);
  712.  
  713. javaex.tip({
  714. content: "可参加"+lmt+"次("+json.name+")抽奖!!!",
  715. type: "success"
  716. });
  717. break;
  718. }
  719.  
  720. }
  721. await HNTOOL.Sleep(1000);
  722.  
  723. for (let i = 0; i < lmt; i++) {
  724.  
  725. let gift = await HNAPI.lotteryDo(json.sid);
  726.  
  727. if(gift == false){
  728. break;
  729. }
  730.  
  731. if(gift != "未中奖0"){
  732. giftArr.push(json.name);
  733. break;
  734. }else{
  735. javaex.tip({
  736. content: "未中奖---8秒后执行下一次("+json.name+")抽奖!!!",
  737. type: "success"
  738. });
  739. }
  740. await HNTOOL.Sleep(8000);
  741.  
  742. }
  743.  
  744.  
  745. }
  746.  
  747. alert("轮盘抽奖完成!!!中奖名单为:"+giftArr.toString());
  748.  
  749.  
  750.  
  751. });
  752.  
  753. $("#addPlay").bind("click", async function () {
  754.  
  755.  
  756. let html = '';
  757.  
  758. html += '<div style="padding: 10px 10px 10px 0px;">'
  759. html += '<form id="getUpMassage_form">'
  760.  
  761. html += ' <div class="javaex-unit clear">'
  762. html += ' <div class="javaex-unit-left"><p class="subtitle required">UID</p></div>'
  763. html += ` <div class="javaex-unit-right" tooltip="请输入用户UID,默认自己" tooltip-pos="up"> `
  764. html += ' <input type="text" class="javaex-text" data-type="positive_int|required" error-msg="请正确输入uid"'
  765. html += ` id="addPlay_uid" value="${Live_info.uid}" placeholder="默认${BiliData.author_uid}"/>`
  766. html += ' </div>'
  767. html += ' </div>'
  768. html += ' <div class="javaex-unit clear">'
  769. html += ' <div class="javaex-unit-left"><p class="subtitle required">BV</p></div>'
  770. html += ' <div class="javaex-unit-right" tooltip="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)" tooltip-pos="up">'
  771. html += ' <input type="text" class="javaex-text" data-type="required|english_number" error-msg=""'
  772. html += ` id="addPlay_bv" value="0" placeholder="请输入视频BV号 例如BV14r4y1A7Q9 (0表示全部)"/>`
  773. html += ' </div>'
  774. html += ' </div>'
  775. html += '</form>';
  776. html += ' <div class="javaex-unit clear tc">'
  777. html += ' <button id="addPlay_bgn" class="javaex-btn blue radius-3">开始</button> '
  778. html += ' </div>'
  779. html += '<hr class="javaex-divider"></hr>';
  780. html += '</div>';
  781.  
  782.  
  783. javaex.panel(this, {
  784. position: "right",
  785. content: html
  786. });
  787.  
  788. $("#addPlay_bgn").click(async function () {
  789.  
  790. let MID = javaex.getSelectVal("#addPlay_uid")
  791. let BV = javaex.getSelectVal("#addPlay_bv");
  792. let bvArr = [];
  793. let bvArr2 = [];
  794.  
  795. MID = javaex.ifnull(MID, BiliData.author_uid);
  796.  
  797.  
  798. if (BV == "0") {
  799.  
  800. //1.查询up所有视频BV号 2.发送心跳间隔2s
  801. HNAPI.getUpAllBV(BiliData.author_uid, 1, 2);
  802. await HNTOOL.Sleep(500);
  803. bvArr2 = BiliData.BVList;
  804.  
  805. for (let i = 1; i > 0; i++) {
  806.  
  807. HNAPI.getUpAllBV(MID, i);
  808.  
  809. await HNTOOL.Sleep(500);
  810.  
  811. if (BiliData.BVList.length == 0) {
  812. if (bvArr.length == 0) {
  813. javaex.tip({
  814. content: "该用户无投稿视频,请确认是否有误!",
  815. type: "success"
  816. });
  817. await HNTOOL.Sleep(2000);
  818. }
  819. //bvArr = bvArr.ifnull(bvArr2, bvArr.concat(bvArr2));
  820. bvArr = bvArr.concat(bvArr2);
  821. break;
  822. }
  823.  
  824. bvArr = bvArr.concat(BiliData.BVList);
  825. }
  826.  
  827.  
  828. if (bvArr.length != 0) {
  829.  
  830. for (const emt of bvArr) {
  831.  
  832. HNAPI.playOneVideo(emt.bvid, MID);
  833.  
  834. await HNTOOL.Sleep(2000);
  835.  
  836. }
  837.  
  838. alert("播放完成!!!");
  839.  
  840. }
  841.  
  842.  
  843. } else {
  844. //1.调用点击播放接口
  845. //2.发送心跳
  846.  
  847. await HNTOOL.Sleep(500);
  848.  
  849. HNAPI.playOneVideo(BV);
  850. }
  851.  
  852.  
  853. });
  854.  
  855.  
  856. });
  857.  
  858. }
  859.  
  860. let showUnreadMsg = function () {
  861.  
  862. var html = '';
  863. html += '<div class="javaex-panel-box" style="width: 250px;">';
  864. html += ' <ul>';
  865. html += ` <p style="color: #FFF;">用户消息</p>`;
  866. html += ` <li><a href="https://message.bilibili.com/#/at">未读艾特数:${BiliData.Unread.at}</a> </li> `;
  867. html += ` <li><a href="https://message.bilibili.com/#/love">未读点赞数:${BiliData.Unread.like}</a> </li> `;
  868. html += ` <li><a href="https://message.bilibili.com/#/reply">未读回复数:${BiliData.Unread.reply}</a> </li> `;
  869. html += ` <li><a href="https://message.bilibili.com/#/system">未读系统通知数:${BiliData.Unread.sys_msg}</a> </li> `;
  870. html += ` <li><a href="">UP主助手信息数:${BiliData.Unread.up}</a> </li> `;
  871. html += ' <hr class="javaex-divider"></hr>';
  872. html += ' </ul>';
  873. html += '</div>';
  874.  
  875.  
  876. javaex.panel(document.getElementById("getUnread"), {
  877. position: "right",
  878. content: html
  879. });
  880.  
  881. javaex.tip({
  882. content: "查询用户通知成功!",
  883. type: "success"
  884. });
  885.  
  886. }
  887.  
  888. /**
  889. * 检查 艾特信息
  890. * @returns {Promise<void>}
  891. */
  892. let chackAtMsg = async function (items) {
  893.  
  894. await HNTOOL.Sleep(500);
  895.  
  896. if (items != false && typeof (items) != "undefined") {
  897.  
  898.  
  899. var html = '';
  900. html += '<div class="javaex-panel-box" style="width: auto;">';
  901. html += ' <ul>';
  902. html += ` <p style="color: #FFF;">@信息</p>`;
  903. items.forEach(function (item) {
  904.  
  905. var atTime = javaex.dateFormat(item.at_time, 'yyyy-MM-dd HH:mm:ss');
  906. HNAPI.sendQmsg(HNTOOL.getConfig().qmsg_key, atTime + " 恭喜动态中奖了!" + `${item.user.nickname}在动态中艾特了你! 内容:${item.item.source_content}`);
  907.  
  908. html += ` <li>${atTime} <a class="fontbold" href="https://space.bilibili.com/${item.user.mid}">:${item.user.nickname}</a>在动态中艾特了你!</li> `
  909. html += ` <li class="fontbold">内容:${item.item.source_content}</li> `;
  910. html += ` <li><a href="${item.item.uri}">---点击查看详情---</a> </li> `;
  911. html += ' <hr class="javaex-divider"></hr>';
  912. });
  913. html += ' </ul>';
  914. html += '</div>';
  915.  
  916.  
  917. if (($("#chackList").attr("class")).indexOf("hover") > -1) {
  918. javaex.panel(document.getElementById("getAtMsg"), {
  919. position: "right",
  920. content: html
  921. });
  922. } else {
  923. javaex.panel(document.getElementById("chackList"), {
  924. position: "right",
  925. content: html
  926. });
  927. }
  928.  
  929.  
  930. }
  931.  
  932. }
  933.  
  934.  
  935. let addSetPage = async function () {
  936.  
  937. HNTOOL.Sleep(1000);
  938.  
  939. $('body').append('' +
  940. '<div id="left_navbar">' +
  941. '<div class="javaex-menu-container"> ' +
  942. ' <div id="menu" class="javaex-menu"> ' +
  943. ' <ul> ' +
  944. ' <li class="javaex-menu-item alone hover" > ' +
  945. ' <a href="javaScript:;" style="background: #fb7299;padding-left: 0px;text-align: center;color: #ffffff;font-weight: bold;border-bottom: 1px solid #eee;" ' +
  946. ` tooltip="我是来测试的" tooltip-pos="right">管理中心 v${GM_info.script.version}</a> ` +
  947. ' </li> ' +
  948. ' </ul> ' +
  949. ' <ul> ' +
  950. ' <li class="javaex-menu-item"> ' +
  951. ' <a href="javascript:;">个人中心<i class="icon-angle-down"></i></a> ' +
  952. ' <ul> ' +
  953. ' <li id="biliUserMsg" class="javaex-hover-pulse"><a href="javaScript:;">用户信息</a></li> ' +
  954. ' </ul> ' +
  955. ' </li> ' +
  956. ' <li id="chackList" class="javaex-menu-item"> ' +
  957. ' <a href="javaScript:;">查询<i class="icon-angle-down"></i></a> ' +
  958. ' <ul> ' +
  959. ' <li id="getUpMassage" ><a href="javaScript:;">查询用户详细信息</a></li> ' +
  960. ' <li><a href="javaScript:;">查询每日最热视频【禁用】</a></li> ' +
  961. ' <li id="getAtMsg"><a href="javaScript:;">查询动态艾特信息</a></li> ' +
  962. ' <li id="getCoinLog" class="javaex-hover-pulse"><a href="javaScript:;">查询硬币变化</a></li> ' +
  963. ' <li id="getUnread" class="javaex-hover-pulse"><a href="javaScript:;">查询消息</a></li> ' +
  964. ' </ul> ' +
  965. ' </li> ' +
  966. ' <li class="javaex-menu-item"> ' +
  967. ' <a href="javascript:;">工具<i class="icon-angle-down"></i></a> ' +
  968. ' <ul> ' +
  969. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >移动粉丝勋章</a></li> ' +
  970. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >评论区抽奖</a></li> ' +
  971. ' <li id="plateActivity" class="javaex-hover-pulse"><a href="javaScript:;" >轮盘抽奖</a></li> ' +
  972. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >注册答题</a></li> ' +
  973. ' <li id="addPlay" class="javaex-hover-pulse"><a href="javaScript:;" >批量播放视频</a></li> ' +
  974. ' <li id="disUser" class="javaex-hover-pulse"><a href="javaScript:;" >批量拉黑</a></li> ' +
  975. ' <li id="batchFollow" class="javaex-hover-pulse"><a href="javaScript:;" >批量关注</a></li> ' +
  976. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发私信</a></li> ' +
  977. ' <li class="javaex-hover-pulse"><a href="javaScript:;" >批量发送视频弹幕</a></li> ' +
  978. ' <li id="" class="javaex-hover-pulse" ><a href="javaScript:;">动态评论区点赞</a></li> ' +//likeInDynamicComments
  979. ' <li id="HNSetup" class="javaex-hover-pulse" ><span class="icon-cogs" style="font-size:50px;color:#ff0000;"></span><a href="javaScript:;">设置</a></li> ' +
  980. ' </ul> ' +
  981. ' </li> ' +
  982. ' <li class="javaex-menu-item"> ' +
  983. ' <a href="javascript:;">其他工具<i class="icon-angle-down"></i></a> ' +
  984. ' <ul> ' +
  985. ' <li id="arrUnique" class="javaex-hover-pulse"><a href="javaScript:;">数组去重</a></li> ' +
  986. ' <li class="javaex-hover-pulse"><a href="https://greasyfork.org/zh-CN/scripts/422731" >更新</a></li> ' +
  987. ' </ul> ' +
  988. ' </li> ' +
  989.  
  990. ' </ul> ' +
  991. ' </div> ' +
  992. '</div>' +
  993. '</div>');
  994. //$("#left_navbar").before('<button hnBtn="btn_open" class="javaex-btn green" onclick="openBar()">点我关闭</button>')
  995.  
  996. javaex.menu({
  997. id: "menu",
  998. isShowAll: false
  999. });
  1000.  
  1001. }
  1002.  
  1003.  
  1004. let addStyle = function () {
  1005. const animate = GM_getResourceText('animate');
  1006. const common = GM_getResourceText('common');
  1007. const defaultCss = GM_getResourceText('defaultCss');
  1008. //const icomoonex = GM_getResourceText('icomoonex');
  1009. //const AllCss = animate + common + defaultCss + icomoonex;
  1010. const AllCss = animate + common + defaultCss;
  1011. const style = document.createElement('style');
  1012. style.innerHTML = AllCss;
  1013. return document.getElementsByTagName('head')[0].appendChild(style);
  1014. }
  1015.  
  1016. /*-----------------------------------------------点击事件绑定--------------------------------------------------*/
  1017.  
  1018.  
  1019. /*-----------------------------------------------常用API--------------------------------------------------*/
  1020.  
  1021. let HNAPI = {
  1022.  
  1023. /**
  1024. *
  1025. * @param sid
  1026. * @returns {Promise<unknown>}
  1027. */
  1028. lotteryDo: async function (sid) {
  1029. return new Promise((resolve) => {
  1030. Ajax.post({
  1031. url: BILIBLI_PATH.api + '/x/activity/lottery/do',
  1032. hasCookies: true,
  1033. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1034. data: {
  1035.  
  1036. sid: sid,
  1037. type: 1,
  1038. csrf: Live_info.csrf_token,
  1039. },
  1040. success: responseText => {
  1041. let res = HNTOOL.strToJson(responseText);
  1042. if (res.code === 0) {
  1043. resolve((res.data)[0].gift_name);
  1044. } else {
  1045. javaex.tip({
  1046. content: "本次抽奖失败!" + res.message,
  1047. type: "error"
  1048. });
  1049. resolve(false);
  1050. }
  1051. }
  1052. })
  1053. });
  1054. },
  1055.  
  1056.  
  1057. getLotteryMytimes: async function (sid) {
  1058. return new Promise((resolve) => {
  1059. Ajax.get({
  1060. url: BILIBLI_PATH.api + '/x/activity/lottery/mytimes',
  1061. queryStringsObj: {
  1062. sid:sid
  1063. },
  1064. hasCookies: true,
  1065. success: responseText => {
  1066. let res = HNTOOL.strToJson(responseText);
  1067. if (res.code === 0) {
  1068. resolve(res.data.times)
  1069. } else {
  1070. resolve(0)
  1071. }
  1072. }
  1073. })
  1074. });
  1075. },
  1076.  
  1077. /**
  1078. * 增加抽奖次数一般是分享
  1079. * @param sid 活动sid
  1080. * @returns {Promise<unknown>}
  1081. */
  1082. addLotteryTimes: async function (sid) {
  1083. return new Promise((resolve) => {
  1084. Ajax.post({
  1085. url: BILIBLI_PATH.api + '/x/activity/lottery/addtimes',
  1086. hasCookies: true,
  1087. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1088. data: {
  1089.  
  1090. sid: sid,
  1091. action_type: 3,
  1092. csrf: Live_info.csrf_token,
  1093. },
  1094. success: responseText => {
  1095. let res = HNTOOL.strToJson(responseText);
  1096. if (res.code === 0) {
  1097. resolve(false)
  1098. } else {
  1099. resolve(true)
  1100. }
  1101. }
  1102. })
  1103. });
  1104. },
  1105. /**
  1106. * 查询用户关注 默认一次查询50
  1107. * @param vmid 用户uid
  1108. * @param pn 页码
  1109. * @returns {Promise<unknown>}
  1110. */
  1111. getMyFollow: async function (vmid, pn) {
  1112. return new Promise((resolve) => {
  1113. Ajax.get({
  1114. url: BILIBLI_PATH.api + '/x/relation/followings',
  1115. queryStringsObj: {
  1116. vmid:vmid,
  1117. pn:pn
  1118. },
  1119. hasCookies: true,
  1120. success: responseText => {
  1121. let res = HNTOOL.strToJson(responseText);
  1122. if (res.code === 0) {
  1123. resolve(res.data)
  1124. } else {
  1125. resolve(null)
  1126. }
  1127. }
  1128. })
  1129. });
  1130. },
  1131.  
  1132.  
  1133. getMyinfo: function () {
  1134. return new Promise((resolve) => {
  1135. Ajax.get({
  1136. url: BILIBLI_PATH.api + '/x/space/myinfo',
  1137. queryStringsObj: {},
  1138. hasCookies: true,
  1139. success: responseText => {
  1140. let res = HNTOOL.strToJson(responseText);
  1141. if (res.code === 0) {
  1142. resolve(res.data)
  1143. } else {
  1144. resolve(null)
  1145. }
  1146. }
  1147. })
  1148. });
  1149. },
  1150.  
  1151. getMyJson: function (url) {
  1152. return new Promise((resolve) => {
  1153. GM_xmlhttpRequest({
  1154. method: "GET",
  1155. url: url,
  1156. onload: function (response) {
  1157. const res = HNTOOL.strToJson((response || {}).responseText)
  1158. resolve(res);
  1159. }
  1160. });
  1161. })
  1162. },
  1163.  
  1164.  
  1165. userInfo: function (mid) {
  1166.  
  1167. Ajax.get({
  1168. url: BILIBLI_PATH.api + '/x/space/acc/info',
  1169. queryStringsObj: {
  1170. mid: mid
  1171. },
  1172. hasCookies: true,
  1173. success: responseText => {
  1174.  
  1175. var json = JSON.parse(responseText);
  1176.  
  1177. if (json.code != 0) {
  1178.  
  1179.  
  1180. }
  1181. }
  1182. });
  1183.  
  1184. },
  1185.  
  1186. sendQmsg: function (key, msg) {
  1187.  
  1188. GM_xmlhttpRequest({
  1189. method: "GET",
  1190. url: `https://qmsg.zendee.cn/send/${key}?msg=${msg}`,
  1191. onload: function (response) {
  1192.  
  1193. let json = JSON.parse(response.response);
  1194. if (json.code == 0) {
  1195.  
  1196. javaex.tip({
  1197. content: "自动动态中奖提醒成功!" + json.reason,
  1198. type: "success"
  1199. });
  1200. } else {
  1201. console.log("自动动态中奖提醒失败!" + json.reason);
  1202. javaex.tip({
  1203. content: "自动动态中奖提醒失败!" + json.reason,
  1204. type: "error"
  1205. });
  1206. }
  1207.  
  1208. }
  1209. });
  1210.  
  1211. },
  1212.  
  1213. /**
  1214. * 批量关注和拉黑 batchModify
  1215. *
  1216. * https://api.bilibili.com/x/relation/batch/modify
  1217. * @param uid
  1218. */
  1219.  
  1220. batchModify: function (uids, act) {
  1221.  
  1222.  
  1223. Ajax.post({
  1224. url: BILIBLI_PATH.api + "/x/relation/batch/modify",
  1225. hasCookies: true,
  1226. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1227. data: {
  1228.  
  1229. "fids": uids,
  1230. "act": act == undefined ? 1 : act, //1 关注 5 拉黑
  1231. "re_src": 151,
  1232. csrf: Live_info.csrf_token,
  1233. },
  1234. success: responseText => {
  1235.  
  1236. let json = JSON.parse(responseText);
  1237.  
  1238. if (/^{"code":0/.test(responseText)) {
  1239.  
  1240. javaex.tip({
  1241. content: `执行成功!---失败(`+json.data.failed_fids.length+`/15)名单:` + json.data.failed_fids,
  1242. type: "success"
  1243. });
  1244.  
  1245. } else {
  1246. javaex.tip({
  1247. content: "关注失败!" + json.message,
  1248. type: "error"
  1249. });
  1250. }
  1251. }
  1252. })
  1253. },
  1254.  
  1255.  
  1256. /**
  1257. * //https://api.bilibili.com/x/relation/modify
  1258. *
  1259. * @param UID
  1260. */
  1261. disUserByUid: function (vmid) {
  1262.  
  1263. Ajax.post({
  1264. url: BILIBLI_PATH.api + '/x/relation/modify',
  1265. data: {
  1266. fid: parseInt(vmid),
  1267. re_src: 11,
  1268. act: 5,
  1269. jsonp: "jsonp",
  1270. csrf: Live_info.csrf_token,
  1271. },
  1272. hasCookies: true,
  1273. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1274. success: responseText => {
  1275.  
  1276. var json = JSON.parse(responseText);
  1277.  
  1278. if (json.code != 0) {
  1279.  
  1280. console.log("拉黑用户失败uid:" + vmid + " 错误信息" + json.message);
  1281. javaex.tip({
  1282. content: "拉黑用户失败uid:" + vmid + " 错误信息" + json.message,
  1283. type: "error"
  1284. });
  1285.  
  1286. } else {
  1287. console.log("拉黑用户成功 uid:" + vmid);
  1288. javaex.tip({
  1289. content: "拉黑用户成功 uid:" + vmid,
  1290. type: "success"
  1291. });
  1292. }
  1293. }
  1294. });
  1295.  
  1296. },
  1297. /**
  1298. * http://api.bilibili.com/x/web-interface/view
  1299. * @param BV
  1300. * 心跳间隔15秒
  1301. */
  1302. playOneVideo: function (BV, MID) {
  1303.  
  1304. //1.调用点击播放接口 https://api.bilibili.com/x/click-interface/click/web/h5
  1305. Ajax.post({
  1306. url: BILIBLI_PATH.api + "/x/click-interface/click/web/h5",
  1307. hasCookies: true,
  1308. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1309. data: {
  1310.  
  1311. "bvid": BV,
  1312. "part": 1,
  1313. "mid": Live_info.uid,
  1314. "lv": 2,
  1315. "jsonp": "jsonp",
  1316. "type": 3,
  1317. "sub_type": 0
  1318. },
  1319. success: responseText => {
  1320.  
  1321. let json = JSON.parse(responseText);
  1322.  
  1323. if (/^{"code":0/.test(responseText)) {
  1324. //发送一次心跳
  1325. HNAPI.sendHeartbeat(BV, MID);
  1326.  
  1327. } else {
  1328. javaex.tip({
  1329. content: "视频" + data.bvid + "播放失败!" + json.message,
  1330. type: "error"
  1331. });
  1332. }
  1333. }
  1334. })
  1335.  
  1336.  
  1337. },
  1338.  
  1339. //上报视频播放心跳(web端)
  1340. /**
  1341. * http://api.bilibili.com/x/click-interface/web/heartbeat
  1342. * @param json
  1343. */
  1344. sendHeartbeat: function (bvid, MID) {
  1345.  
  1346. Ajax.post({
  1347. url: BILIBLI_PATH.api + "/x/click-interface/web/heartbeat",
  1348. hasCookies: true,
  1349. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1350. //aid=756988764&bvid=BV1wr4y1P782&cid=304166326&page=1
  1351. data: {
  1352. "bvid": bvid,
  1353. "type": 3,
  1354. "dt": 2,
  1355. "played_time": HNTOOL.random(12, 40),
  1356. "realtime": HNTOOL.random(12, 40),
  1357. "play_type": 0
  1358. },
  1359. success: responseText => {
  1360.  
  1361. if (/^{"code":0/.test(responseText) && MID != BiliData.author_uid) {
  1362.  
  1363. javaex.tip({
  1364. content: "视频BV" + bvid + "播放一次!",
  1365. type: "success"
  1366. });
  1367. }
  1368. }
  1369. })
  1370.  
  1371. },
  1372.  
  1373. //获取up所有投稿视频
  1374. /**
  1375. * https://api.bilibili.com/x/space/arc/search?mid=99439379&ps=30&tid=0&pn=1&keyword=&order=pubdate&jsonp=jsonp
  1376. * @param mid
  1377. */
  1378. getUpAllBV: function (mid, pn, ps) {
  1379. ps = (ps === undefined ? 30 : ps); // a默认值为1
  1380. Ajax.get({
  1381. url: BILIBLI_PATH.api + '/x/space/arc/search',
  1382. queryStringsObj: {
  1383. mid: mid,
  1384. tid: 0,
  1385. order: 'pubdate',
  1386. jsonp: 'jsonp',
  1387. pn: pn,
  1388. ps: ps
  1389. },
  1390. hasCookies: true,
  1391. success: responseText => {
  1392.  
  1393. var json = JSON.parse(responseText);
  1394.  
  1395. if (json.code != 0) {
  1396.  
  1397. javaex.tip({
  1398. content: "获取up所有投稿视频失败!" + json.message,
  1399. type: "success"
  1400. });
  1401.  
  1402. } else {
  1403. BiliData.BVList = json.data.list.vlist;
  1404.  
  1405. }
  1406. }
  1407. });
  1408.  
  1409. },
  1410.  
  1411.  
  1412. /**
  1413. *
  1414. * @param path
  1415. * @param data
  1416. * @param saveObj
  1417. * @param Func
  1418. */
  1419. publicGet: function (path, queryStringsObj) {
  1420.  
  1421. if (typeof (queryStringsObj) != "undefined") {
  1422. queryStringsObj = {};
  1423. }
  1424. Ajax.get({
  1425. url: BILIBLI_PATH.api + path,
  1426. queryStringsObj: queryStringsObj,
  1427. hasCookies: true,
  1428. success: responseText => {
  1429.  
  1430. let json = JSON.parse(responseText);
  1431. if (chackCode(json.code) && json.code == 0) {
  1432.  
  1433. return json.data;
  1434. }
  1435.  
  1436. return false;
  1437.  
  1438. }
  1439. })
  1440.  
  1441. },
  1442.  
  1443. /**
  1444. * 导航栏用户信息
  1445. */
  1446. getUserNav: async function () {
  1447.  
  1448. GM_xmlhttpRequest({
  1449. method: "GET",
  1450. url: BILIBLI_PATH.api + "/x/web-interface/nav",
  1451. //timeout:3000,
  1452. onload: function (response) {
  1453.  
  1454. let json = JSON.parse(response.response);
  1455. console.log(json);
  1456. BiliData.login_code = json.code;
  1457. BiliData.login_message = json.message;
  1458. BiliData.LoginData = json.data;
  1459.  
  1460. }
  1461. });
  1462.  
  1463. },
  1464.  
  1465. /**
  1466. * 获取某up详细信息
  1467. * http://api.bilibili.com/x/web-interface/card
  1468. */
  1469. getUpCard: function (mid) {
  1470.  
  1471. Ajax.get({
  1472. url: BILIBLI_PATH.api + '/x/web-interface/card',
  1473. queryStringsObj: {
  1474. mid: mid,
  1475. photo: false
  1476. },
  1477. hasCookies: true,
  1478. success: responseText => {
  1479.  
  1480. var json = JSON.parse(responseText);
  1481.  
  1482. if (json.code != 0) {
  1483.  
  1484. javaex.tip({
  1485. content: "查询失败!" + json.message,
  1486. type: "success"
  1487. });
  1488. return false;
  1489. } else {
  1490. BiliData.upCard = json;
  1491.  
  1492. }
  1493.  
  1494.  
  1495. }
  1496. })
  1497.  
  1498. },
  1499.  
  1500. /**
  1501. *
  1502. * @param uid 用户uid
  1503. * @param ps 每页视频个数 默认30个
  1504. * @param pn 第几页
  1505. */
  1506. getUpAllVideo: function (uid, ps, pn) {
  1507.  
  1508. },
  1509. getChallenge: async function () {
  1510.  
  1511.  
  1512. },
  1513. /**
  1514. * 硬币记录
  1515. * @returns {Promise<void>}
  1516. */
  1517. getCoinLog: async function () {
  1518.  
  1519. GM_xmlhttpRequest({
  1520. method: "GET",
  1521. url: BILIBLI_PATH.api + "/x/member/web/coin/log",
  1522. //url: "http://api.bilibili.com/x/member/web/coin/log",
  1523. onload: function (response) {
  1524.  
  1525. let json = JSON.parse(response.response);
  1526. if (json.code == 0) {
  1527.  
  1528. console.log("硬币记录" + json);
  1529. BiliData.CoinLog = json.data;
  1530.  
  1531. return true;
  1532. }
  1533.  
  1534. }
  1535. });
  1536. },
  1537. /**
  1538. * 未读消息数 http://api.bilibili.com/x/msgfeed/unread
  1539. * @returns {Promise<void>}
  1540. */
  1541. getUnread: async function () {
  1542.  
  1543. Ajax.get({
  1544. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1545. hasCookies: true,
  1546. success: responseText => {
  1547.  
  1548. let json = JSON.parse(responseText);
  1549. if (chackCode(json.code) && json.code == 0) {
  1550.  
  1551. BiliData.Unread = json.data;
  1552. showUnreadMsg();
  1553. }
  1554.  
  1555. return false;
  1556.  
  1557. }
  1558. })
  1559.  
  1560. /* GM_xmlhttpRequest({
  1561. method: "GET",
  1562. url: BILIBLI_PATH.api + "/x/msgfeed/unread",
  1563. onload: function (response) {
  1564.  
  1565. let json = JSON.parse(response.response);
  1566.  
  1567. if (chackCode(json.code) && json.code == 0) {
  1568.  
  1569. BiliData.Unread = json.code;
  1570. showUnreadMsg();
  1571.  
  1572. }
  1573.  
  1574. }
  1575. });*/
  1576. },
  1577. /**
  1578. *
  1579. * @param type reply:回复我的 at @我的
  1580. */
  1581. getMsgfeed: function (type) {
  1582. Ajax.get({
  1583. url: BILIBLI_PATH.api + '/x/msgfeed/' + type,
  1584. queryStringsObj: {
  1585. build: 0,
  1586. mobi_app: 'web'
  1587. },
  1588. hasCookies: true,
  1589. success: responseText => {
  1590.  
  1591. var json = JSON.parse(responseText);
  1592.  
  1593. if (json.code != 0 || !json.data.cursor.is_end || json.data.items == null) {
  1594. return false;
  1595. } else {
  1596. chackAtMsg(json.data.items);
  1597.  
  1598. return true;
  1599. }
  1600.  
  1601.  
  1602. }
  1603. })
  1604.  
  1605. },
  1606.  
  1607. /** 未读消息数 http://api.bilibili.com/x/space/arc/search?mid=99439379&pn=1&ps=5
  1608. * @returns {Promise<void>}
  1609. */
  1610. getUnrewad: async function () {
  1611.  
  1612. GM_xmlhttpRequest({
  1613. method: "GET",
  1614. data: {
  1615. "mid": 99439379,
  1616. "pn": 1,
  1617. "ps": 5,
  1618. },
  1619. url: BILIBLI_PATH.api + "/x/space/arc/search",
  1620. onload: function (response) {
  1621.  
  1622. let json = JSON.parse(response.response);
  1623. if (json.code == 0) {
  1624.  
  1625. BiliData.Video = json.data;
  1626. console.log("未读消息数" + json);
  1627. }
  1628.  
  1629. }
  1630. });
  1631. },
  1632.  
  1633. /** 动态评论区点赞 https://api.bilibili.com/x/v2/reply/action
  1634. * @param {number} oid
  1635. * @param {nbumber} rpid
  1636. * @param {number} action
  1637. * @returns {Promise<void>}
  1638. * type: 11
  1639. * ordering: heat
  1640. * jsonp: jsonp
  1641. * csrf: 54a******* CSRF Token(位于cookie)
  1642. */
  1643.  
  1644. likeInDynamicComments: async function (oid, rpid, action) {
  1645.  
  1646.  
  1647. Ajax.post({
  1648. url: BILIBLI_PATH.api + "/x/v2/reply/action",
  1649. hasCookies: true,
  1650. dataType: 'application/x-www-form-urlencoded; charset=UTF-8',
  1651. data: {
  1652. "oid": oid,
  1653. "type": 11,
  1654. "rpid": rpid,
  1655. "action": action,
  1656. "ordering": "heat",
  1657. "jsonp": "jsonp",
  1658. "csrf": Live_info.csrf_token,
  1659. },
  1660. success: responseText => {
  1661.  
  1662. if (/^{"code":0/.test(responseText)) {
  1663.  
  1664. BiliData.replyAction = JSON.parse(responseText);
  1665. console.log("点赞成功!" + responseText);
  1666. }
  1667. }
  1668. })
  1669.  
  1670. }
  1671.  
  1672.  
  1673. }
  1674.  
  1675. /*-----------------------------------------------常用工具函数--------------------------------------------------*/
  1676.  
  1677.  
  1678. let HNTOOL = {
  1679. /**
  1680. * s数组去重并排序
  1681. */
  1682.  
  1683. arrUnique: function (ary) {
  1684.  
  1685. let obj = {};
  1686. for (let i = 0; i < ary.length; i++) {//this 指向方法.前的对象ary
  1687. let item = ary[i]
  1688. obj.hasOwnProperty(item) ? (ary[i] = ary[ary.length - 1], ary.pop(), i--) : obj[item] = item
  1689. } //判断对象obj中是否有item元素,如果有 让当前元素等于数组最后一个元素,删除最后一个元素
  1690. // 如果没有 将这个元素添加到对象中
  1691. ary.sort((a, b) => {
  1692. return a - b
  1693. })// 数组去重后 按升序排列
  1694. obj = null;
  1695. return ary;
  1696.  
  1697. },
  1698.  
  1699. split_array: function (arr, len) {
  1700.  
  1701. let arr_length = arr.length;
  1702. let newArr = [];
  1703. for (let i = 0; i < arr_length; i += len) {
  1704. newArr.push(arr.slice(i, i + len));
  1705. }
  1706. return newArr;
  1707. },
  1708. strToJson: function (params) {
  1709. const isJSON = (str => {
  1710. if (typeof str === 'string') {
  1711. try {
  1712. const obj = JSON.parse(str);
  1713. return typeof obj === 'object' ? obj : false
  1714. } catch (_) {
  1715. console.log(str);
  1716. return false;
  1717. }
  1718. } else {
  1719. console.log(`${str}\nIt is not a string!`);
  1720. return false;
  1721. }
  1722. })(params);
  1723. return isJSON ? isJSON : {}
  1724. },
  1725.  
  1726. chackAtMsg: function () {
  1727.  
  1728. let config = HNTOOL.getConfig();
  1729. if (config.qmsg_checked == true && config.qmsg_key) {
  1730.  
  1731. document.getElementById("getAtMsg").click();
  1732.  
  1733. }
  1734.  
  1735. },
  1736.  
  1737. cssChecked: function (id, dom) {
  1738.  
  1739. dom == true ? $(id).attr("checked", true) : $(id).removeProp("checked");
  1740.  
  1741.  
  1742. },
  1743. getConfig: function () {
  1744.  
  1745. let CONFIG = JSON.parse(localStorage.getItem(`HN_SETUP_CONFIG`));
  1746.  
  1747. if (CONFIG == null) {
  1748. CONFIG = HN_SETUP_CONFIG;
  1749. }
  1750.  
  1751. return CONFIG;
  1752. },
  1753.  
  1754. /**
  1755. * 获取cookie 中某个键对应的值
  1756. * @param name
  1757. */
  1758.  
  1759. getCookie: function (name) {
  1760. let arr = document.cookie.match(new RegExp("(^| )" + name + "=([^;]*)(;|$)"));
  1761. if (arr != null) return unescape(arr[2]);
  1762. return false;
  1763. },
  1764. /**
  1765. * 得到一个字符串数组的中随机一个
  1766. * @param {List} list
  1767. */
  1768. getRandomWordOfList: function (list) {
  1769. var L = list.length;
  1770. var i = Math.ceil(Math.random() * L);
  1771.  
  1772. return list[i];
  1773. },
  1774. random: function (min, max) {
  1775.  
  1776. return Math.floor(Math.random() * (max - min)) + min;
  1777. },
  1778.  
  1779. Sleep: function (ms) {
  1780. return new Promise(resolve => setTimeout(() => resolve('sleep'), ms));
  1781. }
  1782.  
  1783. }
  1784.  
  1785. let errorMsg = {
  1786. "-1": "应用程序不存在或已被封禁!",
  1787. "-2": "Access Key错误!",
  1788. "-3": "API校验密匙错误!",
  1789. "-4": "调用方对该Method没有权限!",
  1790. "-101": "账号未登录!",
  1791. "-102": "账号被封停!",
  1792. "-103": "积分不足!",
  1793. "-104": "硬币不足!",
  1794. "-105": "验证码错误!",
  1795. "-106": "账号非正式会员或在适应期!",
  1796. "-107": "应用不存在或者被封禁!",
  1797. "-108": "未绑定手机!",
  1798. "-109": "未知!",
  1799. "-110": "未绑定手机!",
  1800. "-111": "csrf 校验失败!",
  1801. "-112": "系统升级中!",
  1802. "-113": "账号尚未实名认证!",
  1803. "-114": "请先绑定手机!",
  1804. "-115": "请先完成实名认证!",
  1805. "-304": "木有改动!",
  1806. "-307": "撞车跳转!",
  1807. "-400": "请求错误!",
  1808. "-401": "未认证!",
  1809. "-403": "访问权限不足!",
  1810. "-404": "啥都木有!",
  1811. }
  1812.  
  1813. /*-----------------------------------------------CODE 统一检查--------------------------------------------------*/
  1814. /**
  1815. *
  1816. * @param code
  1817. * @constructor
  1818. */
  1819. let chackCode = function (code) {
  1820.  
  1821. let emsg = errorMsg[code + ""];
  1822. if (emsg != null) {
  1823. javaex.tip({content: emsg, type: "error"});
  1824.  
  1825. return false;
  1826. }
  1827.  
  1828. return true;
  1829. }
  1830.  
  1831.  
  1832. /*-----------------------------------------------localStorage封装 (本地存储信息)--------------------------------------------------*/
  1833. //javaex.setLocalStorage(key, value); var str = javaex.getLocalStorage(key); javaex.deleteLocalStorage(key);
  1834.  
  1835. /*window.onbeforeunload = function() {
  1836. if (!canLeavePage()) {
  1837. return ('确认离开当前页面吗?未保存的数据将会丢失!');
  1838. }
  1839. };*/
  1840.  
  1841.  
  1842. /**
  1843. * Ajax请求对象
  1844. */
  1845. const Ajax = (() => {
  1846. /**
  1847. * 检查options是否符合要求
  1848. * @param {object} options
  1849. * @returns {boolean}
  1850. */
  1851. function checkOptions(options) {
  1852. let result = false;
  1853. if (typeof options !== 'object') {
  1854. console.warn('类型错误: typeof Options !== Object');
  1855. return result;
  1856. } else {
  1857. if (typeof options.url !== 'string') {
  1858. console.warn('类型错误: typeof Link !== Strings');
  1859. return result;
  1860. } else {
  1861. const reg = /^https?:\/\/(?:\w+\.?)+(?:\/.*)*\/?$/i;
  1862. if (!reg.test(options.url)) {
  1863. console.warn('url字符串须为完整http链接');
  1864. return result;
  1865. }
  1866. result = true;
  1867. }
  1868. }
  1869. return result;
  1870. }
  1871.  
  1872. /**
  1873. * 对象转URL编码
  1874. * @param {object} data
  1875. */
  1876. function objToURLCode(data) {
  1877. var _result = [];
  1878. for (var key in data) {
  1879. var value = data[key];
  1880. if (value instanceof Array) {
  1881. value.forEach(function (_value) {
  1882. _result.push(key + "=" + _value);
  1883. });
  1884. } else {
  1885. _result.push(key + '=' + value);
  1886. }
  1887. }
  1888. return _result.join('&');
  1889. }
  1890.  
  1891. /**
  1892. * 请求
  1893. * @param {string} method
  1894. * @param {object} options
  1895. */
  1896. function request(method, options) {
  1897. if (checkOptions(options)) {
  1898. let xhr = new XMLHttpRequest();
  1899. const {url: _url, queryStringsObj, data, dataType, hasCookies} = options
  1900. , url = typeof queryStringsObj === 'object' ?
  1901. _url + '?' + objToURLCode(queryStringsObj) : _url;
  1902. switch (method) {
  1903. case 'GET':
  1904. xhr.open("GET", url);
  1905. break;
  1906. case 'POST':
  1907. xhr.open("POST", url);
  1908. xhr.setRequestHeader('Content-Type', dataType);
  1909. break;
  1910. default:
  1911. break;
  1912. }
  1913. if (hasCookies) xhr.withCredentials = true;
  1914. xhr.timeout = 3000;
  1915. xhr.addEventListener('load', () => {
  1916. if (xhr.status === 200) {
  1917. options.success(xhr.responseText)
  1918. } else {
  1919. console.error(`status:${xhr.status}`);
  1920. options.success(`{"code":${xhr.status},"msg":"频繁访问"}`);
  1921. }
  1922. })
  1923. xhr.addEventListener('error', () => {
  1924. console.error('ajax请求出错')
  1925. options.success('{"code":-1,"msg":"ajax请求出错"}');
  1926. })
  1927. xhr.addEventListener('timeout', () => {
  1928. console.error('请求超时')
  1929. options.success('{"code":-1,"msg":"请求超时"}');
  1930. })
  1931. switch (method) {
  1932. case 'GET':
  1933. xhr.send()
  1934. break;
  1935. case 'POST':
  1936. xhr.send((/urlencoded/.test(dataType)) ? objToURLCode(data) : data)
  1937. break;
  1938. default:
  1939. break;
  1940. }
  1941. }
  1942. }
  1943.  
  1944. return {
  1945. /**
  1946. * 发送Get请求
  1947. * @param {Object} options
  1948. */
  1949. get(options) {
  1950. request("GET", options);
  1951. },
  1952. /**
  1953. * 发送Post请求
  1954. * @param {object} options
  1955. */
  1956. post(options) {
  1957. request("POST", options);
  1958. }
  1959. }
  1960. })()