Bilibili 评论搜索

让 Bilibili 支持评论搜索。

  1. // ==UserScript==
  2. // @name Bilibili 评论搜索
  3. // @name:en Bilibili Comment Search
  4. // @name:zh Bilibili 评论搜索
  5. // @namespace npm/vite-plugin-monkey
  6. // @version 0.2.0
  7. // @author pacexy <pacexy@gmail.com>
  8. // @description 让 Bilibili 支持评论搜索。
  9. // @description:en Add comment searching support in Bilibili.
  10. // @description:zh 让 Bilibili 支持评论搜索。
  11. // @license MIT
  12. // @icon https://www.bilibili.com/favicon.ico
  13. // @homepage https://github.com/pacexy/userscript-bilibili-comment-search#readme
  14. // @homepageURL https://github.com/pacexy/userscript-bilibili-comment-search#readme
  15. // @source https://github.com/pacexy/userscript-bilibili-comment-search.git
  16. // @supportURL https://github.com/pacexy/userscript-bilibili-comment-search/issues
  17. // @match *://www.bilibili.com/video/av*
  18. // @match *://www.bilibili.com/bangumi/play/ep*
  19. // @match *://www.bilibili.com/bangumi/play/ss*
  20. // @match *://www.bilibili.com/video/BV*
  21. // @require https://cdn.jsdelivr.net/npm/react@18.2.0/umd/react.production.min.js
  22. // @require https://cdn.jsdelivr.net/npm/react-dom@18.2.0/umd/react-dom.production.min.js
  23. // ==/UserScript==
  24.  
  25. (e=>{const o=document.createElement("style");o.dataset.source="vite-plugin-monkey",o.textContent=e,document.head.append(o)})(" #comment-search-root{float:right}#comment-search-root button{margin-left:auto;border:none;padding:4px 8px;border-radius:4px}#comment-search-root dialog[open]{display:block}#comment-search-root dialog{display:none;width:800px;margin:auto;padding:1em;border-radius:8px;border:none;outline:none;overflow:hidden}#comment-search-root dialog .header{display:flex;align-items:center}#comment-search-root dialog .header h1{font-size:15px;color:var(--text1)}#comment-search-root dialog .header h1 span{color:var(--text3)}#comment-search-root dialog input{padding:5px 10px;border:1px solid var(--Ga1);border-radius:4px;background-color:var(--bg3);color:var(--text1);outline:none;width:100%;margin-top:20px}#comment-search-root dialog .note{color:var(--text3);margin:10px 0}#comment-search-root dialog .comment-tree{height:500px;overflow:auto;overscroll-behavior:contain}#comment-search-root .comment-item{display:flex}#comment-search-root .comment-item-avatar{border-radius:50%;background-color:var(--Ga1);margin-right:10px;flex-shrink:0}#comment-search-root .comment-item-username{font-size:12px;font-weight:700;margin-bottom:4px;color:#61666d;margin-right:12px}#comment-search-root .comment-item-message{font-size:14px;color:var(--text1)}#comment-search-root .comment-item-highlight{background-color:#f8eec2}#comment-search-root .comment-item-time{color:var(--text3);margin-top:4px} ");
  26.  
  27. (function (require$$0, require$$0$1) {
  28. 'use strict';
  29.  
  30. function getDefaultExportFromCjs(x) {
  31. return x && x.__esModule && Object.prototype.hasOwnProperty.call(x, "default") ? x["default"] : x;
  32. }
  33. var jsxRuntime = { exports: {} };
  34. var reactJsxRuntime_production_min = {};
  35. /**
  36. * @license React
  37. * react-jsx-runtime.production.min.js
  38. *
  39. * Copyright (c) Facebook, Inc. and its affiliates.
  40. *
  41. * This source code is licensed under the MIT license found in the
  42. * LICENSE file in the root directory of this source tree.
  43. */
  44. var f = require$$0, k = Symbol.for("react.element"), l = Symbol.for("react.fragment"), m$1 = Object.prototype.hasOwnProperty, n = f.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner, p = { key: true, ref: true, __self: true, __source: true };
  45. function q(c, a, g) {
  46. var b, d = {}, e = null, h = null;
  47. void 0 !== g && (e = "" + g);
  48. void 0 !== a.key && (e = "" + a.key);
  49. void 0 !== a.ref && (h = a.ref);
  50. for (b in a)
  51. m$1.call(a, b) && !p.hasOwnProperty(b) && (d[b] = a[b]);
  52. if (c && c.defaultProps)
  53. for (b in a = c.defaultProps, a)
  54. void 0 === d[b] && (d[b] = a[b]);
  55. return { $$typeof: k, type: c, key: e, ref: h, props: d, _owner: n.current };
  56. }
  57. reactJsxRuntime_production_min.Fragment = l;
  58. reactJsxRuntime_production_min.jsx = q;
  59. reactJsxRuntime_production_min.jsxs = q;
  60. {
  61. jsxRuntime.exports = reactJsxRuntime_production_min;
  62. }
  63. var jsxRuntimeExports = jsxRuntime.exports;
  64. var client = {};
  65. var m = require$$0$1;
  66. {
  67. client.createRoot = m.createRoot;
  68. client.hydrateRoot = m.hydrateRoot;
  69. }
  70. var main = { exports: {} };
  71. (function(module) {
  72. module.exports = /******/
  73. function(modules) {
  74. var installedModules = {};
  75. function __webpack_require__(moduleId) {
  76. if (installedModules[moduleId])
  77. return installedModules[moduleId].exports;
  78. var module2 = installedModules[moduleId] = {
  79. /******/
  80. exports: {},
  81. /******/
  82. id: moduleId,
  83. /******/
  84. loaded: false
  85. /******/
  86. };
  87. modules[moduleId].call(module2.exports, module2, module2.exports, __webpack_require__);
  88. module2.loaded = true;
  89. return module2.exports;
  90. }
  91. __webpack_require__.m = modules;
  92. __webpack_require__.c = installedModules;
  93. __webpack_require__.p = "";
  94. return __webpack_require__(0);
  95. }([
  96. /* 0 */
  97. /***/
  98. function(module2, exports, __webpack_require__) {
  99. module2.exports = __webpack_require__(1);
  100. },
  101. /* 1 */
  102. /***/
  103. function(module2, exports, __webpack_require__) {
  104. Object.defineProperty(exports, "__esModule", {
  105. value: true
  106. });
  107. function _interopRequireDefault(obj) {
  108. return obj && obj.__esModule ? obj : { "default": obj };
  109. }
  110. var _Highlighter = __webpack_require__(2);
  111. var _Highlighter2 = _interopRequireDefault(_Highlighter);
  112. exports["default"] = _Highlighter2["default"];
  113. module2.exports = exports["default"];
  114. },
  115. /* 2 */
  116. /***/
  117. function(module2, exports, __webpack_require__) {
  118. Object.defineProperty(exports, "__esModule", {
  119. value: true
  120. });
  121. var _extends = Object.assign || function(target) {
  122. for (var i = 1; i < arguments.length; i++) {
  123. var source = arguments[i];
  124. for (var key in source) {
  125. if (Object.prototype.hasOwnProperty.call(source, key)) {
  126. target[key] = source[key];
  127. }
  128. }
  129. }
  130. return target;
  131. };
  132. exports["default"] = Highlighter2;
  133. function _interopRequireDefault(obj) {
  134. return obj && obj.__esModule ? obj : { "default": obj };
  135. }
  136. function _objectWithoutProperties(obj, keys) {
  137. var target = {};
  138. for (var i in obj) {
  139. if (keys.indexOf(i) >= 0)
  140. continue;
  141. if (!Object.prototype.hasOwnProperty.call(obj, i))
  142. continue;
  143. target[i] = obj[i];
  144. }
  145. return target;
  146. }
  147. var _highlightWordsCore = __webpack_require__(3);
  148. var _propTypes = __webpack_require__(4);
  149. var _propTypes2 = _interopRequireDefault(_propTypes);
  150. var _react = __webpack_require__(14);
  151. var _memoizeOne = __webpack_require__(15);
  152. var _memoizeOne2 = _interopRequireDefault(_memoizeOne);
  153. Highlighter2.propTypes = {
  154. activeClassName: _propTypes2["default"].string,
  155. activeIndex: _propTypes2["default"].number,
  156. activeStyle: _propTypes2["default"].object,
  157. autoEscape: _propTypes2["default"].bool,
  158. className: _propTypes2["default"].string,
  159. findChunks: _propTypes2["default"].func,
  160. highlightClassName: _propTypes2["default"].oneOfType([_propTypes2["default"].object, _propTypes2["default"].string]),
  161. highlightStyle: _propTypes2["default"].object,
  162. highlightTag: _propTypes2["default"].oneOfType([_propTypes2["default"].node, _propTypes2["default"].func, _propTypes2["default"].string]),
  163. sanitize: _propTypes2["default"].func,
  164. searchWords: _propTypes2["default"].arrayOf(_propTypes2["default"].oneOfType([_propTypes2["default"].string, _propTypes2["default"].instanceOf(RegExp)])).isRequired,
  165. textToHighlight: _propTypes2["default"].string.isRequired,
  166. unhighlightTag: _propTypes2["default"].oneOfType([_propTypes2["default"].node, _propTypes2["default"].func, _propTypes2["default"].string]),
  167. unhighlightClassName: _propTypes2["default"].string,
  168. unhighlightStyle: _propTypes2["default"].object
  169. };
  170. function Highlighter2(_ref) {
  171. var _ref$activeClassName = _ref.activeClassName;
  172. var activeClassName = _ref$activeClassName === void 0 ? "" : _ref$activeClassName;
  173. var _ref$activeIndex = _ref.activeIndex;
  174. var activeIndex = _ref$activeIndex === void 0 ? -1 : _ref$activeIndex;
  175. var activeStyle = _ref.activeStyle;
  176. var autoEscape = _ref.autoEscape;
  177. var _ref$caseSensitive = _ref.caseSensitive;
  178. var caseSensitive = _ref$caseSensitive === void 0 ? false : _ref$caseSensitive;
  179. var className = _ref.className;
  180. var findChunks = _ref.findChunks;
  181. var _ref$highlightClassName = _ref.highlightClassName;
  182. var highlightClassName = _ref$highlightClassName === void 0 ? "" : _ref$highlightClassName;
  183. var _ref$highlightStyle = _ref.highlightStyle;
  184. var highlightStyle = _ref$highlightStyle === void 0 ? {} : _ref$highlightStyle;
  185. var _ref$highlightTag = _ref.highlightTag;
  186. var highlightTag = _ref$highlightTag === void 0 ? "mark" : _ref$highlightTag;
  187. var sanitize = _ref.sanitize;
  188. var searchWords = _ref.searchWords;
  189. var textToHighlight = _ref.textToHighlight;
  190. var _ref$unhighlightTag = _ref.unhighlightTag;
  191. var unhighlightTag = _ref$unhighlightTag === void 0 ? "span" : _ref$unhighlightTag;
  192. var _ref$unhighlightClassName = _ref.unhighlightClassName;
  193. var unhighlightClassName = _ref$unhighlightClassName === void 0 ? "" : _ref$unhighlightClassName;
  194. var unhighlightStyle = _ref.unhighlightStyle;
  195. var rest = _objectWithoutProperties(_ref, ["activeClassName", "activeIndex", "activeStyle", "autoEscape", "caseSensitive", "className", "findChunks", "highlightClassName", "highlightStyle", "highlightTag", "sanitize", "searchWords", "textToHighlight", "unhighlightTag", "unhighlightClassName", "unhighlightStyle"]);
  196. var chunks = (0, _highlightWordsCore.findAll)({
  197. autoEscape,
  198. caseSensitive,
  199. findChunks,
  200. sanitize,
  201. searchWords,
  202. textToHighlight
  203. });
  204. var HighlightTag = highlightTag;
  205. var highlightIndex = -1;
  206. var highlightClassNames = "";
  207. var highlightStyles = void 0;
  208. var lowercaseProps = function lowercaseProps2(object) {
  209. var mapped = {};
  210. for (var key in object) {
  211. mapped[key.toLowerCase()] = object[key];
  212. }
  213. return mapped;
  214. };
  215. var memoizedLowercaseProps = (0, _memoizeOne2["default"])(lowercaseProps);
  216. return (0, _react.createElement)("span", _extends({
  217. className
  218. }, rest, {
  219. children: chunks.map(function(chunk, index) {
  220. var text = textToHighlight.substr(chunk.start, chunk.end - chunk.start);
  221. if (chunk.highlight) {
  222. highlightIndex++;
  223. var highlightClass = void 0;
  224. if (typeof highlightClassName === "object") {
  225. if (!caseSensitive) {
  226. highlightClassName = memoizedLowercaseProps(highlightClassName);
  227. highlightClass = highlightClassName[text.toLowerCase()];
  228. } else {
  229. highlightClass = highlightClassName[text];
  230. }
  231. } else {
  232. highlightClass = highlightClassName;
  233. }
  234. var isActive = highlightIndex === +activeIndex;
  235. highlightClassNames = highlightClass + " " + (isActive ? activeClassName : "");
  236. highlightStyles = isActive === true && activeStyle != null ? Object.assign({}, highlightStyle, activeStyle) : highlightStyle;
  237. var props = {
  238. children: text,
  239. className: highlightClassNames,
  240. key: index,
  241. style: highlightStyles
  242. };
  243. if (typeof HighlightTag !== "string") {
  244. props.highlightIndex = highlightIndex;
  245. }
  246. return (0, _react.createElement)(HighlightTag, props);
  247. } else {
  248. return (0, _react.createElement)(unhighlightTag, {
  249. children: text,
  250. className: unhighlightClassName,
  251. key: index,
  252. style: unhighlightStyle
  253. });
  254. }
  255. })
  256. }));
  257. }
  258. module2.exports = exports["default"];
  259. },
  260. /* 3 */
  261. /***/
  262. function(module2, exports) {
  263. module2.exports = /******/
  264. function(modules) {
  265. var installedModules = {};
  266. function __webpack_require__(moduleId) {
  267. if (installedModules[moduleId])
  268. return installedModules[moduleId].exports;
  269. var module3 = installedModules[moduleId] = {
  270. /******/
  271. exports: {},
  272. /******/
  273. id: moduleId,
  274. /******/
  275. loaded: false
  276. /******/
  277. };
  278. modules[moduleId].call(module3.exports, module3, module3.exports, __webpack_require__);
  279. module3.loaded = true;
  280. return module3.exports;
  281. }
  282. __webpack_require__.m = modules;
  283. __webpack_require__.c = installedModules;
  284. __webpack_require__.p = "";
  285. return __webpack_require__(0);
  286. }([
  287. /* 0 */
  288. /***/
  289. function(module3, exports2, __webpack_require__) {
  290. module3.exports = __webpack_require__(1);
  291. },
  292. /* 1 */
  293. /***/
  294. function(module3, exports2, __webpack_require__) {
  295. Object.defineProperty(exports2, "__esModule", {
  296. value: true
  297. });
  298. var _utils = __webpack_require__(2);
  299. Object.defineProperty(exports2, "combineChunks", {
  300. enumerable: true,
  301. get: function get() {
  302. return _utils.combineChunks;
  303. }
  304. });
  305. Object.defineProperty(exports2, "fillInChunks", {
  306. enumerable: true,
  307. get: function get() {
  308. return _utils.fillInChunks;
  309. }
  310. });
  311. Object.defineProperty(exports2, "findAll", {
  312. enumerable: true,
  313. get: function get() {
  314. return _utils.findAll;
  315. }
  316. });
  317. Object.defineProperty(exports2, "findChunks", {
  318. enumerable: true,
  319. get: function get() {
  320. return _utils.findChunks;
  321. }
  322. });
  323. },
  324. /* 2 */
  325. /***/
  326. function(module3, exports2) {
  327. Object.defineProperty(exports2, "__esModule", {
  328. value: true
  329. });
  330. exports2.findAll = function findAll(_ref) {
  331. var autoEscape = _ref.autoEscape, _ref$caseSensitive = _ref.caseSensitive, caseSensitive = _ref$caseSensitive === void 0 ? false : _ref$caseSensitive, _ref$findChunks = _ref.findChunks, findChunks = _ref$findChunks === void 0 ? defaultFindChunks : _ref$findChunks, sanitize = _ref.sanitize, searchWords = _ref.searchWords, textToHighlight = _ref.textToHighlight;
  332. return fillInChunks({
  333. chunksToHighlight: combineChunks({
  334. chunks: findChunks({
  335. autoEscape,
  336. caseSensitive,
  337. sanitize,
  338. searchWords,
  339. textToHighlight
  340. })
  341. }),
  342. totalLength: textToHighlight ? textToHighlight.length : 0
  343. });
  344. };
  345. var combineChunks = exports2.combineChunks = function combineChunks2(_ref2) {
  346. var chunks = _ref2.chunks;
  347. chunks = chunks.sort(function(first, second) {
  348. return first.start - second.start;
  349. }).reduce(function(processedChunks, nextChunk) {
  350. if (processedChunks.length === 0) {
  351. return [nextChunk];
  352. } else {
  353. var prevChunk = processedChunks.pop();
  354. if (nextChunk.start <= prevChunk.end) {
  355. var endIndex = Math.max(prevChunk.end, nextChunk.end);
  356. processedChunks.push({ start: prevChunk.start, end: endIndex });
  357. } else {
  358. processedChunks.push(prevChunk, nextChunk);
  359. }
  360. return processedChunks;
  361. }
  362. }, []);
  363. return chunks;
  364. };
  365. var defaultFindChunks = function defaultFindChunks2(_ref3) {
  366. var autoEscape = _ref3.autoEscape, caseSensitive = _ref3.caseSensitive, _ref3$sanitize = _ref3.sanitize, sanitize = _ref3$sanitize === void 0 ? identity : _ref3$sanitize, searchWords = _ref3.searchWords, textToHighlight = _ref3.textToHighlight;
  367. textToHighlight = sanitize(textToHighlight);
  368. return searchWords.filter(function(searchWord) {
  369. return searchWord;
  370. }).reduce(function(chunks, searchWord) {
  371. searchWord = sanitize(searchWord);
  372. if (autoEscape) {
  373. searchWord = escapeRegExpFn(searchWord);
  374. }
  375. var regex = new RegExp(searchWord, caseSensitive ? "g" : "gi");
  376. var match = void 0;
  377. while (match = regex.exec(textToHighlight)) {
  378. var start = match.index;
  379. var end = regex.lastIndex;
  380. if (end > start) {
  381. chunks.push({ start, end });
  382. }
  383. if (match.index == regex.lastIndex) {
  384. regex.lastIndex++;
  385. }
  386. }
  387. return chunks;
  388. }, []);
  389. };
  390. exports2.findChunks = defaultFindChunks;
  391. var fillInChunks = exports2.fillInChunks = function fillInChunks2(_ref4) {
  392. var chunksToHighlight = _ref4.chunksToHighlight, totalLength = _ref4.totalLength;
  393. var allChunks = [];
  394. var append = function append2(start, end, highlight) {
  395. if (end - start > 0) {
  396. allChunks.push({
  397. start,
  398. end,
  399. highlight
  400. });
  401. }
  402. };
  403. if (chunksToHighlight.length === 0) {
  404. append(0, totalLength, false);
  405. } else {
  406. var lastIndex = 0;
  407. chunksToHighlight.forEach(function(chunk) {
  408. append(lastIndex, chunk.start, false);
  409. append(chunk.start, chunk.end, true);
  410. lastIndex = chunk.end;
  411. });
  412. append(lastIndex, totalLength, false);
  413. }
  414. return allChunks;
  415. };
  416. function identity(value) {
  417. return value;
  418. }
  419. function escapeRegExpFn(str) {
  420. return str.replace(/[\-\[\]\/\{\}\(\)\*\+\?\.\\\^\$\|]/g, "\\$&");
  421. }
  422. }
  423. /******/
  424. ]);
  425. },
  426. /* 4 */
  427. /***/
  428. function(module2, exports, __webpack_require__) {
  429. (function(process) {
  430. {
  431. module2.exports = __webpack_require__(13)();
  432. }
  433. }).call(exports, __webpack_require__(5));
  434. },
  435. /* 5 */
  436. /***/
  437. function(module2, exports) {
  438. var process = module2.exports = {};
  439. var cachedSetTimeout;
  440. var cachedClearTimeout;
  441. function defaultSetTimout() {
  442. throw new Error("setTimeout has not been defined");
  443. }
  444. function defaultClearTimeout() {
  445. throw new Error("clearTimeout has not been defined");
  446. }
  447. (function() {
  448. try {
  449. if (typeof setTimeout === "function") {
  450. cachedSetTimeout = setTimeout;
  451. } else {
  452. cachedSetTimeout = defaultSetTimout;
  453. }
  454. } catch (e) {
  455. cachedSetTimeout = defaultSetTimout;
  456. }
  457. try {
  458. if (typeof clearTimeout === "function") {
  459. cachedClearTimeout = clearTimeout;
  460. } else {
  461. cachedClearTimeout = defaultClearTimeout;
  462. }
  463. } catch (e) {
  464. cachedClearTimeout = defaultClearTimeout;
  465. }
  466. })();
  467. function runTimeout(fun) {
  468. if (cachedSetTimeout === setTimeout) {
  469. return setTimeout(fun, 0);
  470. }
  471. if ((cachedSetTimeout === defaultSetTimout || !cachedSetTimeout) && setTimeout) {
  472. cachedSetTimeout = setTimeout;
  473. return setTimeout(fun, 0);
  474. }
  475. try {
  476. return cachedSetTimeout(fun, 0);
  477. } catch (e) {
  478. try {
  479. return cachedSetTimeout.call(null, fun, 0);
  480. } catch (e2) {
  481. return cachedSetTimeout.call(this, fun, 0);
  482. }
  483. }
  484. }
  485. function runClearTimeout(marker) {
  486. if (cachedClearTimeout === clearTimeout) {
  487. return clearTimeout(marker);
  488. }
  489. if ((cachedClearTimeout === defaultClearTimeout || !cachedClearTimeout) && clearTimeout) {
  490. cachedClearTimeout = clearTimeout;
  491. return clearTimeout(marker);
  492. }
  493. try {
  494. return cachedClearTimeout(marker);
  495. } catch (e) {
  496. try {
  497. return cachedClearTimeout.call(null, marker);
  498. } catch (e2) {
  499. return cachedClearTimeout.call(this, marker);
  500. }
  501. }
  502. }
  503. var queue = [];
  504. var draining = false;
  505. var currentQueue;
  506. var queueIndex = -1;
  507. function cleanUpNextTick() {
  508. if (!draining || !currentQueue) {
  509. return;
  510. }
  511. draining = false;
  512. if (currentQueue.length) {
  513. queue = currentQueue.concat(queue);
  514. } else {
  515. queueIndex = -1;
  516. }
  517. if (queue.length) {
  518. drainQueue();
  519. }
  520. }
  521. function drainQueue() {
  522. if (draining) {
  523. return;
  524. }
  525. var timeout = runTimeout(cleanUpNextTick);
  526. draining = true;
  527. var len = queue.length;
  528. while (len) {
  529. currentQueue = queue;
  530. queue = [];
  531. while (++queueIndex < len) {
  532. if (currentQueue) {
  533. currentQueue[queueIndex].run();
  534. }
  535. }
  536. queueIndex = -1;
  537. len = queue.length;
  538. }
  539. currentQueue = null;
  540. draining = false;
  541. runClearTimeout(timeout);
  542. }
  543. process.nextTick = function(fun) {
  544. var args = new Array(arguments.length - 1);
  545. if (arguments.length > 1) {
  546. for (var i = 1; i < arguments.length; i++) {
  547. args[i - 1] = arguments[i];
  548. }
  549. }
  550. queue.push(new Item(fun, args));
  551. if (queue.length === 1 && !draining) {
  552. runTimeout(drainQueue);
  553. }
  554. };
  555. function Item(fun, array) {
  556. this.fun = fun;
  557. this.array = array;
  558. }
  559. Item.prototype.run = function() {
  560. this.fun.apply(null, this.array);
  561. };
  562. process.title = "browser";
  563. process.browser = true;
  564. process.env = {};
  565. process.argv = [];
  566. process.version = "";
  567. process.versions = {};
  568. function noop() {
  569. }
  570. process.on = noop;
  571. process.addListener = noop;
  572. process.once = noop;
  573. process.off = noop;
  574. process.removeListener = noop;
  575. process.removeAllListeners = noop;
  576. process.emit = noop;
  577. process.prependListener = noop;
  578. process.prependOnceListener = noop;
  579. process.listeners = function(name2) {
  580. return [];
  581. };
  582. process.binding = function(name2) {
  583. throw new Error("process.binding is not supported");
  584. };
  585. process.cwd = function() {
  586. return "/";
  587. };
  588. process.chdir = function(dir) {
  589. throw new Error("process.chdir is not supported");
  590. };
  591. process.umask = function() {
  592. return 0;
  593. };
  594. },
  595. /* 6 */
  596. /***/
  597. function(module2, exports, __webpack_require__) {
  598. (function(process) {
  599. var emptyFunction = __webpack_require__(7);
  600. var invariant = __webpack_require__(8);
  601. var warning = __webpack_require__(9);
  602. var assign = __webpack_require__(10);
  603. var ReactPropTypesSecret = __webpack_require__(11);
  604. var checkPropTypes = __webpack_require__(12);
  605. module2.exports = function(isValidElement, throwOnDirectAccess) {
  606. var ITERATOR_SYMBOL = typeof Symbol === "function" && Symbol.iterator;
  607. var FAUX_ITERATOR_SYMBOL = "@@iterator";
  608. function getIteratorFn(maybeIterable) {
  609. var iteratorFn = maybeIterable && (ITERATOR_SYMBOL && maybeIterable[ITERATOR_SYMBOL] || maybeIterable[FAUX_ITERATOR_SYMBOL]);
  610. if (typeof iteratorFn === "function") {
  611. return iteratorFn;
  612. }
  613. }
  614. var ANONYMOUS = "<<anonymous>>";
  615. var ReactPropTypes = {
  616. array: createPrimitiveTypeChecker("array"),
  617. bool: createPrimitiveTypeChecker("boolean"),
  618. func: createPrimitiveTypeChecker("function"),
  619. number: createPrimitiveTypeChecker("number"),
  620. object: createPrimitiveTypeChecker("object"),
  621. string: createPrimitiveTypeChecker("string"),
  622. symbol: createPrimitiveTypeChecker("symbol"),
  623. any: createAnyTypeChecker(),
  624. arrayOf: createArrayOfTypeChecker,
  625. element: createElementTypeChecker(),
  626. instanceOf: createInstanceTypeChecker,
  627. node: createNodeChecker(),
  628. objectOf: createObjectOfTypeChecker,
  629. oneOf: createEnumTypeChecker,
  630. oneOfType: createUnionTypeChecker,
  631. shape: createShapeTypeChecker,
  632. exact: createStrictShapeTypeChecker
  633. };
  634. function is(x, y) {
  635. if (x === y) {
  636. return x !== 0 || 1 / x === 1 / y;
  637. } else {
  638. return x !== x && y !== y;
  639. }
  640. }
  641. function PropTypeError(message) {
  642. this.message = message;
  643. this.stack = "";
  644. }
  645. PropTypeError.prototype = Error.prototype;
  646. function createChainableTypeChecker(validate) {
  647. function checkType(isRequired, props, propName, componentName, location, propFullName, secret) {
  648. componentName = componentName || ANONYMOUS;
  649. propFullName = propFullName || propName;
  650. if (secret !== ReactPropTypesSecret) {
  651. if (throwOnDirectAccess) {
  652. invariant(
  653. false,
  654. "Calling PropTypes validators directly is not supported by the `prop-types` package. Use `PropTypes.checkPropTypes()` to call them. Read more at http://fb.me/use-check-prop-types"
  655. );
  656. }
  657. }
  658. if (props[propName] == null) {
  659. if (isRequired) {
  660. if (props[propName] === null) {
  661. return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required " + ("in `" + componentName + "`, but its value is `null`."));
  662. }
  663. return new PropTypeError("The " + location + " `" + propFullName + "` is marked as required in " + ("`" + componentName + "`, but its value is `undefined`."));
  664. }
  665. return null;
  666. } else {
  667. return validate(props, propName, componentName, location, propFullName);
  668. }
  669. }
  670. var chainedCheckType = checkType.bind(null, false);
  671. chainedCheckType.isRequired = checkType.bind(null, true);
  672. return chainedCheckType;
  673. }
  674. function createPrimitiveTypeChecker(expectedType) {
  675. function validate(props, propName, componentName, location, propFullName, secret) {
  676. var propValue = props[propName];
  677. var propType = getPropType(propValue);
  678. if (propType !== expectedType) {
  679. var preciseType = getPreciseType(propValue);
  680. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + preciseType + "` supplied to `" + componentName + "`, expected ") + ("`" + expectedType + "`."));
  681. }
  682. return null;
  683. }
  684. return createChainableTypeChecker(validate);
  685. }
  686. function createAnyTypeChecker() {
  687. return createChainableTypeChecker(emptyFunction.thatReturnsNull);
  688. }
  689. function createArrayOfTypeChecker(typeChecker) {
  690. function validate(props, propName, componentName, location, propFullName) {
  691. if (typeof typeChecker !== "function") {
  692. return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside arrayOf.");
  693. }
  694. var propValue = props[propName];
  695. if (!Array.isArray(propValue)) {
  696. var propType = getPropType(propValue);
  697. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an array."));
  698. }
  699. for (var i = 0; i < propValue.length; i++) {
  700. var error = typeChecker(propValue, i, componentName, location, propFullName + "[" + i + "]", ReactPropTypesSecret);
  701. if (error instanceof Error) {
  702. return error;
  703. }
  704. }
  705. return null;
  706. }
  707. return createChainableTypeChecker(validate);
  708. }
  709. function createElementTypeChecker() {
  710. function validate(props, propName, componentName, location, propFullName) {
  711. var propValue = props[propName];
  712. if (!isValidElement(propValue)) {
  713. var propType = getPropType(propValue);
  714. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected a single ReactElement."));
  715. }
  716. return null;
  717. }
  718. return createChainableTypeChecker(validate);
  719. }
  720. function createInstanceTypeChecker(expectedClass) {
  721. function validate(props, propName, componentName, location, propFullName) {
  722. if (!(props[propName] instanceof expectedClass)) {
  723. var expectedClassName = expectedClass.name || ANONYMOUS;
  724. var actualClassName = getClassName(props[propName]);
  725. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + actualClassName + "` supplied to `" + componentName + "`, expected ") + ("instance of `" + expectedClassName + "`."));
  726. }
  727. return null;
  728. }
  729. return createChainableTypeChecker(validate);
  730. }
  731. function createEnumTypeChecker(expectedValues) {
  732. if (!Array.isArray(expectedValues)) {
  733. return emptyFunction.thatReturnsNull;
  734. }
  735. function validate(props, propName, componentName, location, propFullName) {
  736. var propValue = props[propName];
  737. for (var i = 0; i < expectedValues.length; i++) {
  738. if (is(propValue, expectedValues[i])) {
  739. return null;
  740. }
  741. }
  742. var valuesString = JSON.stringify(expectedValues);
  743. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of value `" + propValue + "` " + ("supplied to `" + componentName + "`, expected one of " + valuesString + "."));
  744. }
  745. return createChainableTypeChecker(validate);
  746. }
  747. function createObjectOfTypeChecker(typeChecker) {
  748. function validate(props, propName, componentName, location, propFullName) {
  749. if (typeof typeChecker !== "function") {
  750. return new PropTypeError("Property `" + propFullName + "` of component `" + componentName + "` has invalid PropType notation inside objectOf.");
  751. }
  752. var propValue = props[propName];
  753. var propType = getPropType(propValue);
  754. if (propType !== "object") {
  755. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type " + ("`" + propType + "` supplied to `" + componentName + "`, expected an object."));
  756. }
  757. for (var key in propValue) {
  758. if (propValue.hasOwnProperty(key)) {
  759. var error = typeChecker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
  760. if (error instanceof Error) {
  761. return error;
  762. }
  763. }
  764. }
  765. return null;
  766. }
  767. return createChainableTypeChecker(validate);
  768. }
  769. function createUnionTypeChecker(arrayOfTypeCheckers) {
  770. if (!Array.isArray(arrayOfTypeCheckers)) {
  771. return emptyFunction.thatReturnsNull;
  772. }
  773. for (var i = 0; i < arrayOfTypeCheckers.length; i++) {
  774. var checker = arrayOfTypeCheckers[i];
  775. if (typeof checker !== "function") {
  776. warning(
  777. false,
  778. "Invalid argument supplied to oneOfType. Expected an array of check functions, but received %s at index %s.",
  779. getPostfixForTypeWarning(checker),
  780. i
  781. );
  782. return emptyFunction.thatReturnsNull;
  783. }
  784. }
  785. function validate(props, propName, componentName, location, propFullName) {
  786. for (var i2 = 0; i2 < arrayOfTypeCheckers.length; i2++) {
  787. var checker2 = arrayOfTypeCheckers[i2];
  788. if (checker2(props, propName, componentName, location, propFullName, ReactPropTypesSecret) == null) {
  789. return null;
  790. }
  791. }
  792. return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`."));
  793. }
  794. return createChainableTypeChecker(validate);
  795. }
  796. function createNodeChecker() {
  797. function validate(props, propName, componentName, location, propFullName) {
  798. if (!isNode(props[propName])) {
  799. return new PropTypeError("Invalid " + location + " `" + propFullName + "` supplied to " + ("`" + componentName + "`, expected a ReactNode."));
  800. }
  801. return null;
  802. }
  803. return createChainableTypeChecker(validate);
  804. }
  805. function createShapeTypeChecker(shapeTypes) {
  806. function validate(props, propName, componentName, location, propFullName) {
  807. var propValue = props[propName];
  808. var propType = getPropType(propValue);
  809. if (propType !== "object") {
  810. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
  811. }
  812. for (var key in shapeTypes) {
  813. var checker = shapeTypes[key];
  814. if (!checker) {
  815. continue;
  816. }
  817. var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
  818. if (error) {
  819. return error;
  820. }
  821. }
  822. return null;
  823. }
  824. return createChainableTypeChecker(validate);
  825. }
  826. function createStrictShapeTypeChecker(shapeTypes) {
  827. function validate(props, propName, componentName, location, propFullName) {
  828. var propValue = props[propName];
  829. var propType = getPropType(propValue);
  830. if (propType !== "object") {
  831. return new PropTypeError("Invalid " + location + " `" + propFullName + "` of type `" + propType + "` " + ("supplied to `" + componentName + "`, expected `object`."));
  832. }
  833. var allKeys = assign({}, props[propName], shapeTypes);
  834. for (var key in allKeys) {
  835. var checker = shapeTypes[key];
  836. if (!checker) {
  837. return new PropTypeError(
  838. "Invalid " + location + " `" + propFullName + "` key `" + key + "` supplied to `" + componentName + "`.\nBad object: " + JSON.stringify(props[propName], null, " ") + "\nValid keys: " + JSON.stringify(Object.keys(shapeTypes), null, " ")
  839. );
  840. }
  841. var error = checker(propValue, key, componentName, location, propFullName + "." + key, ReactPropTypesSecret);
  842. if (error) {
  843. return error;
  844. }
  845. }
  846. return null;
  847. }
  848. return createChainableTypeChecker(validate);
  849. }
  850. function isNode(propValue) {
  851. switch (typeof propValue) {
  852. case "number":
  853. case "string":
  854. case "undefined":
  855. return true;
  856. case "boolean":
  857. return !propValue;
  858. case "object":
  859. if (Array.isArray(propValue)) {
  860. return propValue.every(isNode);
  861. }
  862. if (propValue === null || isValidElement(propValue)) {
  863. return true;
  864. }
  865. var iteratorFn = getIteratorFn(propValue);
  866. if (iteratorFn) {
  867. var iterator = iteratorFn.call(propValue);
  868. var step;
  869. if (iteratorFn !== propValue.entries) {
  870. while (!(step = iterator.next()).done) {
  871. if (!isNode(step.value)) {
  872. return false;
  873. }
  874. }
  875. } else {
  876. while (!(step = iterator.next()).done) {
  877. var entry = step.value;
  878. if (entry) {
  879. if (!isNode(entry[1])) {
  880. return false;
  881. }
  882. }
  883. }
  884. }
  885. } else {
  886. return false;
  887. }
  888. return true;
  889. default:
  890. return false;
  891. }
  892. }
  893. function isSymbol(propType, propValue) {
  894. if (propType === "symbol") {
  895. return true;
  896. }
  897. if (propValue["@@toStringTag"] === "Symbol") {
  898. return true;
  899. }
  900. if (typeof Symbol === "function" && propValue instanceof Symbol) {
  901. return true;
  902. }
  903. return false;
  904. }
  905. function getPropType(propValue) {
  906. var propType = typeof propValue;
  907. if (Array.isArray(propValue)) {
  908. return "array";
  909. }
  910. if (propValue instanceof RegExp) {
  911. return "object";
  912. }
  913. if (isSymbol(propType, propValue)) {
  914. return "symbol";
  915. }
  916. return propType;
  917. }
  918. function getPreciseType(propValue) {
  919. if (typeof propValue === "undefined" || propValue === null) {
  920. return "" + propValue;
  921. }
  922. var propType = getPropType(propValue);
  923. if (propType === "object") {
  924. if (propValue instanceof Date) {
  925. return "date";
  926. } else if (propValue instanceof RegExp) {
  927. return "regexp";
  928. }
  929. }
  930. return propType;
  931. }
  932. function getPostfixForTypeWarning(value) {
  933. var type = getPreciseType(value);
  934. switch (type) {
  935. case "array":
  936. case "object":
  937. return "an " + type;
  938. case "boolean":
  939. case "date":
  940. case "regexp":
  941. return "a " + type;
  942. default:
  943. return type;
  944. }
  945. }
  946. function getClassName(propValue) {
  947. if (!propValue.constructor || !propValue.constructor.name) {
  948. return ANONYMOUS;
  949. }
  950. return propValue.constructor.name;
  951. }
  952. ReactPropTypes.checkPropTypes = checkPropTypes;
  953. ReactPropTypes.PropTypes = ReactPropTypes;
  954. return ReactPropTypes;
  955. };
  956. }).call(exports, __webpack_require__(5));
  957. },
  958. /* 7 */
  959. /***/
  960. function(module2, exports) {
  961. function makeEmptyFunction(arg) {
  962. return function() {
  963. return arg;
  964. };
  965. }
  966. var emptyFunction = function emptyFunction2() {
  967. };
  968. emptyFunction.thatReturns = makeEmptyFunction;
  969. emptyFunction.thatReturnsFalse = makeEmptyFunction(false);
  970. emptyFunction.thatReturnsTrue = makeEmptyFunction(true);
  971. emptyFunction.thatReturnsNull = makeEmptyFunction(null);
  972. emptyFunction.thatReturnsThis = function() {
  973. return this;
  974. };
  975. emptyFunction.thatReturnsArgument = function(arg) {
  976. return arg;
  977. };
  978. module2.exports = emptyFunction;
  979. },
  980. /* 8 */
  981. /***/
  982. function(module2, exports, __webpack_require__) {
  983. (function(process) {
  984. function invariant(condition, format, a, b, c, d, e, f2) {
  985. if (!condition) {
  986. var error;
  987. if (format === void 0) {
  988. error = new Error("Minified exception occurred; use the non-minified dev environment for the full error message and additional helpful warnings.");
  989. } else {
  990. var args = [a, b, c, d, e, f2];
  991. var argIndex = 0;
  992. error = new Error(format.replace(/%s/g, function() {
  993. return args[argIndex++];
  994. }));
  995. error.name = "Invariant Violation";
  996. }
  997. error.framesToPop = 1;
  998. throw error;
  999. }
  1000. }
  1001. module2.exports = invariant;
  1002. }).call(exports, __webpack_require__(5));
  1003. },
  1004. /* 9 */
  1005. /***/
  1006. function(module2, exports, __webpack_require__) {
  1007. (function(process) {
  1008. var emptyFunction = __webpack_require__(7);
  1009. var warning = emptyFunction;
  1010. module2.exports = warning;
  1011. }).call(exports, __webpack_require__(5));
  1012. },
  1013. /* 10 */
  1014. /***/
  1015. function(module2, exports) {
  1016. var getOwnPropertySymbols = Object.getOwnPropertySymbols;
  1017. var hasOwnProperty = Object.prototype.hasOwnProperty;
  1018. var propIsEnumerable = Object.prototype.propertyIsEnumerable;
  1019. function toObject(val) {
  1020. if (val === null || val === void 0) {
  1021. throw new TypeError("Object.assign cannot be called with null or undefined");
  1022. }
  1023. return Object(val);
  1024. }
  1025. function shouldUseNative() {
  1026. try {
  1027. if (!Object.assign) {
  1028. return false;
  1029. }
  1030. var test1 = new String("abc");
  1031. test1[5] = "de";
  1032. if (Object.getOwnPropertyNames(test1)[0] === "5") {
  1033. return false;
  1034. }
  1035. var test2 = {};
  1036. for (var i = 0; i < 10; i++) {
  1037. test2["_" + String.fromCharCode(i)] = i;
  1038. }
  1039. var order2 = Object.getOwnPropertyNames(test2).map(function(n2) {
  1040. return test2[n2];
  1041. });
  1042. if (order2.join("") !== "0123456789") {
  1043. return false;
  1044. }
  1045. var test3 = {};
  1046. "abcdefghijklmnopqrst".split("").forEach(function(letter) {
  1047. test3[letter] = letter;
  1048. });
  1049. if (Object.keys(Object.assign({}, test3)).join("") !== "abcdefghijklmnopqrst") {
  1050. return false;
  1051. }
  1052. return true;
  1053. } catch (err) {
  1054. return false;
  1055. }
  1056. }
  1057. module2.exports = shouldUseNative() ? Object.assign : function(target, source) {
  1058. var from;
  1059. var to = toObject(target);
  1060. var symbols;
  1061. for (var s = 1; s < arguments.length; s++) {
  1062. from = Object(arguments[s]);
  1063. for (var key in from) {
  1064. if (hasOwnProperty.call(from, key)) {
  1065. to[key] = from[key];
  1066. }
  1067. }
  1068. if (getOwnPropertySymbols) {
  1069. symbols = getOwnPropertySymbols(from);
  1070. for (var i = 0; i < symbols.length; i++) {
  1071. if (propIsEnumerable.call(from, symbols[i])) {
  1072. to[symbols[i]] = from[symbols[i]];
  1073. }
  1074. }
  1075. }
  1076. }
  1077. return to;
  1078. };
  1079. },
  1080. /* 11 */
  1081. /***/
  1082. function(module2, exports) {
  1083. var ReactPropTypesSecret = "SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED";
  1084. module2.exports = ReactPropTypesSecret;
  1085. },
  1086. /* 12 */
  1087. /***/
  1088. function(module2, exports, __webpack_require__) {
  1089. (function(process) {
  1090. function checkPropTypes(typeSpecs, values, location, componentName, getStack) {
  1091. }
  1092. module2.exports = checkPropTypes;
  1093. }).call(exports, __webpack_require__(5));
  1094. },
  1095. /* 13 */
  1096. /***/
  1097. function(module2, exports, __webpack_require__) {
  1098. var emptyFunction = __webpack_require__(7);
  1099. var invariant = __webpack_require__(8);
  1100. var ReactPropTypesSecret = __webpack_require__(11);
  1101. module2.exports = function() {
  1102. function shim(props, propName, componentName, location, propFullName, secret) {
  1103. if (secret === ReactPropTypesSecret) {
  1104. return;
  1105. }
  1106. invariant(
  1107. false,
  1108. "Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types"
  1109. );
  1110. }
  1111. shim.isRequired = shim;
  1112. function getShim() {
  1113. return shim;
  1114. }
  1115. var ReactPropTypes = {
  1116. array: shim,
  1117. bool: shim,
  1118. func: shim,
  1119. number: shim,
  1120. object: shim,
  1121. string: shim,
  1122. symbol: shim,
  1123. any: shim,
  1124. arrayOf: getShim,
  1125. element: shim,
  1126. instanceOf: getShim,
  1127. node: shim,
  1128. objectOf: getShim,
  1129. oneOf: getShim,
  1130. oneOfType: getShim,
  1131. shape: getShim,
  1132. exact: getShim
  1133. };
  1134. ReactPropTypes.checkPropTypes = emptyFunction;
  1135. ReactPropTypes.PropTypes = ReactPropTypes;
  1136. return ReactPropTypes;
  1137. };
  1138. },
  1139. /* 14 */
  1140. /***/
  1141. function(module2, exports) {
  1142. module2.exports = require$$0;
  1143. },
  1144. /* 15 */
  1145. /***/
  1146. function(module2, exports) {
  1147. var simpleIsEqual = function simpleIsEqual2(a, b) {
  1148. return a === b;
  1149. };
  1150. function index(resultFn) {
  1151. var isEqual = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : simpleIsEqual;
  1152. var lastThis = void 0;
  1153. var lastArgs = [];
  1154. var lastResult = void 0;
  1155. var calledOnce = false;
  1156. var isNewArgEqualToLast = function isNewArgEqualToLast2(newArg, index2) {
  1157. return isEqual(newArg, lastArgs[index2]);
  1158. };
  1159. var result = function result2() {
  1160. for (var _len = arguments.length, newArgs = Array(_len), _key = 0; _key < _len; _key++) {
  1161. newArgs[_key] = arguments[_key];
  1162. }
  1163. if (calledOnce && lastThis === this && newArgs.length === lastArgs.length && newArgs.every(isNewArgEqualToLast)) {
  1164. return lastResult;
  1165. }
  1166. calledOnce = true;
  1167. lastThis = this;
  1168. lastArgs = newArgs;
  1169. lastResult = resultFn.apply(this, newArgs);
  1170. return lastResult;
  1171. };
  1172. return result;
  1173. }
  1174. module2.exports = index;
  1175. }
  1176. /******/
  1177. ]);
  1178. })(main);
  1179. var mainExports = main.exports;
  1180. const Highlighter = /* @__PURE__ */ getDefaultExportFromCjs(mainExports);
  1181. var CommentType = /* @__PURE__ */ ((CommentType2) => {
  1182. CommentType2[CommentType2["VIDEO"] = 1] = "VIDEO";
  1183. CommentType2[CommentType2["TOPIC"] = 2] = "TOPIC";
  1184. CommentType2[CommentType2["ACTIVITY"] = 4] = "ACTIVITY";
  1185. CommentType2[CommentType2["SHORT_VIDEO"] = 5] = "SHORT_VIDEO";
  1186. CommentType2[CommentType2["BAN_INFO"] = 6] = "BAN_INFO";
  1187. CommentType2[CommentType2["NOTICE"] = 7] = "NOTICE";
  1188. CommentType2[CommentType2["LIVE_ACTIVITY"] = 8] = "LIVE_ACTIVITY";
  1189. CommentType2[CommentType2["ACTIVITY_ARTICLE"] = 9] = "ACTIVITY_ARTICLE";
  1190. CommentType2[CommentType2["LIVE_NOTICE"] = 10] = "LIVE_NOTICE";
  1191. CommentType2[CommentType2["ALBUM"] = 11] = "ALBUM";
  1192. CommentType2[CommentType2["COLUMN"] = 12] = "COLUMN";
  1193. CommentType2[CommentType2["TICKET"] = 13] = "TICKET";
  1194. CommentType2[CommentType2["AUDIO"] = 14] = "AUDIO";
  1195. CommentType2[CommentType2["JURY"] = 15] = "JURY";
  1196. CommentType2[CommentType2["REVIEW"] = 16] = "REVIEW";
  1197. CommentType2[CommentType2["DYNAMIC"] = 17] = "DYNAMIC";
  1198. CommentType2[CommentType2["PLAYLIST"] = 18] = "PLAYLIST";
  1199. CommentType2[CommentType2["MUSIC_PLAYLIST"] = 19] = "MUSIC_PLAYLIST";
  1200. CommentType2[CommentType2["COMIC_1"] = 20] = "COMIC_1";
  1201. CommentType2[CommentType2["COMIC_2"] = 21] = "COMIC_2";
  1202. CommentType2[CommentType2["COMIC_3"] = 22] = "COMIC_3";
  1203. CommentType2[CommentType2["COURSE"] = 33] = "COURSE";
  1204. return CommentType2;
  1205. })(CommentType || {});
  1206. var CommentSort = /* @__PURE__ */ ((CommentSort2) => {
  1207. CommentSort2[CommentSort2["TIME"] = 0] = "TIME";
  1208. CommentSort2[CommentSort2["LIKES"] = 1] = "LIKES";
  1209. CommentSort2[CommentSort2["REPLIES"] = 2] = "REPLIES";
  1210. return CommentSort2;
  1211. })(CommentSort || {});
  1212. const name = "userscript-bilibili-comment-search";
  1213. const version = "0.2.0";
  1214. function assertEl(el) {
  1215. if (!el) {
  1216. throw new Error("Element not found");
  1217. }
  1218. return el;
  1219. }
  1220. function debug(message) {
  1221. console.log(`[${name}] ${message}`);
  1222. }
  1223. function extractVideoId(url) {
  1224. const match = url.match(/\/video\/(BV\w+)\//);
  1225. if (!match) {
  1226. throw new Error(`Failed to extract video id from url: ${url}`);
  1227. }
  1228. return match[1];
  1229. }
  1230. function formatDateTime(ts) {
  1231. const date = new Date(ts * 1e3);
  1232. return date.toLocaleString("zh-CN", {
  1233. year: "numeric",
  1234. month: "2-digit",
  1235. day: "2-digit",
  1236. hour: "2-digit",
  1237. minute: "2-digit",
  1238. hour12: false
  1239. });
  1240. }
  1241. const PAGE_LIMIT = 20;
  1242. const replies = [];
  1243. async function fetchComments(videoId) {
  1244. if (replies.length > 0) {
  1245. return replies;
  1246. }
  1247. const pageSize = 20;
  1248. let page = 1;
  1249. while (true) {
  1250. const params = new URLSearchParams({
  1251. type: CommentType.VIDEO.toString(),
  1252. oid: videoId,
  1253. sort: CommentSort.TIME.toString(),
  1254. pn: page.toString(),
  1255. ps: pageSize.toString()
  1256. });
  1257. debug(`fetch comments: page ${page}`);
  1258. const response = await fetch(
  1259. `https://api.bilibili.com/x/v2/reply?${params}`,
  1260. { credentials: "include" }
  1261. );
  1262. const data = await response.json();
  1263. if (data.code !== 0) {
  1264. throw new Error(`Failed to fetch comments: ${data.message}`);
  1265. }
  1266. if (!data.data) {
  1267. throw new Error(`Failed to fetch comments: ${data.message}`);
  1268. }
  1269. replies.push(...data.data.replies ?? []);
  1270. if (page * pageSize >= Math.min(PAGE_LIMIT * pageSize, data.data.page.count)) {
  1271. break;
  1272. }
  1273. page++;
  1274. }
  1275. return replies;
  1276. }
  1277. let keyword = "";
  1278. function App() {
  1279. const dialogRef = require$$0.useRef(null);
  1280. const inputRef = require$$0.useRef(null);
  1281. const [comments, setComments] = require$$0.useState();
  1282. const promiseRef = require$$0.useRef(null);
  1283. return /* @__PURE__ */ jsxRuntimeExports.jsxs(jsxRuntimeExports.Fragment, { children: [
  1284. /* @__PURE__ */ jsxRuntimeExports.jsxs(
  1285. "dialog",
  1286. {
  1287. ref: dialogRef,
  1288. onClick: (e) => {
  1289. const rect = e.currentTarget.getBoundingClientRect();
  1290. if (e.clientY < rect.top || e.clientY > rect.bottom || e.clientX < rect.left || e.clientX > rect.right) {
  1291. e.currentTarget.close();
  1292. }
  1293. },
  1294. children: [
  1295. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "header", children: [
  1296. /* @__PURE__ */ jsxRuntimeExports.jsxs("h1", { children: [
  1297. "Bilibili Comment Search ",
  1298. "",
  1299. /* @__PURE__ */ jsxRuntimeExports.jsxs("span", { children: [
  1300. "v",
  1301. version
  1302. ] })
  1303. ] }),
  1304. /* @__PURE__ */ jsxRuntimeExports.jsx("button", { onClick: () => {
  1305. var _a;
  1306. return (_a = dialogRef.current) == null ? void 0 : _a.close();
  1307. }, children: "X" })
  1308. ] }),
  1309. /* @__PURE__ */ jsxRuntimeExports.jsx(
  1310. "input",
  1311. {
  1312. ref: inputRef,
  1313. placeholder: "搜索评论",
  1314. onKeyDown: (e) => {
  1315. if (e.key === "Enter" && promiseRef.current) {
  1316. e.preventDefault();
  1317. keyword = e.currentTarget.value;
  1318. promiseRef.current.then((allComments) => {
  1319. const comments2 = searchComments(allComments);
  1320. setComments(comments2);
  1321. }).catch((e2) => {
  1322. console.error(e2);
  1323. });
  1324. }
  1325. }
  1326. }
  1327. ),
  1328. /* @__PURE__ */ jsxRuntimeExports.jsxs("div", { className: "note", children: [
  1329. "Note: 由于性能和 Rate Limit 的原因,目前仅会加载 ",
  1330. PAGE_LIMIT,
  1331. " ",
  1332. "页评论,即 ",
  1333. PAGE_LIMIT,
  1334. " * 20 条评论,及其至多 3 条子评论。"
  1335. ] }),
  1336. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "comment-tree", children: /* @__PURE__ */ jsxRuntimeExports.jsx(CommentTree, { comments }) })
  1337. ]
  1338. }
  1339. ),
  1340. /* @__PURE__ */ jsxRuntimeExports.jsx(
  1341. "button",
  1342. {
  1343. onClick: () => {
  1344. var _a, _b;
  1345. (_a = dialogRef.current) == null ? void 0 : _a.showModal();
  1346. (_b = inputRef.current) == null ? void 0 : _b.focus();
  1347. const videoId = extractVideoId(window.location.href);
  1348. promiseRef.current = fetchComments(videoId);
  1349. },
  1350. children: "搜索评论"
  1351. }
  1352. )
  1353. ] });
  1354. }
  1355. const CommentTree = ({ comments, sub = false }) => {
  1356. if (!comments)
  1357. return null;
  1358. return /* @__PURE__ */ jsxRuntimeExports.jsx("ul", { children: comments.sort((c1, c2) => c1.ctime - c2.ctime).map((comment) => /* @__PURE__ */ jsxRuntimeExports.jsxs(
  1359. "li",
  1360. {
  1361. className: "comment-item",
  1362. style: {
  1363. marginTop: sub ? "10px" : "20px"
  1364. },
  1365. children: [
  1366. /* @__PURE__ */ jsxRuntimeExports.jsx(
  1367. "img",
  1368. {
  1369. src: comment.member.avatar,
  1370. className: "comment-item-avatar",
  1371. style: {
  1372. width: sub ? "28px" : "40px",
  1373. height: sub ? "28px" : "40px"
  1374. }
  1375. }
  1376. ),
  1377. /* @__PURE__ */ jsxRuntimeExports.jsxs(
  1378. "div",
  1379. {
  1380. className: "comment-item-content",
  1381. style: {
  1382. ...!sub && {
  1383. display: "flex",
  1384. flexDirection: "column"
  1385. }
  1386. },
  1387. children: [
  1388. /* @__PURE__ */ jsxRuntimeExports.jsx("span", { className: "comment-item-username", children: comment.member.uname }),
  1389. /* @__PURE__ */ jsxRuntimeExports.jsx(
  1390. Highlighter,
  1391. {
  1392. className: "comment-item-message",
  1393. highlightClassName: "comment-item-highlight",
  1394. searchWords: [keyword],
  1395. autoEscape: true,
  1396. textToHighlight: comment.content.message
  1397. }
  1398. ),
  1399. /* @__PURE__ */ jsxRuntimeExports.jsx("div", { className: "comment-item-time", children: formatDateTime(comment.ctime) }),
  1400. /* @__PURE__ */ jsxRuntimeExports.jsx(CommentTree, { comments: comment.replies, sub: true })
  1401. ]
  1402. }
  1403. )
  1404. ]
  1405. },
  1406. comment.rpid
  1407. )) });
  1408. };
  1409. function searchComments(allComments) {
  1410. return allComments.filter((comment) => {
  1411. var _a;
  1412. return comment.content.message.includes(keyword) || ((_a = comment.replies) == null ? void 0 : _a.some((reply) => reply.content.message.includes(keyword)));
  1413. });
  1414. }
  1415. function run() {
  1416. debug("run");
  1417. const id = "comment-search-root";
  1418. let root = document.querySelector(`#${id}`);
  1419. if (root) {
  1420. debug("root exists");
  1421. return;
  1422. }
  1423. const container = assertEl(document.querySelector("#commentapp"));
  1424. root = document.createElement("div");
  1425. root.id = id;
  1426. container.prepend(root);
  1427. debug("render");
  1428. client.createRoot(root).render(
  1429. /* @__PURE__ */ jsxRuntimeExports.jsx(require$$0.StrictMode, { children: /* @__PURE__ */ jsxRuntimeExports.jsx(App, {}) })
  1430. );
  1431. }
  1432. window.addEventListener("load", () => {
  1433. const timer = setInterval(() => {
  1434. try {
  1435. run();
  1436. clearInterval(timer);
  1437. } catch (error) {
  1438. }
  1439. }, 500);
  1440. });
  1441.  
  1442. })(React, ReactDOM);

QingJ © 2025

镜像随时可能失效,请加Q群300939539或关注我们的公众号极客氢云获取最新地址