Flow Youtube Chat

Youtubeのチャットをニコニコ風に画面上へ流すスクリプトです(再アップ,絵文字バグ修正済み)

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

  1. // ==UserScript==
  2. // @name Flow Youtube Chat
  3. // @version 1.15.1
  4. // @description Youtubeのチャットをニコニコ風に画面上へ流すスクリプトです(再アップ,絵文字バグ修正済み)
  5. // @match https://www.youtube.com/*
  6. // @namespace FlowYoutubeChatScript
  7. // @run-at document-end
  8. // @grant GM.setValue
  9. // @grant GM.getValue
  10. // @grant GM.deleteValue
  11. // @grant GM.listValues
  12. // @grant GM.setClipboard
  13. // @noframes
  14. // @license AGPL-3.0-or-later
  15. // @require https://cdn.jsdelivr.net/npm/sweetalert2@10.10.1/dist/sweetalert2.all.min.js#sha384-OCBhaEdUu7BFgaeRVey2PDeHof2MSQRFe/e6S8Q3XrmSV7wrKpLmhPj8FOldGiaF
  16. // @require https://unpkg.com/loglevel@1.7.0/dist/loglevel.min.js#sha384-7gGuWfek8Ql6j/uNDFrS0BCe4x2ZihD4B68w9Eu580OVHJBV+bl3rZmEWC7q5/Gj
  17. // @require https://unpkg.com/rxjs@7.0.0-beta.15/dist/bundles/rxjs.umd.min.js#sha384-+Rm7rQiA6cedgczLLWq3cM9/RmnI/NoyMXu+QmVNOeY96sa6u1bTaR5QB0Q3GpUE
  18. // @require https://unpkg.com/mithril@2.0.4/mithril.min.js#sha384-vo9crXih40MlEv6JWHqS7SsPiFp+76csaWQFOF2UU0/xI58Jm/ZvK/1UtpaicJT9
  19. // @require https://cdn.jsdelivr.net/npm/check-types@11.1.2/src/check-types.min.js#sha384-KGnImnhVjA5llfqKEbjBiY+1Mp6oa+NvW/TEY1XTPAKWNgrAwa3Qvn//MXL07wBM
  20. // @require https://cdn.jsdelivr.net/npm/deep-diff@1.0.2/index.min.js#sha384-Q/uiWfFlwn9XjOpL49VpFKn01EkScmaC3hh1prAn7S++WoZgXRrrjQvZ7cI7C7Zn
  21. // @require https://cdn.jsdelivr.net/npm/astring@1.7.0/dist/astring.min.js#sha384-QHrTlnYTIr9r51gEjAJ/fTnbEJpQzcyZFQ7HmNTK+oR/pBYw2m9y0jV0POoLH4bn
  22. // @require https://cdn.jsdelivr.net/npm/jsep@0.4.0/build/jsep.min.js#sha384-89PRdfFVlT2bC9VxvLdvlByyVGml9l14DjpPqZYVI9umfvV24KPZ5dY6qBOeKf2z
  23. // @require https://cdn.jsdelivr.net/npm/hash-it@5.0.0/dist/hash-it.min.js#sha384-FUKF3wpiG+sroVb9gRjA7xyDDUNV0AJKZMqn0pBhxQfTR46NoegCce6vE16E1cbA
  24. // @require https://cdn.jsdelivr.net/npm/micro-memoize@4.0.9/dist/micro-memoize.min.js#sha384-aGxbSIH2oMTKxZ93i+/iQKx5xefR8mHJW3mkbRaiSZizVoCvKS6wzndlLeQzMv9B
  25. // ==/UserScript==
  26.  
  27. /* jshint esversion: 6 */
  28.  
  29. ;(() => {
  30. var __webpack_modules__ = {
  31. 378: module => {
  32. "use strict"
  33. module.exports = function equal(a, b) {
  34. if (a === b) return !0
  35. if (a && b && "object" == typeof a && "object" == typeof b) {
  36. if (a.constructor !== b.constructor) return !1
  37. var length, i, keys
  38. if (Array.isArray(a)) {
  39. if ((length = a.length) != b.length) return !1
  40. for (i = length; 0 != i--; ) if (!equal(a[i], b[i])) return !1
  41. return !0
  42. }
  43. if (a.constructor === RegExp)
  44. return a.source === b.source && a.flags === b.flags
  45. if (a.valueOf !== Object.prototype.valueOf)
  46. return a.valueOf() === b.valueOf()
  47. if (a.toString !== Object.prototype.toString)
  48. return a.toString() === b.toString()
  49. if (
  50. (length = (keys = Object.keys(a)).length) !==
  51. Object.keys(b).length
  52. )
  53. return !1
  54. for (i = length; 0 != i--; )
  55. if (!Object.prototype.hasOwnProperty.call(b, keys[i])) return !1
  56. for (i = length; 0 != i--; ) {
  57. var key = keys[i]
  58. if (!equal(a[key], b[key])) return !1
  59. }
  60. return !0
  61. }
  62. return a != a && b != b
  63. }
  64. },
  65. 815: () => {},
  66. },
  67. __webpack_module_cache__ = {}
  68. function __webpack_require__(moduleId) {
  69. if (__webpack_module_cache__[moduleId])
  70. return __webpack_module_cache__[moduleId].exports
  71. var module = (__webpack_module_cache__[moduleId] = { exports: {} })
  72. return (
  73. __webpack_modules__[moduleId](
  74. module,
  75. module.exports,
  76. __webpack_require__
  77. ),
  78. module.exports
  79. )
  80. }
  81. ;(__webpack_require__.n = module => {
  82. var getter =
  83. module && module.__esModule ? () => module.default : () => module
  84. return __webpack_require__.d(getter, { a: getter }), getter
  85. }),
  86. (__webpack_require__.d = (exports, definition) => {
  87. for (var key in definition)
  88. __webpack_require__.o(definition, key) &&
  89. !__webpack_require__.o(exports, key) &&
  90. Object.defineProperty(exports, key, {
  91. enumerable: !0,
  92. get: definition[key],
  93. })
  94. }),
  95. (__webpack_require__.o = (obj, prop) =>
  96. Object.prototype.hasOwnProperty.call(obj, prop)),
  97. (() => {
  98. "use strict"
  99. var function_getMonoid = function (M) {
  100. var S,
  101. getSemigroupM =
  102. ((S = M),
  103. function () {
  104. return {
  105. concat: function (f, g) {
  106. return function (a) {
  107. return S.concat(f(a), g(a))
  108. }
  109. },
  110. }
  111. })
  112. return function () {
  113. return {
  114. concat: getSemigroupM().concat,
  115. empty: function () {
  116. return M.empty
  117. },
  118. }
  119. }
  120. }
  121. function function_identity(a) {
  122. return a
  123. }
  124. function constant(a) {
  125. return function () {
  126. return a
  127. }
  128. }
  129. var constUndefined = constant(void 0)
  130. function function_pipe(
  131. a,
  132. ab,
  133. bc,
  134. cd,
  135. de,
  136. ef,
  137. fg,
  138. gh,
  139. hi,
  140. ij,
  141. jk,
  142. kl,
  143. lm,
  144. mn,
  145. no,
  146. op,
  147. pq,
  148. qr,
  149. rs,
  150. st
  151. ) {
  152. switch (arguments.length) {
  153. case 1:
  154. return a
  155. case 2:
  156. return ab(a)
  157. case 3:
  158. return bc(ab(a))
  159. case 4:
  160. return cd(bc(ab(a)))
  161. case 5:
  162. return de(cd(bc(ab(a))))
  163. case 6:
  164. return ef(de(cd(bc(ab(a)))))
  165. case 7:
  166. return fg(ef(de(cd(bc(ab(a))))))
  167. case 8:
  168. return gh(fg(ef(de(cd(bc(ab(a)))))))
  169. case 9:
  170. return hi(gh(fg(ef(de(cd(bc(ab(a))))))))
  171. case 10:
  172. return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))
  173. case 11:
  174. return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))
  175. case 12:
  176. return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))
  177. case 13:
  178. return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))
  179. case 14:
  180. return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))
  181. case 15:
  182. return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  183. case 16:
  184. return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  185. case 17:
  186. return pq(
  187. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  188. )
  189. case 18:
  190. return qr(
  191. pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))
  192. )
  193. case 19:
  194. return rs(
  195. qr(
  196. pq(
  197. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  198. )
  199. )
  200. )
  201. case 20:
  202. return st(
  203. rs(
  204. qr(
  205. pq(
  206. op(
  207. no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  208. )
  209. )
  210. )
  211. )
  212. )
  213. }
  214. }
  215. Object.prototype.hasOwnProperty
  216. function flap(F) {
  217. return function (a) {
  218. return function (fab) {
  219. return F.map(fab, function (f) {
  220. return f(a)
  221. })
  222. }
  223. }
  224. }
  225. var separated = function (left, right) {
  226. return { left, right }
  227. },
  228. Separated_map = function (f) {
  229. return function (fa) {
  230. return separated(left(fa), f(right(fa)))
  231. }
  232. },
  233. left =
  234. (flap({
  235. URI: "Separated",
  236. map: function (fa, f) {
  237. return function_pipe(fa, Separated_map(f))
  238. },
  239. }),
  240. function (s) {
  241. return s.left
  242. }),
  243. right = function (s) {
  244. return s.right
  245. },
  246. Option_isSome = function (fa) {
  247. return "Some" === fa._tag
  248. },
  249. isNone = function (fa) {
  250. return "None" === fa._tag
  251. },
  252. none = { _tag: "None" },
  253. some = function (a) {
  254. return { _tag: "Some", value: a }
  255. }
  256. function fromPredicate(predicate) {
  257. return function (a) {
  258. return predicate(a) ? some(a) : none
  259. }
  260. }
  261. var matchW = function (onNone, onSome) {
  262. return function (ma) {
  263. return isNone(ma) ? onNone() : onSome(ma.value)
  264. }
  265. },
  266. match = matchW,
  267. getOrElse = function (onNone) {
  268. return function (ma) {
  269. return isNone(ma) ? onNone() : ma.value
  270. }
  271. },
  272. fromNullable = function (a) {
  273. return null == a ? none : some(a)
  274. },
  275. chainNullableK = function (f) {
  276. return function (ma) {
  277. return isNone(ma) ? none : fromNullable(f(ma.value))
  278. }
  279. },
  280. toUndefined = match(constUndefined, function_identity),
  281. es6_Option_map = function (f) {
  282. return function (fa) {
  283. return isNone(fa) ? none : some(f(fa.value))
  284. }
  285. },
  286. chain = function (f) {
  287. return function (ma) {
  288. return isNone(ma) ? none : f(ma.value)
  289. }
  290. },
  291. alt = function (that) {
  292. return function (fa) {
  293. return isNone(fa) ? that() : fa
  294. }
  295. },
  296. filter = function (predicate) {
  297. return function (fa) {
  298. return isNone(fa) ? none : predicate(fa.value) ? fa : none
  299. }
  300. }
  301. function getEq(E) {
  302. return {
  303. equals: function (x, y) {
  304. return (
  305. x === y ||
  306. (isNone(x) ? isNone(y) : !isNone(y) && E.equals(x.value, y.value))
  307. )
  308. },
  309. }
  310. }
  311. const external_log_namespaceObject = log
  312. var external_log_default = __webpack_require__.n(
  313. external_log_namespaceObject
  314. )
  315. const lib = observer => value => {
  316. observer.next(value)
  317. }
  318. function sleep(time) {
  319. return (
  320. time || (time = 0),
  321. new Promise(function (res) {
  322. return setTimeout(res, time)
  323. })
  324. )
  325. }
  326. function randomToken() {
  327. return Math.random().toString(36).substring(2)
  328. }
  329. var lastMs = 0,
  330. additional = 0
  331. function microSeconds() {
  332. var ms = new Date().getTime()
  333. return ms === lastMs
  334. ? 1e3 * ms + ++additional
  335. : ((lastMs = ms), (additional = 0), 1e3 * ms)
  336. }
  337. var isNode =
  338. "[object process]" ===
  339. Object.prototype.toString.call(
  340. "undefined" != typeof process ? process : 0
  341. )
  342. const methods_native = {
  343. create: function (channelName) {
  344. var state = {
  345. messagesCallback: null,
  346. bc: new BroadcastChannel(channelName),
  347. subFns: [],
  348. }
  349. return (
  350. (state.bc.onmessage = function (msg) {
  351. state.messagesCallback && state.messagesCallback(msg.data)
  352. }),
  353. state
  354. )
  355. },
  356. close: function (channelState) {
  357. channelState.bc.close(), (channelState.subFns = [])
  358. },
  359. onMessage: function (channelState, fn) {
  360. channelState.messagesCallback = fn
  361. },
  362. postMessage: function (channelState, messageJson) {
  363. try {
  364. return (
  365. channelState.bc.postMessage(messageJson, !1), Promise.resolve()
  366. )
  367. } catch (err) {
  368. return Promise.reject(err)
  369. }
  370. },
  371. canBeUsed: function () {
  372. if (isNode && "undefined" == typeof window) return !1
  373. if ("function" == typeof BroadcastChannel) {
  374. if (BroadcastChannel._pubkey)
  375. throw new Error(
  376. "BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"
  377. )
  378. return !0
  379. }
  380. return !1
  381. },
  382. type: "native",
  383. averageResponseTime: function () {
  384. return 150
  385. },
  386. microSeconds,
  387. }
  388. function now() {
  389. return new Date().getTime()
  390. }
  391. const oblivious_set = function (ttl) {
  392. var set = new Set(),
  393. timeMap = new Map()
  394. ;(this.has = set.has.bind(set)),
  395. (this.add = function (value) {
  396. timeMap.set(value, now()),
  397. set.add(value),
  398. (function () {
  399. var olderThen = now() - ttl,
  400. iterator = set[Symbol.iterator]()
  401. for (;;) {
  402. var value = iterator.next().value
  403. if (!value) return
  404. if (!(timeMap.get(value) < olderThen)) return
  405. timeMap.delete(value), set.delete(value)
  406. }
  407. })()
  408. }),
  409. (this.clear = function () {
  410. set.clear(), timeMap.clear()
  411. })
  412. }
  413. function options_fillOptionsWithDefaults() {
  414. var originalOptions =
  415. arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : {},
  416. options = JSON.parse(JSON.stringify(originalOptions))
  417. return (
  418. void 0 === options.webWorkerSupport &&
  419. (options.webWorkerSupport = !0),
  420. options.idb || (options.idb = {}),
  421. options.idb.ttl || (options.idb.ttl = 45e3),
  422. options.idb.fallbackInterval || (options.idb.fallbackInterval = 150),
  423. originalOptions.idb &&
  424. "function" == typeof originalOptions.idb.onclose &&
  425. (options.idb.onclose = originalOptions.idb.onclose),
  426. options.localstorage || (options.localstorage = {}),
  427. options.localstorage.removeTimeout ||
  428. (options.localstorage.removeTimeout = 6e4),
  429. originalOptions.methods &&
  430. (options.methods = originalOptions.methods),
  431. options.node || (options.node = {}),
  432. options.node.ttl || (options.node.ttl = 12e4),
  433. void 0 === options.node.useFastPath &&
  434. (options.node.useFastPath = !0),
  435. options
  436. )
  437. }
  438. function getIdb() {
  439. if ("undefined" != typeof indexedDB) return indexedDB
  440. if ("undefined" != typeof window) {
  441. if (void 0 !== window.mozIndexedDB) return window.mozIndexedDB
  442. if (void 0 !== window.webkitIndexedDB) return window.webkitIndexedDB
  443. if (void 0 !== window.msIndexedDB) return window.msIndexedDB
  444. }
  445. return !1
  446. }
  447. function getMessagesHigherThan(db, lastCursorId) {
  448. var objectStore = db.transaction("messages").objectStore("messages"),
  449. ret = []
  450. return new Promise(function (res) {
  451. ;(function () {
  452. try {
  453. var keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, 1 / 0)
  454. return objectStore.openCursor(keyRangeValue)
  455. } catch (e) {
  456. return objectStore.openCursor()
  457. }
  458. })().onsuccess = function (ev) {
  459. var cursor = ev.target.result
  460. cursor
  461. ? cursor.value.id < lastCursorId + 1
  462. ? cursor.continue(lastCursorId + 1)
  463. : (ret.push(cursor.value), cursor.continue())
  464. : res(ret)
  465. }
  466. })
  467. }
  468. function cleanOldMessages(db, ttl) {
  469. return (function (db, ttl) {
  470. var olderThen = new Date().getTime() - ttl,
  471. objectStore = db.transaction("messages").objectStore("messages"),
  472. ret = []
  473. return new Promise(function (res) {
  474. objectStore.openCursor().onsuccess = function (ev) {
  475. var cursor = ev.target.result
  476. if (cursor) {
  477. var msgObk = cursor.value
  478. if (!(msgObk.time < olderThen)) return void res(ret)
  479. ret.push(msgObk), cursor.continue()
  480. } else res(ret)
  481. }
  482. })
  483. })(db, ttl).then(function (tooOld) {
  484. return Promise.all(
  485. tooOld.map(function (msgObj) {
  486. return (function (db, id) {
  487. var request = db
  488. .transaction(["messages"], "readwrite")
  489. .objectStore("messages")
  490. .delete(id)
  491. return new Promise(function (res) {
  492. request.onsuccess = function () {
  493. return res()
  494. }
  495. })
  496. })(db, msgObj.id)
  497. })
  498. )
  499. })
  500. }
  501. function _readLoop(state) {
  502. state.closed ||
  503. readNewMessages(state)
  504. .then(function () {
  505. return sleep(state.options.idb.fallbackInterval)
  506. })
  507. .then(function () {
  508. return _readLoop(state)
  509. })
  510. }
  511. function readNewMessages(state) {
  512. return state.closed
  513. ? Promise.resolve()
  514. : state.messagesCallback
  515. ? getMessagesHigherThan(state.db, state.lastCursorId).then(function (
  516. newerMessages
  517. ) {
  518. return (
  519. newerMessages
  520. .filter(function (msgObj) {
  521. return !!msgObj
  522. })
  523. .map(function (msgObj) {
  524. return (
  525. msgObj.id > state.lastCursorId &&
  526. (state.lastCursorId = msgObj.id),
  527. msgObj
  528. )
  529. })
  530. .filter(function (msgObj) {
  531. return (function (msgObj, state) {
  532. return !(
  533. msgObj.uuid === state.uuid ||
  534. state.eMIs.has(msgObj.id) ||
  535. msgObj.data.time < state.messagesCallbackTime
  536. )
  537. })(msgObj, state)
  538. })
  539. .sort(function (msgObjA, msgObjB) {
  540. return msgObjA.time - msgObjB.time
  541. })
  542. .forEach(function (msgObj) {
  543. state.messagesCallback &&
  544. (state.eMIs.add(msgObj.id),
  545. state.messagesCallback(msgObj.data))
  546. }),
  547. Promise.resolve()
  548. )
  549. })
  550. : Promise.resolve()
  551. }
  552. const indexed_db = {
  553. create: function (channelName, options) {
  554. return (
  555. (options = options_fillOptionsWithDefaults(options)),
  556. (function (channelName) {
  557. var dbName = "pubkey.broadcast-channel-0-" + channelName,
  558. openRequest = getIdb().open(dbName, 1)
  559. return (
  560. (openRequest.onupgradeneeded = function (ev) {
  561. ev.target.result.createObjectStore("messages", {
  562. keyPath: "id",
  563. autoIncrement: !0,
  564. })
  565. }),
  566. new Promise(function (res, rej) {
  567. ;(openRequest.onerror = function (ev) {
  568. return rej(ev)
  569. }),
  570. (openRequest.onsuccess = function () {
  571. res(openRequest.result)
  572. })
  573. })
  574. )
  575. })(channelName).then(function (db) {
  576. var state = {
  577. closed: !1,
  578. lastCursorId: 0,
  579. channelName,
  580. options,
  581. uuid: randomToken(),
  582. eMIs: new oblivious_set(2 * options.idb.ttl),
  583. writeBlockPromise: Promise.resolve(),
  584. messagesCallback: null,
  585. readQueuePromises: [],
  586. db,
  587. }
  588. return (
  589. (db.onclose = function () {
  590. ;(state.closed = !0),
  591. options.idb.onclose && options.idb.onclose()
  592. }),
  593. _readLoop(state),
  594. state
  595. )
  596. })
  597. )
  598. },
  599. close: function (channelState) {
  600. ;(channelState.closed = !0), channelState.db.close()
  601. },
  602. onMessage: function (channelState, fn, time) {
  603. ;(channelState.messagesCallbackTime = time),
  604. (channelState.messagesCallback = fn),
  605. readNewMessages(channelState)
  606. },
  607. postMessage: function (channelState, messageJson) {
  608. return (
  609. (channelState.writeBlockPromise = channelState.writeBlockPromise
  610. .then(function () {
  611. return (function (db, readerUuid, messageJson) {
  612. var writeObject = {
  613. uuid: readerUuid,
  614. time: new Date().getTime(),
  615. data: messageJson,
  616. },
  617. transaction = db.transaction(["messages"], "readwrite")
  618. return new Promise(function (res, rej) {
  619. ;(transaction.oncomplete = function () {
  620. return res()
  621. }),
  622. (transaction.onerror = function (ev) {
  623. return rej(ev)
  624. }),
  625. transaction.objectStore("messages").add(writeObject)
  626. })
  627. })(channelState.db, channelState.uuid, messageJson)
  628. })
  629. .then(function () {
  630. 0 ===
  631. (function (min, max) {
  632. return Math.floor(Math.random() * (max - min + 1) + min)
  633. })(0, 10) &&
  634. cleanOldMessages(
  635. channelState.db,
  636. channelState.options.idb.ttl
  637. )
  638. })),
  639. channelState.writeBlockPromise
  640. )
  641. },
  642. canBeUsed: function () {
  643. return !isNode && !!getIdb()
  644. },
  645. type: "idb",
  646. averageResponseTime: function (options) {
  647. return 2 * options.idb.fallbackInterval
  648. },
  649. microSeconds,
  650. }
  651. function getLocalStorage() {
  652. var localStorage
  653. if ("undefined" == typeof window) return null
  654. try {
  655. ;(localStorage = window.localStorage),
  656. (localStorage =
  657. window["ie8-eventlistener/storage"] || window.localStorage)
  658. } catch (e) {}
  659. return localStorage
  660. }
  661. function storageKey(channelName) {
  662. return "pubkey.broadcastChannel-" + channelName
  663. }
  664. function localstorage_canBeUsed() {
  665. if (isNode) return !1
  666. var ls = getLocalStorage()
  667. if (!ls) return !1
  668. try {
  669. var key = "__broadcastchannel_check"
  670. ls.setItem(key, "works"), ls.removeItem(key)
  671. } catch (e) {
  672. return !1
  673. }
  674. return !0
  675. }
  676. const localstorage = {
  677. create: function (channelName, options) {
  678. if (
  679. ((options = options_fillOptionsWithDefaults(options)),
  680. !localstorage_canBeUsed())
  681. )
  682. throw new Error("BroadcastChannel: localstorage cannot be used")
  683. var uuid = randomToken(),
  684. eMIs = new oblivious_set(options.localstorage.removeTimeout),
  685. state = { channelName, uuid, eMIs }
  686. return (
  687. (state.listener = (function (channelName, fn) {
  688. var key = storageKey(channelName),
  689. listener = function (ev) {
  690. ev.key === key && fn(JSON.parse(ev.newValue))
  691. }
  692. return window.addEventListener("storage", listener), listener
  693. })(channelName, function (msgObj) {
  694. state.messagesCallback &&
  695. msgObj.uuid !== uuid &&
  696. msgObj.token &&
  697. !eMIs.has(msgObj.token) &&
  698. ((msgObj.data.time &&
  699. msgObj.data.time < state.messagesCallbackTime) ||
  700. (eMIs.add(msgObj.token), state.messagesCallback(msgObj.data)))
  701. })),
  702. state
  703. )
  704. },
  705. close: function (channelState) {
  706. var listener
  707. ;(listener = channelState.listener),
  708. window.removeEventListener("storage", listener)
  709. },
  710. onMessage: function (channelState, fn, time) {
  711. ;(channelState.messagesCallbackTime = time),
  712. (channelState.messagesCallback = fn)
  713. },
  714. postMessage: function (channelState, messageJson) {
  715. return new Promise(function (res) {
  716. sleep().then(function () {
  717. var key = storageKey(channelState.channelName),
  718. writeObj = {
  719. token: randomToken(),
  720. time: new Date().getTime(),
  721. data: messageJson,
  722. uuid: channelState.uuid,
  723. },
  724. value = JSON.stringify(writeObj)
  725. getLocalStorage().setItem(key, value)
  726. var ev = document.createEvent("Event")
  727. ev.initEvent("storage", !0, !0),
  728. (ev.key = key),
  729. (ev.newValue = value),
  730. window.dispatchEvent(ev),
  731. res()
  732. })
  733. })
  734. },
  735. canBeUsed: localstorage_canBeUsed,
  736. type: "localstorage",
  737. averageResponseTime: function () {
  738. var userAgent = navigator.userAgent.toLowerCase()
  739. return userAgent.includes("safari") && !userAgent.includes("chrome")
  740. ? 240
  741. : 120
  742. },
  743. microSeconds,
  744. }
  745. var simulate_microSeconds = microSeconds,
  746. SIMULATE_CHANNELS = new Set()
  747. const simulate = {
  748. create: function (channelName) {
  749. var state = { name: channelName, messagesCallback: null }
  750. return SIMULATE_CHANNELS.add(state), state
  751. },
  752. close: function (channelState) {
  753. SIMULATE_CHANNELS.delete(channelState)
  754. },
  755. onMessage: function (channelState, fn) {
  756. channelState.messagesCallback = fn
  757. },
  758. postMessage: function (channelState, messageJson) {
  759. return new Promise(function (res) {
  760. return setTimeout(function () {
  761. Array.from(SIMULATE_CHANNELS)
  762. .filter(function (channel) {
  763. return channel.name === channelState.name
  764. })
  765. .filter(function (channel) {
  766. return channel !== channelState
  767. })
  768. .filter(function (channel) {
  769. return !!channel.messagesCallback
  770. })
  771. .forEach(function (channel) {
  772. return channel.messagesCallback(messageJson)
  773. }),
  774. res()
  775. }, 5)
  776. })
  777. },
  778. canBeUsed: function () {
  779. return !0
  780. },
  781. type: "simulate",
  782. averageResponseTime: function () {
  783. return 5
  784. },
  785. microSeconds: simulate_microSeconds,
  786. }
  787. var METHODS = [methods_native, indexed_db, localstorage]
  788. if (isNode) {
  789. var NodeMethod = __webpack_require__(815)
  790. "function" == typeof NodeMethod.canBeUsed && METHODS.push(NodeMethod)
  791. }
  792. var ENFORCED_OPTIONS,
  793. broadcast_channel_BroadcastChannel = function (name, options) {
  794. var channel, maybePromise, obj
  795. ;(this.name = name),
  796. ENFORCED_OPTIONS && (options = ENFORCED_OPTIONS),
  797. (this.options = options_fillOptionsWithDefaults(options)),
  798. (this.method = (function (options) {
  799. var chooseMethods = []
  800. .concat(options.methods, METHODS)
  801. .filter(Boolean)
  802. if (options.type) {
  803. if ("simulate" === options.type) return simulate
  804. var ret = chooseMethods.find(function (m) {
  805. return m.type === options.type
  806. })
  807. if (ret) return ret
  808. throw new Error("method-type " + options.type + " not found")
  809. }
  810. options.webWorkerSupport ||
  811. isNode ||
  812. (chooseMethods = chooseMethods.filter(function (m) {
  813. return "idb" !== m.type
  814. }))
  815. var useMethod = chooseMethods.find(function (method) {
  816. return method.canBeUsed()
  817. })
  818. if (useMethod) return useMethod
  819. throw new Error(
  820. "No useable methode found:" +
  821. JSON.stringify(
  822. METHODS.map(function (m) {
  823. return m.type
  824. })
  825. )
  826. )
  827. })(this.options)),
  828. (this._iL = !1),
  829. (this._onML = null),
  830. (this._addEL = { message: [], internal: [] }),
  831. (this._uMP = new Set()),
  832. (this._befC = []),
  833. (this._prepP = null),
  834. (maybePromise = (channel = this).method.create(
  835. channel.name,
  836. channel.options
  837. )),
  838. (obj = maybePromise) && "function" == typeof obj.then
  839. ? ((channel._prepP = maybePromise),
  840. maybePromise.then(function (s) {
  841. channel._state = s
  842. }))
  843. : (channel._state = maybePromise)
  844. }
  845. function _post(broadcastChannel, type, msg) {
  846. var msgObj = {
  847. time: broadcastChannel.method.microSeconds(),
  848. type,
  849. data: msg,
  850. }
  851. return (broadcastChannel._prepP
  852. ? broadcastChannel._prepP
  853. : Promise.resolve()
  854. ).then(function () {
  855. var sendPromise = broadcastChannel.method.postMessage(
  856. broadcastChannel._state,
  857. msgObj
  858. )
  859. return (
  860. broadcastChannel._uMP.add(sendPromise),
  861. sendPromise.catch().then(function () {
  862. return broadcastChannel._uMP.delete(sendPromise)
  863. }),
  864. sendPromise
  865. )
  866. })
  867. }
  868. function _hasMessageListeners(channel) {
  869. return (
  870. channel._addEL.message.length > 0 ||
  871. channel._addEL.internal.length > 0
  872. )
  873. }
  874. function _addListenerObject(channel, type, obj) {
  875. channel._addEL[type].push(obj),
  876. (function (channel) {
  877. if (!channel._iL && _hasMessageListeners(channel)) {
  878. var listenerFn = function (msgObj) {
  879. channel._addEL[msgObj.type].forEach(function (obj) {
  880. msgObj.time >= obj.time && obj.fn(msgObj.data)
  881. })
  882. },
  883. time = channel.method.microSeconds()
  884. channel._prepP
  885. ? channel._prepP.then(function () {
  886. ;(channel._iL = !0),
  887. channel.method.onMessage(channel._state, listenerFn, time)
  888. })
  889. : ((channel._iL = !0),
  890. channel.method.onMessage(channel._state, listenerFn, time))
  891. }
  892. })(channel)
  893. }
  894. function _removeListenerObject(channel, type, obj) {
  895. ;(channel._addEL[type] = channel._addEL[type].filter(function (o) {
  896. return o !== obj
  897. })),
  898. (function (channel) {
  899. if (channel._iL && !_hasMessageListeners(channel)) {
  900. channel._iL = !1
  901. var time = channel.method.microSeconds()
  902. channel.method.onMessage(channel._state, null, time)
  903. }
  904. })(channel)
  905. }
  906. ;(broadcast_channel_BroadcastChannel._pubkey = !0),
  907. (broadcast_channel_BroadcastChannel.prototype = {
  908. postMessage: function (msg) {
  909. if (this.closed)
  910. throw new Error(
  911. "BroadcastChannel.postMessage(): Cannot post message after channel has closed"
  912. )
  913. return _post(this, "message", msg)
  914. },
  915. postInternal: function (msg) {
  916. return _post(this, "internal", msg)
  917. },
  918. set onmessage(fn) {
  919. var listenObj = { time: this.method.microSeconds(), fn }
  920. _removeListenerObject(this, "message", this._onML),
  921. fn && "function" == typeof fn
  922. ? ((this._onML = listenObj),
  923. _addListenerObject(this, "message", listenObj))
  924. : (this._onML = null)
  925. },
  926. addEventListener: function (type, fn) {
  927. _addListenerObject(this, type, {
  928. time: this.method.microSeconds(),
  929. fn,
  930. })
  931. },
  932. removeEventListener: function (type, fn) {
  933. _removeListenerObject(
  934. this,
  935. type,
  936. this._addEL[type].find(function (obj) {
  937. return obj.fn === fn
  938. })
  939. )
  940. },
  941. close: function () {
  942. var _this = this
  943. if (!this.closed) {
  944. this.closed = !0
  945. var awaitPrepare = this._prepP ? this._prepP : Promise.resolve()
  946. return (
  947. (this._onML = null),
  948. (this._addEL.message = []),
  949. awaitPrepare
  950. .then(function () {
  951. return Promise.all(Array.from(_this._uMP))
  952. })
  953. .then(function () {
  954. return Promise.all(
  955. _this._befC.map(function (fn) {
  956. return fn()
  957. })
  958. )
  959. })
  960. .then(function () {
  961. return _this.method.close(_this._state)
  962. })
  963. )
  964. }
  965. },
  966. get type() {
  967. return this.method.type
  968. },
  969. })
  970. const external_DeepDiff_namespaceObject = DeepDiff,
  971. external_jsep_namespaceObject = jsep
  972. var external_jsep_default = __webpack_require__.n(
  973. external_jsep_namespaceObject
  974. ),
  975. u = {
  976. "||": function (e, r) {
  977. return e || r
  978. },
  979. "&&": function (e, r) {
  980. return e && r
  981. },
  982. "|": function (e, r) {
  983. return e | r
  984. },
  985. "^": function (e, r) {
  986. return e ^ r
  987. },
  988. "&": function (e, r) {
  989. return e & r
  990. },
  991. "==": function (e, r) {
  992. return e == r
  993. },
  994. "!=": function (e, r) {
  995. return e != r
  996. },
  997. "===": function (e, r) {
  998. return e === r
  999. },
  1000. "!==": function (e, r) {
  1001. return e !== r
  1002. },
  1003. "<": function (e, r) {
  1004. return e < r
  1005. },
  1006. ">": function (e, r) {
  1007. return e > r
  1008. },
  1009. "<=": function (e, r) {
  1010. return e <= r
  1011. },
  1012. ">=": function (e, r) {
  1013. return e >= r
  1014. },
  1015. "<<": function (e, r) {
  1016. return e << r
  1017. },
  1018. ">>": function (e, r) {
  1019. return e >> r
  1020. },
  1021. ">>>": function (e, r) {
  1022. return e >>> r
  1023. },
  1024. "+": function (e, r) {
  1025. return e + r
  1026. },
  1027. "-": function (e, r) {
  1028. return e - r
  1029. },
  1030. "*": function (e, r) {
  1031. return e * r
  1032. },
  1033. "/": function (e, r) {
  1034. return e / r
  1035. },
  1036. "%": function (e, r) {
  1037. return e % r
  1038. },
  1039. },
  1040. i = {
  1041. "-": function (e) {
  1042. return -e
  1043. },
  1044. "+": function (e) {
  1045. return +e
  1046. },
  1047. "~": function (e) {
  1048. return ~e
  1049. },
  1050. "!": function (e) {
  1051. return !e
  1052. },
  1053. }
  1054. function s(e, r) {
  1055. return e.map(function (e) {
  1056. return a(e, r)
  1057. })
  1058. }
  1059. function c(e, r) {
  1060. var n = a(e.object, r)
  1061. return e.computed ? [n, n[a(e.property, r)]] : [n, n[e.property.name]]
  1062. }
  1063. function a(e, r) {
  1064. var n = e
  1065. switch (n.type) {
  1066. case "ArrayExpression":
  1067. return s(n.elements, r)
  1068. case "BinaryExpression":
  1069. return u[n.operator](a(n.left, r), a(n.right, r))
  1070. case "CallExpression":
  1071. var t, o, l
  1072. if (
  1073. ("MemberExpression" === n.callee.type
  1074. ? ((t = (l = c(n.callee, r))[0]), (o = l[1]))
  1075. : (o = a(n.callee, r)),
  1076. "function" != typeof o)
  1077. )
  1078. return
  1079. return o.apply(t, s(n.arguments, r))
  1080. case "ConditionalExpression":
  1081. return a(n.test, r) ? a(n.consequent, r) : a(n.alternate, r)
  1082. case "Identifier":
  1083. return r[n.name]
  1084. case "Literal":
  1085. return n.value
  1086. case "LogicalExpression":
  1087. return "||" === n.operator
  1088. ? a(n.left, r) || a(n.right, r)
  1089. : "&&" === n.operator
  1090. ? a(n.left, r) && a(n.right, r)
  1091. : u[n.operator](a(n.left, r), a(n.right, r))
  1092. case "MemberExpression":
  1093. return c(n, r)[1]
  1094. case "ThisExpression":
  1095. return r
  1096. case "UnaryExpression":
  1097. return i[n.operator](a(n.argument, r))
  1098. default:
  1099. return
  1100. }
  1101. }
  1102. var eqStrict = {
  1103. equals: function (a, b) {
  1104. return a === b
  1105. },
  1106. },
  1107. eqString = eqStrict,
  1108. IO_map = function (ma, f) {
  1109. return function () {
  1110. return f(ma())
  1111. }
  1112. },
  1113. IO_of = constant,
  1114. IO_Functor = { URI: "IO", map: IO_map },
  1115. IO_sequenceArray =
  1116. (flap(IO_Functor),
  1117. (function (f) {
  1118. return (function (f) {
  1119. return function (as) {
  1120. return function () {
  1121. return as.map(function (a, i) {
  1122. return f(i, a)()
  1123. })
  1124. }
  1125. }
  1126. })(function (_, a) {
  1127. return f(a)
  1128. })
  1129. })(function_identity)),
  1130. ReadonlyNonEmptyArray_empty = [],
  1131. isNonEmpty = function (as) {
  1132. return as.length > 0
  1133. },
  1134. append = function (end) {
  1135. return function (init) {
  1136. return concat(init, [end])
  1137. }
  1138. },
  1139. uniq = function (E) {
  1140. return function (as) {
  1141. if (1 === as.length) return as
  1142. for (
  1143. var out = [head(as)],
  1144. _loop_1 = function (a) {
  1145. out.every(function (o) {
  1146. return !E.equals(o, a)
  1147. }) && out.push(a)
  1148. },
  1149. _i = 0,
  1150. rest_1 = tail(as);
  1151. _i < rest_1.length;
  1152. _i++
  1153. ) {
  1154. _loop_1(rest_1[_i])
  1155. }
  1156. return out
  1157. }
  1158. }
  1159. function concat(first, second) {
  1160. return first.concat(second)
  1161. }
  1162. var ReadonlyNonEmptyArray_map = function (fa, f) {
  1163. return function_pipe(fa, es6_ReadonlyNonEmptyArray_map(f))
  1164. },
  1165. es6_ReadonlyNonEmptyArray_map = function (f) {
  1166. return mapWithIndex(function (_, a) {
  1167. return f(a)
  1168. })
  1169. },
  1170. mapWithIndex = function (f) {
  1171. return function (as) {
  1172. for (var out = [f(0, head(as))], i = 1; i < as.length; i++)
  1173. out.push(f(i, as[i]))
  1174. return out
  1175. }
  1176. },
  1177. extract = function (as) {
  1178. return as[0]
  1179. },
  1180. ReadonlyNonEmptyArray_Functor = {
  1181. URI: "ReadonlyNonEmptyArray",
  1182. map: ReadonlyNonEmptyArray_map,
  1183. },
  1184. head = (flap(ReadonlyNonEmptyArray_Functor), extract),
  1185. tail = function (as) {
  1186. return as.slice(1)
  1187. }
  1188. var ReadonlyArray_append = append,
  1189. isEmpty = function (as) {
  1190. return 0 === as.length
  1191. },
  1192. ReadonlyArray_isNonEmpty = isNonEmpty
  1193. var ReadonlyArray_map = function (fa, f) {
  1194. return function_pipe(fa, es6_ReadonlyArray_map(f))
  1195. },
  1196. es6_ReadonlyArray_chain = function (f) {
  1197. return function (ma) {
  1198. return function_pipe(
  1199. ma,
  1200. (function (f) {
  1201. return function (as) {
  1202. if (isEmpty(as)) return ReadonlyArray_empty
  1203. for (var out = [], i = 0; i < as.length; i++)
  1204. out.push.apply(out, f(i, as[i]))
  1205. return out
  1206. }
  1207. })(function (_, a) {
  1208. return f(a)
  1209. })
  1210. )
  1211. }
  1212. },
  1213. es6_ReadonlyArray_map = function (f) {
  1214. return function (fa) {
  1215. return fa.map(function (a) {
  1216. return f(a)
  1217. })
  1218. }
  1219. },
  1220. es6_ReadonlyArray_filter = function (predicate) {
  1221. return function (fa) {
  1222. return fa.filter(predicate)
  1223. }
  1224. },
  1225. filterMapWithIndex = function (f) {
  1226. return function (fa) {
  1227. for (var out = [], i = 0; i < fa.length; i++) {
  1228. var optionB = f(i, fa[i])
  1229. Option_isSome(optionB) && out.push(optionB.value)
  1230. }
  1231. return out
  1232. }
  1233. },
  1234. es6_ReadonlyArray_filterMap = function (f) {
  1235. return filterMapWithIndex(function (_, a) {
  1236. return f(a)
  1237. })
  1238. },
  1239. ReadonlyArray_compact = es6_ReadonlyArray_filterMap(function_identity),
  1240. ReadonlyArray_Functor = {
  1241. URI: "ReadonlyArray",
  1242. map: ReadonlyArray_map,
  1243. },
  1244. toArray =
  1245. (flap(ReadonlyArray_Functor),
  1246. function (as) {
  1247. return as.slice()
  1248. }),
  1249. ReadonlyArray_empty = ReadonlyNonEmptyArray_empty,
  1250. ReadonlyArray_some = function (predicate) {
  1251. return function (as) {
  1252. return as.some(predicate)
  1253. }
  1254. }
  1255. const external_m_namespaceObject = m
  1256. var external_m_default = __webpack_require__.n(external_m_namespaceObject)
  1257. const external_rxjs_namespaceObject = rxjs,
  1258. external_rxjs_operators_namespaceObject = rxjs.operators,
  1259. package_namespaceObject_i8 = "1.15.1",
  1260. indirectConfig = async (gmKey, defaultVal, toItem, toGm) => {
  1261. const val = await GM.getValue(gmKey)
  1262. return {
  1263. gmKey,
  1264. val: void 0 !== val ? toItem(val) : defaultVal,
  1265. defaultVal,
  1266. toGm,
  1267. }
  1268. },
  1269. simpleConfig = async (gmKey, defaultVal) => {
  1270. var _a
  1271. return {
  1272. gmKey,
  1273. val:
  1274. null !== (_a = await GM.getValue(gmKey)) && void 0 !== _a
  1275. ? _a
  1276. : defaultVal,
  1277. defaultVal,
  1278. toGm: x => x,
  1279. }
  1280. },
  1281. lineConfigArgs = [
  1282. [],
  1283. x => x.split(/\r\n|\n/).filter(s => "" !== s),
  1284. x => x.join("\n"),
  1285. ],
  1286. chatApp = () =>
  1287. function_pipe(
  1288. fromNullable(document.querySelector("#chatframe")),
  1289. filter(x => {
  1290. var _a
  1291. const state =
  1292. null === (_a = x.contentDocument) || void 0 === _a
  1293. ? void 0
  1294. : _a.readyState
  1295. return "loading" === state || "complete" === state
  1296. }),
  1297. chainNullableK(x => x.contentDocument),
  1298. alt(() => some(document)),
  1299. chainNullableK(x => x.querySelector("yt-live-chat-app"))
  1300. ),
  1301. mountComponent = x => {
  1302. ;(x.root.style.display = "contents"),
  1303. external_m_default().mount(x.root, x.comp)
  1304. }
  1305. var semigroupVoid = (function (a) {
  1306. return {
  1307. concat: function () {
  1308. return a
  1309. },
  1310. }
  1311. })(void 0),
  1312. Semigroup_concatAll = function (S) {
  1313. return function (startWith) {
  1314. return function (as) {
  1315. return as.reduce(S.concat, startWith)
  1316. }
  1317. }
  1318. }
  1319. semigroupVoid.concat
  1320. var Monoid_concatAll = function (M) {
  1321. return Semigroup_concatAll(M)(M.empty)
  1322. },
  1323. monoidAll = {
  1324. concat: function (x, y) {
  1325. return x && y
  1326. },
  1327. empty: !0,
  1328. },
  1329. monoidAny = {
  1330. concat: function (x, y) {
  1331. return x || y
  1332. },
  1333. empty: !1,
  1334. }
  1335. var Eq = eqString
  1336. const external_Swal_namespaceObject = Swal
  1337. var external_Swal_default = __webpack_require__.n(
  1338. external_Swal_namespaceObject
  1339. )
  1340. const addBanButton_button = document.createElement("button")
  1341. addBanButton_button.classList.add(
  1342. "style-scope",
  1343. "yt-icon-button",
  1344. "fyc_button"
  1345. ),
  1346. (addBanButton_button.style.padding = "0px"),
  1347. (addBanButton_button.style.width = "20px"),
  1348. (addBanButton_button.style.height = "20px"),
  1349. (addBanButton_button.style.fill = "#fff"),
  1350. addBanButton_button.setAttribute(
  1351. "aria-label",
  1352. "NGに入れる(Ban this user)"
  1353. ),
  1354. (addBanButton_button.innerHTML =
  1355. '<svg class="style-scope yt-icon" style="width: 100%; height: 75%; fill: var(--yt-spec-text-secondary);" viewBox="0 0 512 512"><path d="M440 78A256 256 0 1 0 73 435 256 256 0 0 0 440 78zm-99 35L113 341C37 179 212 44 341 113zM177 405l228-228c76 162-99 297-228 228z" fill-rule="evenodd"/></svg>')
  1356. const addBanButton = (chat, id, getConfig, setConfig) => {
  1357. var _a
  1358. if (chat.children.namedItem("card")) return
  1359. const buttonClone = addBanButton_button.cloneNode(!0)
  1360. ;(buttonClone.onclick = () => {
  1361. const users = getConfig.bannedUsers()
  1362. users.includes(id) ||
  1363. (setConfig.bannedUsers(
  1364. function_pipe(
  1365. users,
  1366. (function (E) {
  1367. var f = uniq(E)
  1368. return function (as) {
  1369. return ReadonlyArray_isNonEmpty(as) ? f(as) : as
  1370. }
  1371. })(Eq),
  1372. ReadonlyArray_append(id),
  1373. toArray
  1374. )
  1375. ),
  1376. external_m_default().redraw(),
  1377. external_Swal_default()
  1378. .mixin({
  1379. toast: !0,
  1380. position: "bottom-left",
  1381. timer: 2500,
  1382. timerProgressBar: !0,
  1383. showConfirmButton: !1,
  1384. didOpen: toast => {
  1385. toast.addEventListener(
  1386. "mouseenter",
  1387. external_Swal_default().stopTimer
  1388. ),
  1389. toast.addEventListener(
  1390. "mouseleave",
  1391. external_Swal_default().resumeTimer
  1392. )
  1393. },
  1394. })
  1395. .fire({ title: `Added Banned User: ${id}`, icon: "success" })),
  1396. (chat.style.display = "none")
  1397. }),
  1398. null === (_a = chat.querySelector("#content #message")) ||
  1399. void 0 === _a ||
  1400. _a.append(buttonClone)
  1401. },
  1402. getChatFontSize = (mainState, getConfig) =>
  1403. Math.round(
  1404. Math.max(getConfig.fontSize() - 0.2, 0.01) *
  1405. (mainState.playerRect.height / getConfig.laneCount()) *
  1406. 100
  1407. ) / 100,
  1408. external_window_micro_memoize_namespaceObject = window["micro-memoize"]
  1409. var external_window_micro_memoize_default = __webpack_require__.n(
  1410. external_window_micro_memoize_namespaceObject
  1411. )
  1412. const getFlowChatProgress = chat => {
  1413. var _a, _b
  1414. return (
  1415. (null !==
  1416. (_b =
  1417. null === (_a = chat.animation) || void 0 === _a
  1418. ? void 0
  1419. : _a.currentTime) && void 0 !== _b
  1420. ? _b
  1421. : 0) / chat.animationDuration
  1422. )
  1423. },
  1424. getFlowChatRect = (chat, mainState) => {
  1425. const x =
  1426. mainState.playerRect.width -
  1427. (chat.width + mainState.playerRect.width) *
  1428. getFlowChatProgress(chat)
  1429. return new DOMRect(x, chat.y, chat.width, chat.height)
  1430. },
  1431. getChatLane = (flowChat, progress, flowChats, mainState, getConfig) => {
  1432. const playerWidth = mainState.playerRect.width,
  1433. chatRect = getFlowChatRect(flowChat, mainState),
  1434. chatWidth = chatRect.width,
  1435. chatHeight = chatRect.height,
  1436. chatX = chatRect.x,
  1437. chatIndex = flowChats.indexOf(flowChat),
  1438. movingChats =
  1439. ((as = flowChats
  1440. .slice(0, chatIndex >= 0 ? chatIndex : void 0)
  1441. .filter(chat => !chat.animationEnded)
  1442. .sort((a, b) => a.lane - b.lane)),
  1443. isEmpty(as) ? ReadonlyArray_empty : as.slice())
  1444. var as
  1445. const tooCloseTo = external_window_micro_memoize_default()(
  1446. i => {
  1447. const otherRect = getFlowChatRect(movingChats[i], mainState),
  1448. otherWidth = otherRect.width,
  1449. otherX = otherRect.x,
  1450. gap =
  1451. (chatHeight * otherWidth * chatWidth) ** 0.333 *
  1452. getConfig.minSpacing()
  1453. return (
  1454. (playerWidth - otherX) / (playerWidth + otherWidth) -
  1455. progress <
  1456. (chatWidth + gap) / (playerWidth + chatWidth) ||
  1457. otherX + otherWidth + gap > chatX
  1458. )
  1459. },
  1460. { maxSize: 1e3 }
  1461. ),
  1462. occupyInfo = [
  1463. ...movingChats.map((x, i) => ({
  1464. tooClose: () => tooCloseTo(i),
  1465. lane: x.lane,
  1466. })),
  1467. { tooClose: () => !0, lane: getConfig.laneCount() },
  1468. ],
  1469. index = occupyInfo.findIndex(x => x.lane >= flowChat.lane),
  1470. rightFreeLane = occupyInfo
  1471. .slice(index)
  1472. .findIndex(x => x.tooClose()),
  1473. leftFreeLane = function_pipe(
  1474. occupyInfo.slice(0, index),
  1475. ((predicate = x => x.tooClose()),
  1476. function (as) {
  1477. for (var i = as.length - 1; i >= 0; i--)
  1478. if (predicate(as[i])) return some(i)
  1479. return none
  1480. }),
  1481. getOrElse(() => -1)
  1482. )
  1483. var predicate
  1484. let formerLaneInterval = 0
  1485. leftFreeLane < flowChat.lane &&
  1486. flowChat.lane < rightFreeLane &&
  1487. (formerLaneInterval = Math.min(
  1488. Math.max(
  1489. formerLaneInterval,
  1490. Math.min(
  1491. flowChat.lane - leftFreeLane,
  1492. rightFreeLane - flowChat.lane
  1493. )
  1494. ),
  1495. 1
  1496. ))
  1497. let maxInterval = 0,
  1498. maxIntervalLane = 0,
  1499. lastLane = -1
  1500. for (let i = 0; i < occupyInfo.length; i += 1)
  1501. if (occupyInfo[i].tooClose()) {
  1502. const nextLane = occupyInfo[i].lane,
  1503. interLane = Math.min(
  1504. Math.max((lastLane + nextLane) / 2, 0),
  1505. getConfig.laneCount() - 1
  1506. ),
  1507. newInterval = Math.min(
  1508. interLane - lastLane,
  1509. nextLane - interLane,
  1510. 1
  1511. )
  1512. if (
  1513. newInterval - maxInterval > 0.001 &&
  1514. ((maxIntervalLane = Math.max(lastLane + newInterval, 0)),
  1515. (maxInterval = newInterval),
  1516. maxInterval > 0.999)
  1517. )
  1518. break
  1519. lastLane = nextLane
  1520. }
  1521. return {
  1522. lane:
  1523. Math.abs(formerLaneInterval - maxInterval) < 0.001
  1524. ? flowChat.lane
  1525. : maxIntervalLane,
  1526. interval: maxInterval,
  1527. }
  1528. },
  1529. external_window_hash_it_namespaceObject = window["hash-it"]
  1530. var external_window_hash_it_default = __webpack_require__.n(
  1531. external_window_hash_it_namespaceObject
  1532. )
  1533. const setChatPlayState = (flowChat, mainState, getConfig) => {
  1534. !flowChat.animationEnded &&
  1535. flowChat.animation &&
  1536. (mainState.chatPlaying
  1537. ? flowChat.animation.play()
  1538. : flowChat.animation.pause(),
  1539. (flowChat.animation.playbackRate = getConfig.flowSpeed() / 15))
  1540. },
  1541. getWidth = external_window_micro_memoize_default()(
  1542. ele => ele.getBoundingClientRect().width,
  1543. {
  1544. maxSize: 2e3,
  1545. transformKey: args => args.map(external_window_hash_it_default()),
  1546. }
  1547. ),
  1548. setChatAnimation = (chat, chats, mainState, getConfig) => {
  1549. var _a
  1550. const fontSize = getChatFontSize(mainState, getConfig)
  1551. if (
  1552. ((chat.element.style.transform = `translate(${
  1553. mainState.playerRect.width
  1554. }px, -${2 * fontSize}px)`),
  1555. chat.animationEnded)
  1556. )
  1557. return !1
  1558. ;(chat.animationDuration = 6400),
  1559. (chat.width = getWidth(chat.element)),
  1560. (chat.height = fontSize)
  1561. const progress = getFlowChatProgress(chat),
  1562. { lane, interval } = getChatLane(
  1563. chat,
  1564. progress,
  1565. chats,
  1566. mainState,
  1567. getConfig
  1568. )
  1569. if (getConfig.noOverlap() && interval < 0.999)
  1570. return (
  1571. null === (_a = chat.animation) || void 0 === _a || _a.finish(),
  1572. (chat.animation = void 0),
  1573. !1
  1574. )
  1575. chat.lane = lane
  1576. const laneY = ((lane, mainState, getConfig) =>
  1577. (mainState.playerRect.height * lane) / getConfig.laneCount() + 4)(
  1578. chat.lane,
  1579. mainState,
  1580. getConfig
  1581. )
  1582. chat.animation && chat.animation.cancel(),
  1583. (chat.animation = chat.element.animate(
  1584. [
  1585. {
  1586. transform: `translate(${mainState.playerRect.width}px, ${laneY}px)`,
  1587. },
  1588. { transform: `translate(${-chat.width}px, ${laneY}px)` },
  1589. ],
  1590. { duration: 6400, easing: getConfig.timingFunction() }
  1591. )),
  1592. (chat.animation.onfinish = () => {
  1593. chat.animationEnded = !0
  1594. }),
  1595. (chat.y = laneY)
  1596. const newTime = 6400 * progress
  1597. return (
  1598. (chat.animation.currentTime = newTime),
  1599. setChatPlayState(chat, mainState, getConfig),
  1600. !0
  1601. )
  1602. },
  1603. textStyle = { fontFamily: "inherit" },
  1604. chatNode = (data, mainState, getConfig) =>
  1605. external_m_default()(
  1606. "span",
  1607. {
  1608. style: {
  1609. fontSize: `${getChatFontSize(mainState, getConfig)}px`,
  1610. visibility: getConfig.displayChats() ? "visible" : "hidden",
  1611. color:
  1612. "owner" === data.authorType
  1613. ? getConfig.ownerColor()
  1614. : "moderator" === data.authorType
  1615. ? getConfig.moderatorColor()
  1616. : "member" === data.authorType
  1617. ? getConfig.memberColor()
  1618. : getConfig.color(),
  1619. fontWeight: getConfig.fontWeight().toString(),
  1620. fontFamily: getConfig.font(),
  1621. opacity: getConfig.chatOpacity().toString(),
  1622. ...function_pipe(
  1623. getConfig.shadowFontWeight(),
  1624. x => `${x}px`,
  1625. x => ({
  1626. textShadow: `-${x} -${x} #0009, ${x} -${x} #0009, -${x} ${x} #0009, ${x} ${x} #0009`,
  1627. })
  1628. ),
  1629. },
  1630. },
  1631. function_pipe(
  1632. [
  1633. function_pipe(
  1634. data.authorName,
  1635. filter(x => x.visible),
  1636. es6_Option_map(x =>
  1637. external_m_default()(
  1638. "span",
  1639. {
  1640. style: {
  1641. color: toUndefined(data.textColor),
  1642. fontSize: "0.84em",
  1643. ...textStyle,
  1644. },
  1645. },
  1646. `${x.content}: `
  1647. )
  1648. )
  1649. ),
  1650. function_pipe(
  1651. data.message,
  1652. es6_Option_map(x =>
  1653. ((message, getConfig) => {
  1654. var _a
  1655. const eleWin =
  1656. null !== (_a = message.ownerDocument.defaultView) &&
  1657. void 0 !== _a
  1658. ? _a
  1659. : window,
  1660. maxChatLength = getConfig.maxChatLength(),
  1661. vnodes = []
  1662. let length = 0
  1663. return (
  1664. Array.from(message.childNodes).some(node => {
  1665. var _a, _b
  1666. if (
  1667. !getConfig.textOnly() &&
  1668. node instanceof eleWin.HTMLImageElement
  1669. ) {
  1670. const { src, alt } = node
  1671. vnodes.push(
  1672. external_m_default()("img", {
  1673. style: {
  1674. height: "1em",
  1675. width: "1em",
  1676. verticalAlign: "text-top",
  1677. },
  1678. src,
  1679. alt,
  1680. })
  1681. ),
  1682. (length += 1)
  1683. } else if (node instanceof eleWin.HTMLAnchorElement) {
  1684. const beginning = (null !==
  1685. (_a = node.textContent) && void 0 !== _a
  1686. ? _a
  1687. : ""
  1688. ).slice(0, maxChatLength)
  1689. vnodes.push(
  1690. external_m_default()(
  1691. "span",
  1692. {
  1693. style: {
  1694. fontSize: "0.84em",
  1695. textDecoration: "underline",
  1696. ...textStyle,
  1697. },
  1698. },
  1699. beginning
  1700. )
  1701. ),
  1702. (length += beginning.length)
  1703. } else {
  1704. const beginning = (null !==
  1705. (_b = node.textContent) && void 0 !== _b
  1706. ? _b
  1707. : ""
  1708. ).slice(0, maxChatLength)
  1709. vnodes.push(
  1710. external_m_default().fragment({}, beginning)
  1711. ),
  1712. (length += beginning.length)
  1713. }
  1714. return length >= maxChatLength
  1715. }),
  1716. { vnodes, length }
  1717. )
  1718. })(x, getConfig)
  1719. ),
  1720. es6_Option_map(x =>
  1721. external_m_default()(
  1722. "span",
  1723. {
  1724. style: {
  1725. color: toUndefined(data.textColor),
  1726. ...textStyle,
  1727. },
  1728. },
  1729. x.vnodes
  1730. )
  1731. )
  1732. ),
  1733. function_pipe(
  1734. data.paymentInfo,
  1735. filter(x => x.visible),
  1736. es6_Option_map(x =>
  1737. external_m_default()(
  1738. "span",
  1739. {
  1740. style: {
  1741. color: toUndefined(data.paidColor),
  1742. fontSize: "0.84em",
  1743. ...textStyle,
  1744. },
  1745. },
  1746. external_m_default()(
  1747. "strong",
  1748. { style: textStyle },
  1749. x.content
  1750. )
  1751. )
  1752. )
  1753. ),
  1754. ],
  1755. ReadonlyArray_compact
  1756. ).slice()
  1757. ),
  1758. setChatStyle = (chat, mainState, getConfig) =>
  1759. external_m_default().render(
  1760. chat.element,
  1761. chatNode(chat.data, mainState, getConfig)
  1762. ),
  1763. emptyElement = document.createElement("span")
  1764. var MonoidAny = monoidAny
  1765. const basicOperators = {
  1766. some: ReadonlyArray_some,
  1767. every: function (predicate) {
  1768. return function (as) {
  1769. return as.every(predicate)
  1770. }
  1771. },
  1772. size: function (as) {
  1773. return as.length
  1774. },
  1775. filter: es6_ReadonlyArray_filter,
  1776. compact: ReadonlyArray_compact,
  1777. allPredicates: Monoid_concatAll(function_getMonoid(monoidAll)()),
  1778. anyPredicates: Monoid_concatAll(function_getMonoid(MonoidAny)()),
  1779. matchesWords: words => text =>
  1780. function_pipe(
  1781. words,
  1782. ReadonlyArray_some(x => text.content.includes(x))
  1783. ),
  1784. matchesRegexes: regexes => text =>
  1785. function_pipe(
  1786. regexes,
  1787. ReadonlyArray_some(x =>
  1788. Boolean(text.content.match(RegExp(x, "u")))
  1789. )
  1790. ),
  1791. isVisible: x => x.visible,
  1792. },
  1793. evalChatFilter = (expression, data) =>
  1794. a(
  1795. expression,
  1796. (data => ({
  1797. ...basicOperators,
  1798. authorName: data.authorName,
  1799. message: function_pipe(
  1800. data.message,
  1801. es6_Option_map(x => ({ visible: !0, content: x.innerHTML }))
  1802. ),
  1803. messageText: function_pipe(
  1804. data.message,
  1805. es6_Option_map(x => {
  1806. var _a
  1807. return {
  1808. visible: !0,
  1809. content:
  1810. null !== (_a = x.textContent) && void 0 !== _a ? _a : "",
  1811. }
  1812. })
  1813. ),
  1814. paymentInfo: data.paymentInfo,
  1815. }))(data)
  1816. ),
  1817. assert_lib = check.assert,
  1818. tapNonNull = x => (assert_lib(null != x), x),
  1819. onChatFieldMutate = (
  1820. chatScrn,
  1821. flowChats,
  1822. mainState,
  1823. getConfig,
  1824. setConfig,
  1825. mainLog
  1826. ) => mutations => {
  1827. function_pipe(
  1828. mutations,
  1829. es6_ReadonlyArray_chain(e => Array.from(e.addedNodes)),
  1830. es6_ReadonlyArray_filter(x => x.children.length > 0)
  1831. ).forEach(chat => {
  1832. const chatData = (chat => {
  1833. var _a, _b, _c
  1834. const authorType = chat.querySelector(".owner")
  1835. ? "owner"
  1836. : chat.querySelector(".moderator")
  1837. ? "moderator"
  1838. : chat.querySelector(".member")
  1839. ? "member"
  1840. : "normal",
  1841. authorName = fromNullable(
  1842. null === (_a = chat.querySelector("#author-name")) ||
  1843. void 0 === _a
  1844. ? void 0
  1845. : _a.textContent
  1846. ),
  1847. message = fromNullable(chat.querySelector("#message")),
  1848. isCard = Boolean(chat.querySelector("#card")),
  1849. isPaidNormal =
  1850. !!isCard &&
  1851. Boolean(
  1852. chat.querySelector(
  1853. [
  1854. ".style-scope",
  1855. ".yt-live-chat-paid-message-renderer",
  1856. ].join("")
  1857. )
  1858. ),
  1859. isPaidSticker =
  1860. !!isCard &&
  1861. Boolean(
  1862. chat.querySelector(
  1863. [
  1864. ".style-scope",
  1865. ".yt-live-chat-paid-sticker-renderer",
  1866. ].join("")
  1867. )
  1868. ),
  1869. paymentInfo = fromNullable(
  1870. isCard
  1871. ? null ===
  1872. (_b = chat.querySelector(
  1873. ["#purchase-amount", "#purchase-amount-chip"].join(
  1874. ", "
  1875. )
  1876. )) || void 0 === _b
  1877. ? void 0
  1878. : _b.textContent
  1879. : void 0
  1880. ),
  1881. textColor = fromNullable(
  1882. isPaidNormal
  1883. ? window
  1884. .getComputedStyle(
  1885. tapNonNull(chat.querySelector("#header"))
  1886. )
  1887. .getPropertyValue("background-color")
  1888. : isPaidSticker
  1889. ? window
  1890. .getComputedStyle(chat)
  1891. .getPropertyValue(
  1892. "--yt-live-chat-paid-sticker-chip-background-color"
  1893. )
  1894. : void 0
  1895. ),
  1896. paidColor = fromNullable(
  1897. isPaidNormal
  1898. ? window
  1899. .getComputedStyle(
  1900. tapNonNull(chat.querySelector("#content"))
  1901. )
  1902. .getPropertyValue("background-color")
  1903. : isPaidSticker
  1904. ? window
  1905. .getComputedStyle(chat)
  1906. .getPropertyValue(
  1907. "--yt-live-chat-paid-sticker-background-color"
  1908. )
  1909. : void 0
  1910. ),
  1911. authorPhotoMatches =
  1912. null ===
  1913. (_c = chat.querySelector(
  1914. ["#author-photo", "img"].join(" ")
  1915. )) || void 0 === _c
  1916. ? void 0
  1917. : _c.src.match(/ytc\/(.*)=/)
  1918. return {
  1919. authorType,
  1920. authorID: fromNullable(
  1921. null == authorPhotoMatches
  1922. ? void 0
  1923. : authorPhotoMatches[authorPhotoMatches.length - 1]
  1924. ),
  1925. authorName,
  1926. message,
  1927. paymentInfo,
  1928. textColor,
  1929. paidColor,
  1930. }
  1931. })(chat),
  1932. displayData = ((data, getConfig) => ({
  1933. authorType: data.authorType,
  1934. authorName: function_pipe(
  1935. data.authorName,
  1936. es6_Option_map(x => ({
  1937. visible:
  1938. ("moderator" === data.authorType &&
  1939. getConfig.displayModName()) ||
  1940. (Option_isSome(data.paymentInfo) &&
  1941. getConfig.displaySuperChatAuthor()),
  1942. content: x,
  1943. }))
  1944. ),
  1945. message: data.message,
  1946. paymentInfo: function_pipe(
  1947. data.paymentInfo,
  1948. es6_Option_map(x => ({ visible: !0, content: x }))
  1949. ),
  1950. textColor: data.textColor,
  1951. paidColor: data.paidColor,
  1952. }))(chatData, getConfig)
  1953. var predicate
  1954. ;((data, mainState, getConfig, mainLog) =>
  1955. function_pipe(
  1956. data,
  1957. fromPredicate(() =>
  1958. function_pipe(
  1959. mainState.filterExp,
  1960. es6_Option_map(x => evalChatFilter(x, data)),
  1961. getOrElse(() => !1)
  1962. )
  1963. ),
  1964. chain(x => x.message),
  1965. match(
  1966. () => () => !1,
  1967. x => () => (
  1968. mainLog(`Banned chat: ${JSON.stringify(x.innerHTML)}`), !0
  1969. )
  1970. )
  1971. )())(displayData, mainState, 0, mainLog) ||
  1972. function_pipe(
  1973. chatData.authorID,
  1974. ((predicate = x =>
  1975. ((authorID, getConfig, mainLog) =>
  1976. getConfig
  1977. .bannedUsers()
  1978. .some(
  1979. user =>
  1980. !(
  1981. authorID !== user ||
  1982. (mainLog(`Banned User: "${authorID}"`), 0)
  1983. )
  1984. ))(x, getConfig, mainLog)),
  1985. function (ma) {
  1986. return !isNone(ma) && predicate(ma.value)
  1987. })
  1988. )
  1989. ? (chat.style.display = "none")
  1990. : (getConfig.createChats() &&
  1991. !chat.querySelector(
  1992. [
  1993. ".yt-live-chat-viewer-engagement-message-renderer",
  1994. ".yt-live-chat-membership-item-renderer",
  1995. ].join(",")
  1996. ) &&
  1997. ((data, flowChats, chatScrn, mainState, getConfig) => {
  1998. var _a
  1999. const emptyChat = {
  2000. data,
  2001. element: emptyElement,
  2002. lane: -1,
  2003. animation: void 0,
  2004. animationDuration: 0,
  2005. animationEnded: !1,
  2006. width: 2,
  2007. height: getChatFontSize(mainState, getConfig),
  2008. y: 0,
  2009. }
  2010. if (
  2011. getConfig.noOverlap() &&
  2012. getChatLane(emptyChat, 0, flowChats, mainState, getConfig)
  2013. .interval < 0.999
  2014. )
  2015. return
  2016. let element
  2017. const offScreenChatIndex = flowChats.findIndex(
  2018. chat =>
  2019. chat.animationEnded ||
  2020. flowChats.length >= getConfig.maxChatCount()
  2021. )
  2022. if (-1 !== offScreenChatIndex) {
  2023. element = flowChats[offScreenChatIndex].element
  2024. const [oldChat] = flowChats.splice(offScreenChatIndex, 1)
  2025. null === (_a = oldChat.animation) ||
  2026. void 0 === _a ||
  2027. _a.cancel()
  2028. } else
  2029. external_log_default().debug("CreateFlowChat"),
  2030. (element = document.createElement("span")),
  2031. chatScrn.append(element)
  2032. const flowChat = {
  2033. data,
  2034. element,
  2035. lane: -1,
  2036. animation: void 0,
  2037. animationDuration: 0,
  2038. animationEnded: !1,
  2039. width: 2,
  2040. height: getChatFontSize(mainState, getConfig),
  2041. y: 0,
  2042. }
  2043. element.classList.add("fyc_chat"),
  2044. setChatStyle(flowChat, mainState, getConfig),
  2045. setChatAnimation(
  2046. flowChat,
  2047. flowChats,
  2048. mainState,
  2049. getConfig
  2050. )
  2051. ? flowChats.push(flowChat)
  2052. : flowChat.element.remove()
  2053. })(displayData, flowChats, chatScrn, mainState, getConfig),
  2054. function_pipe(
  2055. chatData.authorID,
  2056. filter(
  2057. () =>
  2058. getConfig.createBanButton() &&
  2059. !chat.querySelector(".owner")
  2060. ),
  2061. match(
  2062. () => () => {},
  2063. x => () => addBanButton(chat, x, getConfig, setConfig)
  2064. )
  2065. )(),
  2066. getConfig.simplifyChatField() &&
  2067. (chat => {
  2068. if (
  2069. chat.querySelector(
  2070. ".style-scope.yt-live-chat-paid-message-renderer"
  2071. ) ||
  2072. chat.querySelector(".owner")
  2073. )
  2074. return
  2075. chat.style.borderBottom =
  2076. "1px solid var(--yt-spec-text-secondary)"
  2077. const authorPhoto = chat.querySelector("#author-photo")
  2078. authorPhoto && (authorPhoto.style.display = "none")
  2079. const authorChip = chat.querySelector(
  2080. "yt-live-chat-author-chip.style-scope.yt-live-chat-text-message-renderer"
  2081. )
  2082. authorChip && (authorChip.style.display = "none")
  2083. })(chat))
  2084. })
  2085. },
  2086. removeOldChats = (flowChats, maxChatCount) => {
  2087. flowChats.sort((a, b) =>
  2088. a.animationEnded === b.animationEnded
  2089. ? 0
  2090. : a.animationEnded
  2091. ? -1
  2092. : 1
  2093. ),
  2094. flowChats
  2095. .splice(0, Math.max(0, flowChats.length - maxChatCount))
  2096. .forEach(x => {
  2097. external_log_default().debug("RemoveChat"), x.element.remove()
  2098. })
  2099. }
  2100. var fast_deep_equal = __webpack_require__(378),
  2101. fast_deep_equal_default = __webpack_require__.n(fast_deep_equal)
  2102. const textRecord = {
  2103. font: ["Font", "フォント"],
  2104. color: ["Color(Normal)", "色(通常)"],
  2105. ownerColor: ["Color(Owner)", "色(オーナー)"],
  2106. moderatorColor: ["Color(Moderator)", "色(モデレーター)"],
  2107. memberColor: ["Color(Member)", "色(メンバー)"],
  2108. feedback: ["Feedback", "バグ報告と要望"],
  2109. eventLog: ["Event log", "イベントログ"],
  2110. giveFeedback: [
  2111. "Give your feedbacks here(Please attach the event log if they're bug related)",
  2112. "バグ報告、要望はこちら(バグの場合は、イベントログを添付してください)",
  2113. ],
  2114. chatOpacity: ["Opacity", "不透明度"],
  2115. fontSize: ["Size", "サイズ"],
  2116. fontWeight: ["Weight", "太さ"],
  2117. shadowFontWeight: ["Weight(Shadow)", "太さ(影)"],
  2118. flowSpeed: ["Speed", "速度"],
  2119. maxChatCount: ["Max number of chats", "最大表示数"],
  2120. maxChatLength: ["Max number of characters", "最大文字数"],
  2121. laneCount: ["Number of rows", "行数"],
  2122. bannedWords: ["Banned Words", "NGワード"],
  2123. bannedWordRegexs: ["Banned Words(Regex)", "NGワード(正規表現)"],
  2124. bannedUsers: ["Banned Users", "NGユーザー"],
  2125. simplifyChatField: ["Simplify", "簡略化する"],
  2126. createBanButton: ["Show ban button", "NGボタンを表示する"],
  2127. displayModName: [
  2128. "Show moderator's name",
  2129. "モデレータの名前を表示する",
  2130. ],
  2131. displaySuperChatAuthor: [
  2132. "Show super chat author",
  2133. "スパチャの作成者を表示する",
  2134. ],
  2135. createChats: ["Display flowing chats", "チャットを流す"],
  2136. textOnly: ["Text only(ignore emojis)", "文字のみ(絵文字を無視する)"],
  2137. error: ["Error", "エラー"],
  2138. video: ["Video", "画面"],
  2139. chatField: ["Chat Window", "チャット欄"],
  2140. useStepTiming: ["Move chat in steps", "チャットを段階的に動かす"],
  2141. timingStepCount: ["└Step Count", "└段階数"],
  2142. chatFilter: ["Chat Filter", "チャットフィルター"],
  2143. flowChat: ["Flow Chat", "チャット流れ"],
  2144. clearFlowChats: ["Clear Flowing Chats", "流れるチャットをクリアする"],
  2145. flowNewChatIf: [
  2146. "A new chat will appear if all of the followings are met:",
  2147. "新しいチャットは以下のすべてを満たす場合に流れます:",
  2148. ],
  2149. noOverlap: ["└Chats won't overlap", "└他のチャットと重ならない"],
  2150. minSpacing: ["Min spacing between chats", "チャットの最小間隔"],
  2151. fieldScale: ["Scale", "拡大率"],
  2152. copy: ["Copy", "コピーする"],
  2153. showChat: ["Show Chats", "チャット非表示"],
  2154. hideChat: ["Hide Chats", "チャット表示"],
  2155. },
  2156. getLang = getConfig => key =>
  2157. textRecord[key]["FYC_EN" === getConfig.lang() ? 0 : 1],
  2158. settingPanel_option = (value, label) =>
  2159. external_m_default()("option", { value }, label),
  2160. settingRow = (label, content) =>
  2161. external_m_default()("div", [
  2162. external_m_default()("span", label),
  2163. external_m_default()("div", content),
  2164. ]),
  2165. tabContainer = (style, labels, tabs, currentTab, ontabSelect) => {
  2166. var _a
  2167. return external_m_default()("div", [
  2168. external_m_default()(
  2169. "div",
  2170. ...labels.map((x, i) =>
  2171. external_m_default()(
  2172. "span",
  2173. {
  2174. style: {
  2175. ...style.label,
  2176. ...(currentTab === i ? style.labelFocus : {}),
  2177. display: "inline-block",
  2178. },
  2179. onclick: () => ontabSelect(i),
  2180. },
  2181. x
  2182. )
  2183. )
  2184. ),
  2185. external_m_default()(
  2186. "div",
  2187. { style: { ...style.container, overflow: "hidden auto" } },
  2188. external_m_default()(
  2189. "div",
  2190. { style: { ...style.tab } },
  2191. null === (_a = tabs.find((_, i) => i === currentTab)) ||
  2192. void 0 === _a
  2193. ? void 0
  2194. : _a()
  2195. )
  2196. ),
  2197. ])
  2198. },
  2199. textColorRow = (color, textStyle, oninput) =>
  2200. external_m_default()("div", [
  2201. external_m_default()("input", {
  2202. style: { width: "36px", verticalAlign: "middle" },
  2203. type: "color",
  2204. value: color,
  2205. oninput,
  2206. }),
  2207. external_m_default()("input", {
  2208. style: { verticalAlign: "middle", width: "5.5em" },
  2209. maxlength: 20,
  2210. value: color,
  2211. oninput,
  2212. }),
  2213. external_m_default()(
  2214. "span",
  2215. { style: { ...textStyle, color } },
  2216. "Aa1あア亜"
  2217. ),
  2218. ]),
  2219. rangeRow = (min, max, step, value, oninput) =>
  2220. external_m_default()("div", [
  2221. external_m_default()("input", {
  2222. style: { width: "150px", verticalAlign: "middle" },
  2223. type: "range",
  2224. min,
  2225. max,
  2226. step,
  2227. value,
  2228. oninput,
  2229. }),
  2230. external_m_default()("input", {
  2231. style: {
  2232. width: "30px",
  2233. backgroundColor: "transparent",
  2234. color: "inherit",
  2235. borderWidth: "1px",
  2236. verticalAlign: "middle",
  2237. },
  2238. inputmode: "decimal",
  2239. value,
  2240. onchange: oninput,
  2241. }),
  2242. ]),
  2243. textAreaStyle = {
  2244. resize: "horizontal",
  2245. boxSizing: "border-box",
  2246. width: "100%",
  2247. },
  2248. panelBoxStyle = width => ({ flex: `0 0 ${width}px`, margin: "2px" }),
  2249. inputRowStyle = { width: "70%", boxSizing: "border-box" },
  2250. textAreaRow = (rows, value, onchange) =>
  2251. external_m_default()(
  2252. "textarea",
  2253. { rows: 18, style: textAreaStyle, onchange },
  2254. value.join("\n")
  2255. ),
  2256. getInputValue = e => {
  2257. const target = e.currentTarget
  2258. if (
  2259. target instanceof HTMLSelectElement ||
  2260. target instanceof HTMLTextAreaElement ||
  2261. target instanceof HTMLInputElement
  2262. )
  2263. return target.value
  2264. throw Error("Event target type isn't acceptable.")
  2265. },
  2266. getInputChecked = e => {
  2267. return ((constructor = HTMLInputElement),
  2268. (x = e.currentTarget),
  2269. assert_lib(x instanceof constructor),
  2270. x).checked
  2271. var constructor, x
  2272. },
  2273. langOptions = [
  2274. ["FYC_EN", "English"],
  2275. ["FYC_JA", "日本語"],
  2276. ],
  2277. fontOptions = currentFont => [
  2278. ["", "Default", "デフォルト"],
  2279. ["arial", "Arial", "Arial"],
  2280. ["arial black", "Arial Black", "Arial Black"],
  2281. ["arial narrow", "Arial Narrow", "Arial Narrow"],
  2282. ["Century", "Century", "Century"],
  2283. ["Comic Sans MS", "Comic Sans MS", "Comic Sans MS"],
  2284. ["Courier", "Courier", "Courier"],
  2285. ["cursive", "cursive", "cursive"],
  2286. ["fantasy", "fantasy", "fantasy"],
  2287. ["Impact", "Impact", "Impact"],
  2288. ["Meiryo", "Meiryo", "メイリオ"],
  2289. ["Meiryo UI", "Meiryo UI", "メイリオ UI"],
  2290. ["monospace", "monospace", "monospace"],
  2291. ["Monotype Corsiva", "Monotype Corsiva", "Monotype Corsiva"],
  2292. ["MS PGothic", "MS PGothic", "MS Pゴシック"],
  2293. ["MS Gothic", "MS Gothic", "MS ゴシック"],
  2294. ["MS Sans Serif", "MS Sans Serif", "MS Sans Serif"],
  2295. ["MS Serif", "MS Serif", "MS Serif"],
  2296. ["MS UI Gothic", "MS UI Gothic", "MS UI Gothic"],
  2297. ["sans-serif", "Sans-serif", "Sans-serif"],
  2298. ["serif", "Serif", "Serif"],
  2299. ["Times New Roman", "Times New Roman", "Times New Roman"],
  2300. ["Yu Gothic", "Yu Gothic", "遊ゴシック"],
  2301. ["YuGothic", "YuGothic", "游ゴシック体"],
  2302. [currentFont, "Custom", "カスタム"],
  2303. ],
  2304. settingPanel = (flowChats, mainState, state, getConfig, setConfig) => {
  2305. var _a, _b
  2306. const panelState = {
  2307. bannedWordRegexs: getConfig.bannedWordRegexs(),
  2308. bannedWordRegexsValid: !0,
  2309. bannedWordRegexsError: "",
  2310. currentTab: 0,
  2311. timingStepCount: parseInt(
  2312. null !==
  2313. (_b =
  2314. null ===
  2315. (_a = getConfig
  2316. .timingFunction()
  2317. .match(/^steps\((\d+),.+/)) || void 0 === _a
  2318. ? void 0
  2319. : _a[1]) && void 0 !== _b
  2320. ? _b
  2321. : "150",
  2322. 10
  2323. ),
  2324. },
  2325. stepTiming = stepCount => `steps(${stepCount}, jump-end)`,
  2326. getState = {
  2327. ...getConfig,
  2328. bannedWordRegexs: () => {
  2329. const local = panelState.bannedWordRegexs,
  2330. global = getConfig.bannedWordRegexs()
  2331. return (
  2332. panelState.bannedWordRegexsValid &&
  2333. !fast_deep_equal_default()(local, global) &&
  2334. (panelState.bannedWordRegexs = global),
  2335. panelState.bannedWordRegexs
  2336. )
  2337. },
  2338. bannedWordRegexsValid: () => panelState.bannedWordRegexsValid,
  2339. bannedWordRegexsError: () => panelState.bannedWordRegexsError,
  2340. currentTab: () => panelState.currentTab,
  2341. timingStepCount: () => panelState.timingStepCount,
  2342. useStepTiming: () =>
  2343. Boolean(getConfig.timingFunction().match(/^steps\(.+/)),
  2344. },
  2345. setState = {
  2346. ...setConfig,
  2347. bannedWordRegexs: async val => {
  2348. panelState.bannedWordRegexs = val
  2349. let valid = !0
  2350. ;(panelState.bannedWordRegexsError = ""),
  2351. panelState.bannedWordRegexs.forEach(regex => {
  2352. try {
  2353. RegExp(regex, "u")
  2354. } catch (error) {
  2355. ;(panelState.bannedWordRegexsError += `${error} in ${regex};`),
  2356. (valid = !1)
  2357. }
  2358. }),
  2359. valid && setConfig.bannedWordRegexs(val),
  2360. (panelState.bannedWordRegexsValid = valid)
  2361. },
  2362. currentTab: async val => {
  2363. panelState.currentTab = val
  2364. },
  2365. timingStepCount: async val => {
  2366. ;(panelState.timingStepCount = val),
  2367. setConfig.timingFunction(stepTiming(val))
  2368. },
  2369. useStepTiming: async val =>
  2370. setConfig.timingFunction(
  2371. val ? stepTiming(panelState.timingStepCount) : "linear"
  2372. ),
  2373. },
  2374. getText = getLang(getConfig),
  2375. ss = function_pipe(
  2376. [
  2377. "lang",
  2378. "font",
  2379. "color",
  2380. "ownerColor",
  2381. "moderatorColor",
  2382. "memberColor",
  2383. "chatOpacity",
  2384. "fontSize",
  2385. "fontWeight",
  2386. "shadowFontWeight",
  2387. "flowSpeed",
  2388. "minSpacing",
  2389. "fieldScale",
  2390. "maxChatCount",
  2391. "maxChatLength",
  2392. "laneCount",
  2393. "bannedWords",
  2394. "bannedWordRegexs",
  2395. "bannedUsers",
  2396. "createChats",
  2397. "textOnly",
  2398. "displayModName",
  2399. "displaySuperChatAuthor",
  2400. "noOverlap",
  2401. "simplifyChatField",
  2402. "createBanButton",
  2403. "useStepTiming",
  2404. "timingStepCount",
  2405. "clearFlowChats",
  2406. "currentTab",
  2407. "copy",
  2408. ],
  2409. es6_ReadonlyArray_map(x => [
  2410. x,
  2411. new external_rxjs_namespaceObject.Subject(),
  2412. ]),
  2413. Object.fromEntries
  2414. ),
  2415. checkboxNode = label =>
  2416. ((label, checked, onchange) =>
  2417. external_m_default()(
  2418. "div",
  2419. external_m_default()("label", [
  2420. label,
  2421. external_m_default()("input", {
  2422. type: "checkbox",
  2423. checked,
  2424. onchange,
  2425. }),
  2426. ])
  2427. ))(getText(label), getState[label](), lib(ss[label])),
  2428. textColorNode = label =>
  2429. settingRow(getText(label), [
  2430. textColorRow(
  2431. getState[label](),
  2432. {
  2433. fontFamily: getConfig.font(),
  2434. fontWeight: getConfig.fontWeight().toString(),
  2435. },
  2436. lib(ss[label])
  2437. ),
  2438. ]),
  2439. rangeNode = (label, min, max, step) =>
  2440. settingRow(getText(label), [
  2441. rangeRow(min, max, step, getState[label](), lib(ss[label])),
  2442. ]),
  2443. buttonNode = label =>
  2444. external_m_default()(
  2445. "button",
  2446. { type: "button", onclick: lib(ss[label]) },
  2447. getText(label)
  2448. ),
  2449. textAreaNode = (label, rows) =>
  2450. settingRow(getText(label), [
  2451. textAreaRow(0, getState[label](), lib(ss[label])),
  2452. ]),
  2453. updateString = key =>
  2454. ss[key].pipe(
  2455. (0, external_rxjs_operators_namespaceObject.map)(getInputValue),
  2456. (0, external_rxjs_operators_namespaceObject.tap)(setState[key])
  2457. ),
  2458. updateNumber = key =>
  2459. ss[key].pipe(
  2460. (0, external_rxjs_operators_namespaceObject.map)(getInputValue),
  2461. (0, external_rxjs_operators_namespaceObject.map)(parseFloat),
  2462. (0, external_rxjs_operators_namespaceObject.tap)(setState[key])
  2463. ),
  2464. updateInt = key =>
  2465. ss[key].pipe(
  2466. (0, external_rxjs_operators_namespaceObject.map)(getInputValue),
  2467. (0, external_rxjs_operators_namespaceObject.map)(x =>
  2468. parseInt(x, 10)
  2469. ),
  2470. (0, external_rxjs_operators_namespaceObject.tap)(setState[key])
  2471. ),
  2472. updateBool = key =>
  2473. ss[key].pipe(
  2474. (0, external_rxjs_operators_namespaceObject.map)(
  2475. getInputChecked
  2476. ),
  2477. (0, external_rxjs_operators_namespaceObject.tap)(setState[key])
  2478. ),
  2479. updateStrings = key =>
  2480. ss[key].pipe(
  2481. (0, external_rxjs_operators_namespaceObject.map)(getInputValue),
  2482. (0, external_rxjs_operators_namespaceObject.map)(x =>
  2483. x.split(/\r\n|\n/).filter(str => "" !== str)
  2484. ),
  2485. (0, external_rxjs_operators_namespaceObject.tap)(setState[key])
  2486. )
  2487. return (
  2488. (0, external_rxjs_namespaceObject.merge)(
  2489. (0, external_rxjs_namespaceObject.merge)(
  2490. (0, external_rxjs_namespaceObject.merge)(
  2491. updateString("font"),
  2492. updateNumber("fontSize"),
  2493. updateNumber("fontWeight"),
  2494. updateInt("laneCount"),
  2495. updateNumber("minSpacing")
  2496. ).pipe(
  2497. (0, external_rxjs_operators_namespaceObject.mapTo)({
  2498. setStyle: !0,
  2499. setAnimation: !0,
  2500. })
  2501. ),
  2502. (0, external_rxjs_namespaceObject.merge)(
  2503. updateString("color"),
  2504. updateString("ownerColor"),
  2505. updateString("moderatorColor"),
  2506. updateString("memberColor"),
  2507. updateNumber("chatOpacity"),
  2508. updateNumber("shadowFontWeight")
  2509. ).pipe(
  2510. (0, external_rxjs_operators_namespaceObject.mapTo)({
  2511. setStyle: !0,
  2512. })
  2513. ),
  2514. (0, external_rxjs_namespaceObject.merge)(
  2515. updateNumber("flowSpeed")
  2516. ).pipe(
  2517. (0, external_rxjs_operators_namespaceObject.mapTo)({
  2518. setPlayState: !0,
  2519. })
  2520. ),
  2521. (0, external_rxjs_namespaceObject.merge)(
  2522. updateInt("maxChatCount").pipe(
  2523. (0, external_rxjs_operators_namespaceObject.tap)(x =>
  2524. removeOldChats(flowChats, x)
  2525. )
  2526. ),
  2527. updateBool("noOverlap"),
  2528. updateBool("useStepTiming"),
  2529. updateInt("timingStepCount")
  2530. ).pipe(
  2531. (0, external_rxjs_operators_namespaceObject.mapTo)({
  2532. setAnimation: !0,
  2533. })
  2534. )
  2535. ).pipe(
  2536. (0, external_rxjs_operators_namespaceObject.throttleTime)(
  2537. 180,
  2538. void 0,
  2539. { leading: !0, trailing: !0 }
  2540. ),
  2541. (0, external_rxjs_operators_namespaceObject.tap)(x => {
  2542. flowChats
  2543. .filter(chat => !chat.animationEnded)
  2544. .forEach(chat => {
  2545. const config = {
  2546. setStyle: !1,
  2547. setAnimation: !1,
  2548. setPlayState: !1,
  2549. ...x,
  2550. }
  2551. config.setStyle &&
  2552. setChatStyle(chat, mainState, getConfig),
  2553. config.setAnimation
  2554. ? setChatAnimation(
  2555. chat,
  2556. flowChats,
  2557. mainState,
  2558. getConfig
  2559. )
  2560. : config.setPlayState &&
  2561. setChatPlayState(chat, mainState, getConfig)
  2562. })
  2563. })
  2564. ),
  2565. updateString("lang"),
  2566. ss.currentTab.pipe(
  2567. (0, external_rxjs_operators_namespaceObject.tap)(
  2568. setState.currentTab
  2569. )
  2570. ),
  2571. updateInt("maxChatLength"),
  2572. updateBool("simplifyChatField"),
  2573. updateBool("createBanButton"),
  2574. updateBool("createChats"),
  2575. updateBool("displayModName"),
  2576. updateBool("displaySuperChatAuthor"),
  2577. updateBool("textOnly"),
  2578. updateNumber("fieldScale"),
  2579. updateStrings("bannedWords"),
  2580. updateStrings("bannedWordRegexs"),
  2581. updateStrings("bannedUsers"),
  2582. ss.clearFlowChats.pipe(
  2583. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  2584. removeOldChats(flowChats, 0)
  2585. )
  2586. ),
  2587. ss.copy.pipe(
  2588. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  2589. GM.setClipboard(mainState.log)
  2590. )
  2591. )
  2592. ).subscribe(),
  2593. {
  2594. view: () =>
  2595. external_m_default()(
  2596. "div",
  2597. {
  2598. className: "fyc_panel",
  2599. style: {
  2600. visibility: state.showPanel ? "visible" : "hidden",
  2601. backgroundColor: "rgba(30,30,30,0.9)",
  2602. zIndex: 5,
  2603. position: "absolute",
  2604. bottom: "40px",
  2605. right: "0px",
  2606. color: "#fff",
  2607. fontSize: "14px",
  2608. width: "660px",
  2609. border: "solid 1px #666",
  2610. fontFamily: "MS PGothic",
  2611. lineHeight: "1.2",
  2612. },
  2613. },
  2614. [
  2615. external_m_default()(
  2616. "div",
  2617. { style: { float: "right", margin: "3px 3px 0 0" } },
  2618. [
  2619. "🌐",
  2620. external_m_default()(
  2621. "select",
  2622. {
  2623. selectedIndex: langOptions.findIndex(
  2624. x => x[0] === getState.lang()
  2625. ),
  2626. onchange: lib(ss.lang),
  2627. },
  2628. langOptions.map(x => settingPanel_option(...x))
  2629. ),
  2630. ]
  2631. ),
  2632. tabContainer(
  2633. {
  2634. container: { height: "364px" },
  2635. label: { padding: "6px" },
  2636. labelFocus: { background: "#666" },
  2637. tab: { display: "flex", padding: "6px" },
  2638. },
  2639. [
  2640. getText("flowChat"),
  2641. getText("chatFilter"),
  2642. getText("chatField"),
  2643. getText("feedback"),
  2644. ],
  2645. [
  2646. () => [
  2647. external_m_default()(
  2648. "div",
  2649. { style: panelBoxStyle(212) },
  2650. [
  2651. settingRow(getText("font"), [
  2652. external_m_default()(
  2653. "select",
  2654. {
  2655. style: inputRowStyle,
  2656. selectedIndex: fontOptions(
  2657. getState.font()
  2658. ).findIndex(x => x[0] === getState.font()),
  2659. onchange: lib(ss.font),
  2660. },
  2661. fontOptions(getState.font()).map(x =>
  2662. settingPanel_option(
  2663. x[0],
  2664. "FYC_JA" === getState.lang() ? x[2] : x[1]
  2665. )
  2666. )
  2667. ),
  2668. ]),
  2669. external_m_default()("input", {
  2670. style: inputRowStyle,
  2671. maxlength: 20,
  2672. value: getState.font(),
  2673. oninput: lib(ss.font),
  2674. }),
  2675. textColorNode("color"),
  2676. textColorNode("ownerColor"),
  2677. textColorNode("moderatorColor"),
  2678. textColorNode("memberColor"),
  2679. ]
  2680. ),
  2681. external_m_default()(
  2682. "div",
  2683. { style: panelBoxStyle(212) },
  2684. [
  2685. rangeNode("chatOpacity", 0, 1, 0.05),
  2686. rangeNode("fontSize", 0.3, 2, 0.05),
  2687. rangeNode("fontWeight", 10, 1e3, 10),
  2688. rangeNode("shadowFontWeight", 0, 3, 0.1),
  2689. rangeNode("flowSpeed", 1, 50, 1),
  2690. rangeNode("maxChatCount", 5, 200, 5),
  2691. rangeNode("maxChatLength", 5, 200, 5),
  2692. rangeNode("laneCount", 1, 25, 1),
  2693. ]
  2694. ),
  2695. external_m_default()(
  2696. "div",
  2697. { style: panelBoxStyle(212) },
  2698. [
  2699. rangeNode("minSpacing", 0, 2.5, 0.1),
  2700. checkboxNode("useStepTiming"),
  2701. external_m_default()(
  2702. "div",
  2703. {
  2704. style: {
  2705. ...(getState.useStepTiming()
  2706. ? {}
  2707. : { opacity: "0.5" }),
  2708. },
  2709. },
  2710. rangeNode("timingStepCount", 1, 400, 1)
  2711. ),
  2712. checkboxNode("createChats"),
  2713. checkboxNode("displayModName"),
  2714. checkboxNode("displaySuperChatAuthor"),
  2715. checkboxNode("textOnly"),
  2716. external_m_default()(
  2717. "span",
  2718. getText("flowNewChatIf")
  2719. ),
  2720. checkboxNode("noOverlap"),
  2721. buttonNode("clearFlowChats"),
  2722. ]
  2723. ),
  2724. ],
  2725. () => [
  2726. external_m_default()(
  2727. "div",
  2728. { style: panelBoxStyle(212) },
  2729. textAreaNode("bannedWords")
  2730. ),
  2731. external_m_default()(
  2732. "div",
  2733. { style: panelBoxStyle(212) },
  2734. settingRow(getText("bannedWordRegexs"), [
  2735. external_m_default()(
  2736. "span",
  2737. getState.bannedWordRegexsValid()
  2738. ? ""
  2739. : `${getText(
  2740. "error"
  2741. )}: ${getState.bannedWordRegexsError()}`
  2742. ),
  2743. textAreaRow(
  2744. 0,
  2745. getState.bannedWordRegexs(),
  2746. lib(ss.bannedWordRegexs)
  2747. ),
  2748. ])
  2749. ),
  2750. external_m_default()(
  2751. "div",
  2752. { style: panelBoxStyle(212) },
  2753. textAreaNode("bannedUsers")
  2754. ),
  2755. ],
  2756. () => [
  2757. external_m_default()(
  2758. "div",
  2759. { style: panelBoxStyle(644) },
  2760. [
  2761. rangeNode("fieldScale", 0.7, 1.5, 0.05),
  2762. checkboxNode("simplifyChatField"),
  2763. checkboxNode("createBanButton"),
  2764. ]
  2765. ),
  2766. ],
  2767. () => [
  2768. external_m_default()(
  2769. "div",
  2770. { style: panelBoxStyle(644) },
  2771. [
  2772. external_m_default()(
  2773. "div",
  2774. { style: { float: "right" } },
  2775. external_m_default()(
  2776. "a",
  2777. {
  2778. style: { color: "#f0f" },
  2779. href:
  2780. "https://greasyfork.org/en/scripts/411442-flow-youtube-chat/feedback",
  2781. target: "_blank",
  2782. },
  2783. getText("giveFeedback")
  2784. )
  2785. ),
  2786. external_m_default()("div", [
  2787. external_m_default()(
  2788. "span",
  2789. getText("eventLog")
  2790. ),
  2791. buttonNode("copy"),
  2792. external_m_default()(
  2793. "div",
  2794. external_m_default()(
  2795. "textarea",
  2796. {
  2797. rows: 18,
  2798. style: textAreaStyle,
  2799. readOnly: !0,
  2800. onclick: () => {},
  2801. },
  2802. mainState.log
  2803. )
  2804. ),
  2805. ]),
  2806. ]
  2807. ),
  2808. ],
  2809. ],
  2810. getState.currentTab(),
  2811. lib(ss.currentTab)
  2812. ),
  2813. ]
  2814. ),
  2815. }
  2816. )
  2817. },
  2818. settingComponent = (flowChats, mainState, getConfig, setConfig) => {
  2819. const state = { showPanel: !1 },
  2820. panel = settingPanel(
  2821. flowChats,
  2822. mainState,
  2823. state,
  2824. getConfig,
  2825. setConfig
  2826. ),
  2827. toggleButton = ((state, getConfig) => {
  2828. const click$ = new external_rxjs_namespaceObject.Subject()
  2829. return (
  2830. click$
  2831. .pipe(
  2832. (0, external_rxjs_operators_namespaceObject.tap)(() => {
  2833. state.showPanel = !state.showPanel
  2834. })
  2835. )
  2836. .subscribe(),
  2837. {
  2838. view: () =>
  2839. external_m_default()(
  2840. "button",
  2841. {
  2842. className: "fyc_button",
  2843. style: {
  2844. background: "rgba(0,0,0,0)",
  2845. marginLeft: "10px",
  2846. whiteSpace: "nowrap",
  2847. },
  2848. onclick: lib(click$),
  2849. },
  2850. [
  2851. external_m_default()(
  2852. "svg",
  2853. {
  2854. preserveAspectRatio: "xMidYMid meet",
  2855. viewBox: "0 0 640 640",
  2856. width: "15",
  2857. height: "15",
  2858. style: { position: "relative", top: "1px" },
  2859. },
  2860. [
  2861. external_m_default()(
  2862. "defs",
  2863. external_m_default()("path", {
  2864. id: "d1TbzTC1zI",
  2865. d:
  2866. "M135 58c25 14 67 30 82 35-7 49 16 109-15 149-50 71-19 184 64 213 74 31 165-18 183-95-3-38 23-62 58-36l120 55c-39 10-106 35-72 85 40 38 1 71-29 98-29 53-70-17-109-5-46 22-25 109-96 85h-55c-24-31-21-103-80-84-32 32-70 31-93-9l-35-36c4-40 57-96-6-120-45 5-58-32-52-68 2-19-4-41 3-59 35-15 100-22 77-79-48-43 1-84 35-115 5-6 12-12 20-14zM577 2c52 3 72 62 62 106-5 51 19 117-27 155-18 24 8 49 11 74-39-8-98-46-146-60-55-1-111 2-167-2-52-15-57-76-52-121S242 52 282 18c38-30 88-11 132-16h163z",
  2867. })
  2868. ),
  2869. external_m_default()("use", {
  2870. "xlink:href": "#d1TbzTC1zI",
  2871. opacity: "1",
  2872. fill: "var(--iron-icon-fill-color, currentcolor)",
  2873. "fill-opacity": "1",
  2874. }),
  2875. ]
  2876. ),
  2877. external_m_default()(
  2878. "span",
  2879. {
  2880. style: {
  2881. position: "relative",
  2882. top: "-2px",
  2883. marginLeft: "8px,",
  2884. },
  2885. },
  2886. "FYC_JA" === getConfig.lang() ? "設定" : "Settings"
  2887. ),
  2888. ]
  2889. ),
  2890. }
  2891. )
  2892. })(state, getConfig)
  2893. return {
  2894. view: () => [
  2895. external_m_default()(panel),
  2896. external_m_default()(toggleButton),
  2897. ],
  2898. }
  2899. },
  2900. initialize = async (mainState, mainLog) => {
  2901. const consoleLog = (a, ...b) => {
  2902. mainLog(a, ...b),
  2903. external_log_default().info(`【FYC ${a}`),
  2904. b.length > 0 && external_log_default().info(...b)
  2905. }
  2906. mainLog("Version", package_namespaceObject_i8),
  2907. mainLog("User Agent", window.navigator.userAgent)
  2908. const userConfig = await (async () => ({
  2909. lang: await simpleConfig("FYC_LANG", "FYC_EN"),
  2910. font: await simpleConfig("FYC_FONT", "MS PGothic"),
  2911. chatOpacity: await simpleConfig("FYC_OPACITY", 0.8),
  2912. color: await simpleConfig("FYC_COLOR", "#ffffff"),
  2913. ownerColor: await simpleConfig("FYC_COLOR_OWNER", "#ffd600"),
  2914. moderatorColor: await simpleConfig(
  2915. "FYC_COLOR_MODERATOR",
  2916. "#a74fff"
  2917. ),
  2918. memberColor: await simpleConfig("FYC_COLOR_MEMBER", "#9fffff"),
  2919. fontSize: await simpleConfig("FYC_SIZE", 1),
  2920. fontWeight: await simpleConfig("FYC_WEIGHT", 730),
  2921. shadowFontWeight: await simpleConfig("FYC_WEIGHT_SHADOW", 1),
  2922. maxChatCount: await simpleConfig("FYC_LIMIT", 40),
  2923. flowSpeed: await simpleConfig("FYC_SPEED", 18),
  2924. maxChatLength: await simpleConfig("FYC_MAX", 100),
  2925. laneCount: await simpleConfig("FYC_LANE_DIV", 12),
  2926. bannedWords: await indirectConfig(
  2927. "FYC_NG_WORDS",
  2928. ...lineConfigArgs
  2929. ),
  2930. bannedWordRegexs: await indirectConfig(
  2931. "FYC_NG_REG_WORDS",
  2932. ...lineConfigArgs
  2933. ),
  2934. bannedUsers: await indirectConfig(
  2935. "FYC_NG_USERS",
  2936. ...lineConfigArgs
  2937. ),
  2938. createChats: await simpleConfig("FYC_TOGGLE_CREATE_COMMENTS", !0),
  2939. noOverlap: await simpleConfig("FYC_NO_OVERLAP", !0),
  2940. createBanButton: await simpleConfig("FYC_NG_BUTTON", !0),
  2941. simplifyChatField: await simpleConfig("FYC_SIMPLE_CHAT_FIELD", !1),
  2942. displayModName: await simpleConfig(
  2943. "FYC_DISPLAY_MODERATOR_NAME",
  2944. !0
  2945. ),
  2946. displaySuperChatAuthor: await simpleConfig(
  2947. "FYC_DISPLAY_SUPER_CHAT_AUTHOR",
  2948. !0
  2949. ),
  2950. textOnly: await simpleConfig("FYC_TEXT_ONLY", !1),
  2951. timingFunction: await simpleConfig("FYC_TIMING_FUNCTION", "linear"),
  2952. displayChats: await simpleConfig("FYC_DISPLAY_COMMENTS", !0),
  2953. minSpacing: await simpleConfig("FYC_MIN_SPACING", 0.5),
  2954. fieldScale: await simpleConfig("FYC_FIELD_SCALE", 1),
  2955. }))()
  2956. mainLog("UserConfig", JSON.stringify(userConfig))
  2957. const configKeys = Object.keys(userConfig),
  2958. getConfig = function_pipe(
  2959. configKeys,
  2960. es6_ReadonlyArray_map(x => [x, () => userConfig[x].val]),
  2961. Object.fromEntries
  2962. ),
  2963. configSubject = function_pipe(
  2964. configKeys,
  2965. es6_ReadonlyArray_map(x => [
  2966. x,
  2967. new external_rxjs_namespaceObject.Subject(),
  2968. ]),
  2969. Object.fromEntries
  2970. ),
  2971. channel = new broadcast_channel_BroadcastChannel(
  2972. "fyc-0615654655528523"
  2973. ),
  2974. setConfigPlain = function_pipe(
  2975. configKeys,
  2976. es6_ReadonlyArray_map(x => [
  2977. x,
  2978. async val => {
  2979. ;(userConfig[x].val = val), configSubject[x].next(val)
  2980. },
  2981. ]),
  2982. Object.fromEntries
  2983. ),
  2984. setConfig = function_pipe(
  2985. configKeys,
  2986. es6_ReadonlyArray_map(x => [
  2987. x,
  2988. async val => {
  2989. setConfigPlain[x](val)
  2990. const item = userConfig[x]
  2991. channel.postMessage([x, val]),
  2992. await GM.setValue(item.gmKey, item.toGm(val))
  2993. },
  2994. ]),
  2995. Object.fromEntries
  2996. ),
  2997. reinitSubject = new external_rxjs_namespaceObject.Subject(),
  2998. reinitialize = () => {
  2999. requestAnimationFrame(() => lib(reinitSubject)())
  3000. },
  3001. chatScreen = (() => {
  3002. const element = document.createElement("div")
  3003. return (
  3004. (element.style.pointerEvents = "none"),
  3005. (element.style.zIndex = "30"),
  3006. element
  3007. )
  3008. })(),
  3009. css = (() => {
  3010. const element = document.createElement("style")
  3011. return (
  3012. (element.innerHTML =
  3013. ".fyc_chat {\n line-height: 1;\n z-index: 30;\n position: absolute;\n user-select: none;\n white-space: nowrap;\n will-change: transform;\n }\n .fyc_button {\n display: inline-block;\n border-style: none;\n z-index: 4;\n font-weight: 500;\n color: var(--yt-spec-text-secondary);\n }"),
  3014. element
  3015. )
  3016. })(),
  3017. flowChats = [],
  3018. observePair = con => {
  3019. const subject = new external_rxjs_namespaceObject.Subject()
  3020. return { subject, observer: new con(lib(subject)) }
  3021. },
  3022. documentMutationPair = observePair(MutationObserver),
  3023. chatFieldMutationPair = observePair(MutationObserver),
  3024. playerResizePair = observePair(ResizeObserver),
  3025. simpleWrap = comp => ({
  3026. comp,
  3027. root: document.createElement("span"),
  3028. }),
  3029. wrappedToggleChatBtn = simpleWrap(
  3030. ((flowChats, getConfig, setConfig) => {
  3031. const click$ = new external_rxjs_namespaceObject.Subject()
  3032. click$
  3033. .pipe(
  3034. (0, external_rxjs_operators_namespaceObject.tap)(() => {
  3035. const newDisplay = !getConfig.displayChats()
  3036. flowChats.forEach(x => {
  3037. x.element.style.visibility = newDisplay
  3038. ? "visible"
  3039. : "hidden"
  3040. }),
  3041. setConfig.displayChats(newDisplay)
  3042. })
  3043. )
  3044. .subscribe()
  3045. const getText = getLang(getConfig),
  3046. label = () =>
  3047. getText(getConfig.displayChats() ? "hideChat" : "showChat")
  3048. return {
  3049. view: () =>
  3050. external_m_default()(
  3051. "button",
  3052. {
  3053. className: ["ytp-button"].join(" "),
  3054. style: {
  3055. background: "none",
  3056. border: "none",
  3057. cursor: "pointer",
  3058. float: "left",
  3059. fontSize: "1em",
  3060. height: "4em",
  3061. outline: "none",
  3062. overflow: "visible",
  3063. padding: "0 0 0em",
  3064. position: "relative",
  3065. width: "3em",
  3066. },
  3067. type: "button",
  3068. "aria-label": label(),
  3069. title: label(),
  3070. onclick: lib(click$),
  3071. },
  3072. [
  3073. external_m_default()(
  3074. "svg",
  3075. { style: { width: "100%" }, viewBox: "0 0 36 36" },
  3076. [
  3077. external_m_default()("path", {
  3078. className: ["chat-button-path"].join(" "),
  3079. d:
  3080. "m11 12h17q1 0 1 1v9q0 1-1 1h-1v2l-4-2h-12q-1 0-1-1v-9q0-1 1-1z",
  3081. fill: "#fff",
  3082. "fill-opacity": getConfig.displayChats()
  3083. ? "1"
  3084. : "0",
  3085. stroke: "#fff",
  3086. "stroke-width": "2",
  3087. }),
  3088. ]
  3089. ),
  3090. ]
  3091. ),
  3092. }
  3093. })(flowChats, getConfig, setConfig)
  3094. ),
  3095. wrappedSetting = simpleWrap(
  3096. settingComponent(flowChats, mainState, getConfig, setConfig)
  3097. ),
  3098. livePage = {
  3099. toggleChatBtnParent: () =>
  3100. fromNullable(document.querySelector(".ytp-right-controls")),
  3101. settingNextElement: () =>
  3102. fromNullable(
  3103. document.querySelector(
  3104. "#menu-container .dropdown-trigger.ytd-menu-renderer"
  3105. )
  3106. ),
  3107. player: () =>
  3108. fromNullable(document.querySelector("#movie_player")),
  3109. video: () =>
  3110. fromNullable(
  3111. document.querySelector("video.video-stream.html5-main-video")
  3112. ),
  3113. chatField: () =>
  3114. function_pipe(
  3115. chatApp(),
  3116. chainNullableK(x =>
  3117. x.querySelector("#items.yt-live-chat-item-list-renderer")
  3118. )
  3119. ),
  3120. chatScroller: () =>
  3121. function_pipe(
  3122. chatApp(),
  3123. chainNullableK(x =>
  3124. x.querySelector(
  3125. "#item-scroller.yt-live-chat-item-list-renderer"
  3126. )
  3127. )
  3128. ),
  3129. offlineSlate: () =>
  3130. fromNullable(document.querySelector(".ytp-offline-slate")),
  3131. },
  3132. liveElementKeys = Object.keys(livePage),
  3133. live = function_pipe(
  3134. liveElementKeys,
  3135. es6_ReadonlyArray_map(x => {
  3136. return [x, ((key = x), { ele: none, read: livePage[key] })]
  3137. var key
  3138. }),
  3139. Object.fromEntries
  3140. ),
  3141. eq = getEq(eqStrict).equals
  3142. reinitSubject
  3143. .pipe(
  3144. (0, external_rxjs_operators_namespaceObject.observeOn)(
  3145. external_rxjs_namespaceObject.asyncScheduler
  3146. ),
  3147. (0, external_rxjs_operators_namespaceObject.delay)(100),
  3148. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  3149. consoleLog("Init")
  3150. ),
  3151. (0, external_rxjs_operators_namespaceObject.switchMap)(() =>
  3152. (0, external_rxjs_namespaceObject.interval)(700).pipe(
  3153. (0, external_rxjs_operators_namespaceObject.filter)(() =>
  3154. function_pipe(
  3155. liveElementKeys,
  3156. es6_ReadonlyArray_map(key =>
  3157. function_pipe(
  3158. live[key].read(),
  3159. fromPredicate(newEle => !eq(live[key].ele, newEle)),
  3160. es6_Option_map(x => () => (
  3161. (live[key].ele = x),
  3162. consoleLog(`${key} changed`),
  3163. !0
  3164. )),
  3165. getOrElse(() => IO_of(!1))
  3166. )
  3167. ),
  3168. IO_sequenceArray,
  3169. (function (f) {
  3170. return function (fa) {
  3171. return IO_map(fa, f)
  3172. }
  3173. })(ReadonlyArray_some(Boolean))
  3174. )()
  3175. ),
  3176. (0, external_rxjs_operators_namespaceObject.startWith)(0)
  3177. )
  3178. ),
  3179. (0, external_rxjs_operators_namespaceObject.tap)(() => {
  3180. consoleLog("Loading..."),
  3181. removeOldChats(flowChats, 0),
  3182. documentMutationPair.observer.disconnect(),
  3183. documentMutationPair.observer.observe(document, {
  3184. childList: !0,
  3185. subtree: !0,
  3186. }),
  3187. chatFieldMutationPair.observer.disconnect(),
  3188. playerResizePair.observer.disconnect(),
  3189. document.head.append(css),
  3190. function_pipe(
  3191. [
  3192. function_pipe(
  3193. live.chatField.ele,
  3194. es6_Option_map(x => () => {
  3195. var chatField
  3196. ;((chatField = x),
  3197. () =>
  3198. function_pipe(
  3199. fromNullable(chatField.parentElement),
  3200. es6_Option_map(x => () => {
  3201. x.style.overflow = "unset"
  3202. })
  3203. ))(),
  3204. chatFieldMutationPair.observer.observe(x, {
  3205. childList: !0,
  3206. })
  3207. })
  3208. ),
  3209. function_pipe(
  3210. live.player.ele,
  3211. es6_Option_map(x => () => {
  3212. playerResizePair.observer.observe(x),
  3213. x.insertAdjacentElement("afterbegin", chatScreen)
  3214. })
  3215. ),
  3216. function_pipe(
  3217. live.toggleChatBtnParent.ele,
  3218. es6_Option_map(x => () => {
  3219. x.append(wrappedToggleChatBtn.root),
  3220. mountComponent(wrappedToggleChatBtn)
  3221. })
  3222. ),
  3223. function_pipe(
  3224. live.settingNextElement.ele,
  3225. es6_Option_map(x => () => {
  3226. x.insertAdjacentElement(
  3227. "beforebegin",
  3228. wrappedSetting.root
  3229. ),
  3230. mountComponent(wrappedSetting)
  3231. })
  3232. ),
  3233. ],
  3234. ReadonlyArray_compact,
  3235. ReadonlyArray_append(
  3236. function_pipe(
  3237. live.video.ele,
  3238. filter(x => !x.paused),
  3239. alt(() => live.offlineSlate.ele),
  3240. Option_isSome,
  3241. x => () => {
  3242. mainState.chatPlaying = x
  3243. }
  3244. )
  3245. ),
  3246. IO_sequenceArray
  3247. )()
  3248. }),
  3249. (0, external_rxjs_operators_namespaceObject.switchMap)(() =>
  3250. (0, external_rxjs_namespaceObject.merge)(
  3251. (0, external_rxjs_namespaceObject.fromEvent)(
  3252. channel,
  3253. "message"
  3254. ).pipe(
  3255. (0, external_rxjs_operators_namespaceObject.tap)(
  3256. ([key, val]) => {
  3257. ;[
  3258. "bannedWords",
  3259. "bannedWordRegexs",
  3260. "bannedUsers",
  3261. "simplifyChatField",
  3262. "createBanButton",
  3263. "fieldScale",
  3264. ].includes(key) &&
  3265. (setConfigPlain[key](val),
  3266. external_m_default().redraw())
  3267. }
  3268. )
  3269. ),
  3270. ...function_pipe(
  3271. configKeys,
  3272. es6_ReadonlyArray_map(key =>
  3273. configSubject[key].pipe(
  3274. (0, external_rxjs_operators_namespaceObject.startWith)(
  3275. getConfig[key]()
  3276. ),
  3277. (0,
  3278. external_rxjs_operators_namespaceObject.bufferCount)(
  3279. 2,
  3280. 1
  3281. ),
  3282. (0,
  3283. external_rxjs_operators_namespaceObject.map)(([x, y]) =>
  3284. (0, external_DeepDiff_namespaceObject.diff)(x, y)
  3285. ),
  3286. (0, external_rxjs_operators_namespaceObject.tap)(x =>
  3287. mainLog(`Config ${key}`, JSON.stringify(x))
  3288. )
  3289. )
  3290. )
  3291. ),
  3292. (0, external_rxjs_namespaceObject.merge)(
  3293. configSubject.bannedWordRegexs,
  3294. configSubject.bannedWords
  3295. ).pipe(
  3296. (0, external_rxjs_operators_namespaceObject.startWith)(
  3297. void 0
  3298. ),
  3299. (0, external_rxjs_operators_namespaceObject.tap)(() => {
  3300. mainState.filterExp = some(
  3301. external_jsep_default()(
  3302. `\nsome(anyPredicates([\n matchesRegexes(${JSON.stringify(
  3303. getConfig.bannedWordRegexs()
  3304. )}),\n matchesWords(${JSON.stringify(
  3305. getConfig.bannedWords()
  3306. )})\n]))(compact([\n messageText,\n paymentInfo\n]))\n `
  3307. )
  3308. )
  3309. })
  3310. ),
  3311. configSubject.fieldScale.pipe(
  3312. (0, external_rxjs_operators_namespaceObject.startWith)(
  3313. getConfig.fieldScale()
  3314. ),
  3315. (0, external_rxjs_operators_namespaceObject.tap)(scale =>
  3316. function_pipe(
  3317. live.chatField.ele,
  3318. match(
  3319. () => () => {},
  3320. field =>
  3321. function_pipe(
  3322. [
  3323. function_pipe(
  3324. fromNullable(field.parentElement),
  3325. es6_Option_map(x => () => {
  3326. ;(x.style.transformOrigin =
  3327. (scale >= 1 ? "top" : "bottom") +
  3328. " left"),
  3329. (x.style.transform = `scale(${scale})`),
  3330. (x.style.width = 100 / scale + "%"),
  3331. (x.style.height = `${field.offsetHeight}px`)
  3332. })
  3333. ),
  3334. function_pipe(
  3335. live.chatScroller.ele,
  3336. es6_Option_map(scroller => () => {
  3337. scroller.scrollTop = scroller.scrollHeight
  3338. })
  3339. ),
  3340. ],
  3341. ReadonlyArray_compact,
  3342. IO_sequenceArray
  3343. )
  3344. )
  3345. )()
  3346. )
  3347. ),
  3348. function_pipe(
  3349. live.video.ele,
  3350. match(
  3351. () => external_rxjs_namespaceObject.EMPTY,
  3352. x => {
  3353. return ((video = x),
  3354. (0, external_rxjs_namespaceObject.merge)(
  3355. (0, external_rxjs_namespaceObject.fromEvent)(
  3356. video,
  3357. "playing"
  3358. ).pipe(
  3359. (0, external_rxjs_operators_namespaceObject.mapTo)(
  3360. !0
  3361. )
  3362. ),
  3363. (0, external_rxjs_namespaceObject.fromEvent)(
  3364. video,
  3365. "waiting"
  3366. ).pipe(
  3367. (0, external_rxjs_operators_namespaceObject.mapTo)(
  3368. !1
  3369. )
  3370. ),
  3371. (0, external_rxjs_namespaceObject.fromEvent)(
  3372. video,
  3373. "pause"
  3374. ).pipe(
  3375. (0, external_rxjs_operators_namespaceObject.mapTo)(
  3376. !1
  3377. )
  3378. )
  3379. )).pipe(
  3380. (0, external_rxjs_operators_namespaceObject.map)(
  3381. playing =>
  3382. playing || Option_isSome(live.offlineSlate.ele)
  3383. ),
  3384. (0, external_rxjs_operators_namespaceObject.tap)(
  3385. chatPlaying => {
  3386. ;(mainState.chatPlaying = chatPlaying),
  3387. flowChats.forEach(chat => {
  3388. setChatPlayState(chat, mainState, getConfig)
  3389. })
  3390. }
  3391. )
  3392. )
  3393. var video
  3394. }
  3395. )
  3396. ),
  3397. chatFieldMutationPair.subject.pipe(
  3398. (0, external_rxjs_operators_namespaceObject.tap)(
  3399. onChatFieldMutate(
  3400. chatScreen,
  3401. flowChats,
  3402. mainState,
  3403. getConfig,
  3404. setConfig,
  3405. mainLog
  3406. )
  3407. )
  3408. ),
  3409. documentMutationPair.subject.pipe(
  3410. (0, external_rxjs_operators_namespaceObject.map)(
  3411. () => window.location.href
  3412. ),
  3413. (0,
  3414. external_rxjs_operators_namespaceObject.distinctUntilChanged)(),
  3415. (0, external_rxjs_operators_namespaceObject.skip)(1),
  3416. (0, external_rxjs_operators_namespaceObject.tap)(x => {
  3417. consoleLog("URL Changed", x),
  3418. removeOldChats(flowChats, 0),
  3419. consoleLog("Wait for 1700ms...")
  3420. }),
  3421. (0, external_rxjs_operators_namespaceObject.delay)(1700),
  3422. (0, external_rxjs_operators_namespaceObject.tap)(() =>
  3423. reinitialize()
  3424. )
  3425. ),
  3426. playerResizePair.subject.pipe(
  3427. (0,
  3428. external_rxjs_operators_namespaceObject.throttleTime)(
  3429. 500,
  3430. void 0,
  3431. { leading: !0, trailing: !0 }
  3432. ),
  3433. (0, external_rxjs_operators_namespaceObject.startWith)([]),
  3434. (0, external_rxjs_operators_namespaceObject.map)(
  3435. () => live.player.ele
  3436. ),
  3437. (0, external_rxjs_operators_namespaceObject.map)(
  3438. es6_Option_map(x => x.getBoundingClientRect())
  3439. ),
  3440. (0, external_rxjs_operators_namespaceObject.tap)(x =>
  3441. ((rect, flowChats, mainState, getConfig, mainLog) =>
  3442. function_pipe(
  3443. rect,
  3444. match(
  3445. () => () => {},
  3446. x => () => {
  3447. mainLog("Resize detected"),
  3448. (mainState.playerRect = x),
  3449. flowChats.forEach(chat => {
  3450. setChatStyle(chat, mainState, getConfig),
  3451. setChatAnimation(
  3452. chat,
  3453. flowChats,
  3454. mainState,
  3455. getConfig
  3456. )
  3457. })
  3458. }
  3459. )
  3460. )())(x, flowChats, mainState, getConfig, mainLog)
  3461. )
  3462. )
  3463. )
  3464. ),
  3465. (0, external_rxjs_operators_namespaceObject.retryWhen)(e =>
  3466. e.pipe(
  3467. (0, external_rxjs_operators_namespaceObject.tap)(() => {
  3468. consoleLog("Errored", e)
  3469. }),
  3470. (0, external_rxjs_operators_namespaceObject.delay)(5e3),
  3471. (0, external_rxjs_operators_namespaceObject.tap)(x => {
  3472. consoleLog(x), reinitialize()
  3473. })
  3474. )
  3475. )
  3476. )
  3477. .subscribe({
  3478. error: x => consoleLog("Stream error", x),
  3479. complete: () => consoleLog("Stream complete"),
  3480. }),
  3481. reinitialize()
  3482. }
  3483. ;(async () => {
  3484. external_log_namespaceObject.setLevel("info")
  3485. const mainState = {
  3486. chatPlaying: !0,
  3487. playerRect: new DOMRect(24, 80, 839, 472),
  3488. log: "",
  3489. filterExp: none,
  3490. }
  3491. try {
  3492. await initialize(
  3493. mainState,
  3494. (mainState => (a, ...b) => {
  3495. ;(mainState.log += `${a}${b.length > 0 ? ": " : ""}${b.join(
  3496. ", "
  3497. )}\n`),
  3498. mainState.log.length > 22e3 &&
  3499. (mainState.log = `${mainState.log.slice(0, 6e3)}\n`)
  3500. })(mainState)
  3501. )
  3502. } catch (error) {
  3503. external_log_namespaceObject.info("【FYC】 Error", error)
  3504. }
  3505. })()
  3506. })()
  3507. })()