Flow Youtube Chat

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

目前為 2021-08-03 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Flow Youtube Chat
  3. // @version 1.15.6
  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@11.0.18/dist/sweetalert2.all.min.js#sha384-EoPspU1QiQ0II6WaHKy5pERCBPBD1VqZByJ29O7fDUJxGXwWLyEREDpvym8c4v2S
  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.3.0/dist/bundles/rxjs.umd.min.js#sha384-B2HMABdZA26zJ9QwbG/c5zrcdr6+Zs8J4MgKs7udycjXgvRDA5nZKLzJ1vXWzJyH
  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.5/dist/astring.min.js#sha384-mGnfE+xZkK7mo04MqU0t7DI1ZTFZSKwfPNjrLFeibz94N4lJgdHXh5+kI6rf5x10
  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.2/dist/hash-it.min.js#sha384-biRMep0zr/5fw/hIdnBIb56UHRgiIyhAagZrngd9dSxxQ9aDFMP0hbYR8PEj5lVu
  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. 844: (
  32. __unused_webpack_module,
  33. __unused_webpack___webpack_exports__,
  34. __webpack_require__
  35. ) => {
  36. "use strict"
  37. const external_log_namespaceObject = log
  38. var external_log_default = __webpack_require__.n(
  39. external_log_namespaceObject
  40. )
  41. const lib = observer => value => {
  42. observer.next(value)
  43. }
  44. function sleep(time) {
  45. time || (time = 0)
  46. return new Promise(function (res) {
  47. return setTimeout(res, time)
  48. })
  49. }
  50. function randomToken() {
  51. return Math.random().toString(36).substring(2)
  52. }
  53. var lastMs = 0,
  54. additional = 0
  55. function microSeconds() {
  56. var ms = new Date().getTime()
  57. if (ms === lastMs) return 1e3 * ms + ++additional
  58. lastMs = ms
  59. additional = 0
  60. return 1e3 * ms
  61. }
  62. var isNode =
  63. "[object process]" ===
  64. Object.prototype.toString.call(
  65. "undefined" != typeof process ? process : 0
  66. )
  67. const methods_native = {
  68. create: function (channelName) {
  69. var state = {
  70. messagesCallback: null,
  71. bc: new BroadcastChannel(channelName),
  72. subFns: [],
  73. }
  74. state.bc.onmessage = function (msg) {
  75. state.messagesCallback && state.messagesCallback(msg.data)
  76. }
  77. return state
  78. },
  79. close: function (channelState) {
  80. channelState.bc.close()
  81. channelState.subFns = []
  82. },
  83. onMessage: function (channelState, fn) {
  84. channelState.messagesCallback = fn
  85. },
  86. postMessage: function (channelState, messageJson) {
  87. try {
  88. channelState.bc.postMessage(messageJson, !1)
  89. return Promise.resolve()
  90. } catch (err) {
  91. return Promise.reject(err)
  92. }
  93. },
  94. canBeUsed: function () {
  95. if (isNode && "undefined" == typeof window) return !1
  96. if ("function" == typeof BroadcastChannel) {
  97. if (BroadcastChannel._pubkey)
  98. throw new Error(
  99. "BroadcastChannel: Do not overwrite window.BroadcastChannel with this module, this is not a polyfill"
  100. )
  101. return !0
  102. }
  103. return !1
  104. },
  105. type: "native",
  106. averageResponseTime: function () {
  107. return 150
  108. },
  109. microSeconds,
  110. }
  111. var ObliviousSet = (function () {
  112. function ObliviousSet(ttl) {
  113. this.ttl = ttl
  114. this.set = new Set()
  115. this.timeMap = new Map()
  116. }
  117. ObliviousSet.prototype.has = function (value) {
  118. return this.set.has(value)
  119. }
  120. ObliviousSet.prototype.add = function (value) {
  121. var _this = this
  122. this.timeMap.set(value, now())
  123. this.set.add(value)
  124. setTimeout(function () {
  125. !(function (obliviousSet) {
  126. var olderThen = now() - obliviousSet.ttl,
  127. iterator = obliviousSet.set[Symbol.iterator]()
  128. for (;;) {
  129. var value = iterator.next().value
  130. if (!value) return
  131. if (!(obliviousSet.timeMap.get(value) < olderThen)) return
  132. obliviousSet.timeMap.delete(value)
  133. obliviousSet.set.delete(value)
  134. }
  135. })(_this)
  136. }, 0)
  137. }
  138. ObliviousSet.prototype.clear = function () {
  139. this.set.clear()
  140. this.timeMap.clear()
  141. }
  142. return ObliviousSet
  143. })()
  144. function now() {
  145. return new Date().getTime()
  146. }
  147. function options_fillOptionsWithDefaults() {
  148. var originalOptions =
  149. arguments.length > 0 && void 0 !== arguments[0]
  150. ? arguments[0]
  151. : {},
  152. options = JSON.parse(JSON.stringify(originalOptions))
  153. void 0 === options.webWorkerSupport && (options.webWorkerSupport = !0)
  154. options.idb || (options.idb = {})
  155. options.idb.ttl || (options.idb.ttl = 45e3)
  156. options.idb.fallbackInterval || (options.idb.fallbackInterval = 150)
  157. originalOptions.idb &&
  158. "function" == typeof originalOptions.idb.onclose &&
  159. (options.idb.onclose = originalOptions.idb.onclose)
  160. options.localstorage || (options.localstorage = {})
  161. options.localstorage.removeTimeout ||
  162. (options.localstorage.removeTimeout = 6e4)
  163. originalOptions.methods && (options.methods = originalOptions.methods)
  164. options.node || (options.node = {})
  165. options.node.ttl || (options.node.ttl = 12e4)
  166. void 0 === options.node.useFastPath && (options.node.useFastPath = !0)
  167. return options
  168. }
  169. function getIdb() {
  170. if ("undefined" != typeof indexedDB) return indexedDB
  171. if ("undefined" != typeof window) {
  172. if (void 0 !== window.mozIndexedDB) return window.mozIndexedDB
  173. if (void 0 !== window.webkitIndexedDB) return window.webkitIndexedDB
  174. if (void 0 !== window.msIndexedDB) return window.msIndexedDB
  175. }
  176. return !1
  177. }
  178. function getMessagesHigherThan(db, lastCursorId) {
  179. var objectStore = db.transaction("messages").objectStore("messages"),
  180. ret = []
  181. return new Promise(function (res) {
  182. ;(function () {
  183. try {
  184. var keyRangeValue = IDBKeyRange.bound(lastCursorId + 1, 1 / 0)
  185. return objectStore.openCursor(keyRangeValue)
  186. } catch (e) {
  187. return objectStore.openCursor()
  188. }
  189. })().onsuccess = function (ev) {
  190. var cursor = ev.target.result
  191. if (cursor)
  192. if (cursor.value.id < lastCursorId + 1)
  193. cursor.continue(lastCursorId + 1)
  194. else {
  195. ret.push(cursor.value)
  196. cursor.continue()
  197. }
  198. else res(ret)
  199. }
  200. })
  201. }
  202. function cleanOldMessages(db, ttl) {
  203. return (function (db, ttl) {
  204. var olderThen = new Date().getTime() - ttl,
  205. objectStore = db.transaction("messages").objectStore("messages"),
  206. ret = []
  207. return new Promise(function (res) {
  208. objectStore.openCursor().onsuccess = function (ev) {
  209. var cursor = ev.target.result
  210. if (cursor) {
  211. var msgObk = cursor.value
  212. if (!(msgObk.time < olderThen)) {
  213. res(ret)
  214. return
  215. }
  216. ret.push(msgObk)
  217. cursor.continue()
  218. } else res(ret)
  219. }
  220. })
  221. })(db, ttl).then(function (tooOld) {
  222. return Promise.all(
  223. tooOld.map(function (msgObj) {
  224. return (function (db, id) {
  225. var request = db
  226. .transaction(["messages"], "readwrite")
  227. .objectStore("messages")
  228. .delete(id)
  229. return new Promise(function (res) {
  230. request.onsuccess = function () {
  231. return res()
  232. }
  233. })
  234. })(db, msgObj.id)
  235. })
  236. )
  237. })
  238. }
  239. function _readLoop(state) {
  240. state.closed ||
  241. readNewMessages(state)
  242. .then(function () {
  243. return sleep(state.options.idb.fallbackInterval)
  244. })
  245. .then(function () {
  246. return _readLoop(state)
  247. })
  248. }
  249. function readNewMessages(state) {
  250. return state.closed
  251. ? Promise.resolve()
  252. : state.messagesCallback
  253. ? getMessagesHigherThan(state.db, state.lastCursorId).then(
  254. function (newerMessages) {
  255. newerMessages
  256. .filter(function (msgObj) {
  257. return !!msgObj
  258. })
  259. .map(function (msgObj) {
  260. msgObj.id > state.lastCursorId &&
  261. (state.lastCursorId = msgObj.id)
  262. return msgObj
  263. })
  264. .filter(function (msgObj) {
  265. return (function (msgObj, state) {
  266. return !(
  267. msgObj.uuid === state.uuid ||
  268. state.eMIs.has(msgObj.id) ||
  269. msgObj.data.time < state.messagesCallbackTime
  270. )
  271. })(msgObj, state)
  272. })
  273. .sort(function (msgObjA, msgObjB) {
  274. return msgObjA.time - msgObjB.time
  275. })
  276. .forEach(function (msgObj) {
  277. if (state.messagesCallback) {
  278. state.eMIs.add(msgObj.id)
  279. state.messagesCallback(msgObj.data)
  280. }
  281. })
  282. return Promise.resolve()
  283. }
  284. )
  285. : Promise.resolve()
  286. }
  287. const indexed_db = {
  288. create: function (channelName, options) {
  289. options = options_fillOptionsWithDefaults(options)
  290. return (function (channelName) {
  291. var dbName = "pubkey.broadcast-channel-0-" + channelName,
  292. openRequest = getIdb().open(dbName, 1)
  293. openRequest.onupgradeneeded = function (ev) {
  294. ev.target.result.createObjectStore("messages", {
  295. keyPath: "id",
  296. autoIncrement: !0,
  297. })
  298. }
  299. return new Promise(function (res, rej) {
  300. openRequest.onerror = function (ev) {
  301. return rej(ev)
  302. }
  303. openRequest.onsuccess = function () {
  304. res(openRequest.result)
  305. }
  306. })
  307. })(channelName).then(function (db) {
  308. var state = {
  309. closed: !1,
  310. lastCursorId: 0,
  311. channelName,
  312. options,
  313. uuid: randomToken(),
  314. eMIs: new ObliviousSet(2 * options.idb.ttl),
  315. writeBlockPromise: Promise.resolve(),
  316. messagesCallback: null,
  317. readQueuePromises: [],
  318. db,
  319. }
  320. db.onclose = function () {
  321. state.closed = !0
  322. options.idb.onclose && options.idb.onclose()
  323. }
  324. _readLoop(state)
  325. return state
  326. })
  327. },
  328. close: function (channelState) {
  329. channelState.closed = !0
  330. channelState.db.close()
  331. },
  332. onMessage: function (channelState, fn, time) {
  333. channelState.messagesCallbackTime = time
  334. channelState.messagesCallback = fn
  335. readNewMessages(channelState)
  336. },
  337. postMessage: function (channelState, messageJson) {
  338. channelState.writeBlockPromise = channelState.writeBlockPromise
  339. .then(function () {
  340. return (function (db, readerUuid, messageJson) {
  341. var writeObject = {
  342. uuid: readerUuid,
  343. time: new Date().getTime(),
  344. data: messageJson,
  345. },
  346. transaction = db.transaction(["messages"], "readwrite")
  347. return new Promise(function (res, rej) {
  348. transaction.oncomplete = function () {
  349. return res()
  350. }
  351. transaction.onerror = function (ev) {
  352. return rej(ev)
  353. }
  354. transaction.objectStore("messages").add(writeObject)
  355. })
  356. })(channelState.db, channelState.uuid, messageJson)
  357. })
  358. .then(function () {
  359. 0 ===
  360. (function (min, max) {
  361. return Math.floor(Math.random() * (max - min + 1) + min)
  362. })(0, 10) &&
  363. cleanOldMessages(
  364. channelState.db,
  365. channelState.options.idb.ttl
  366. )
  367. })
  368. return channelState.writeBlockPromise
  369. },
  370. canBeUsed: function () {
  371. return !isNode && !!getIdb()
  372. },
  373. type: "idb",
  374. averageResponseTime: function (options) {
  375. return 2 * options.idb.fallbackInterval
  376. },
  377. microSeconds,
  378. }
  379. function getLocalStorage() {
  380. var localStorage
  381. if ("undefined" == typeof window) return null
  382. try {
  383. localStorage = window.localStorage
  384. localStorage =
  385. window["ie8-eventlistener/storage"] || window.localStorage
  386. } catch (e) {}
  387. return localStorage
  388. }
  389. function storageKey(channelName) {
  390. return "pubkey.broadcastChannel-" + channelName
  391. }
  392. function localstorage_canBeUsed() {
  393. if (isNode) return !1
  394. var ls = getLocalStorage()
  395. if (!ls) return !1
  396. try {
  397. var key = "__broadcastchannel_check"
  398. ls.setItem(key, "works")
  399. ls.removeItem(key)
  400. } catch (e) {
  401. return !1
  402. }
  403. return !0
  404. }
  405. const localstorage = {
  406. create: function (channelName, options) {
  407. options = options_fillOptionsWithDefaults(options)
  408. if (!localstorage_canBeUsed())
  409. throw new Error("BroadcastChannel: localstorage cannot be used")
  410. var uuid = randomToken(),
  411. eMIs = new ObliviousSet(options.localstorage.removeTimeout),
  412. state = { channelName, uuid, eMIs }
  413. state.listener = (function (channelName, fn) {
  414. var key = storageKey(channelName),
  415. listener = function (ev) {
  416. ev.key === key && fn(JSON.parse(ev.newValue))
  417. }
  418. window.addEventListener("storage", listener)
  419. return listener
  420. })(channelName, function (msgObj) {
  421. if (
  422. state.messagesCallback &&
  423. msgObj.uuid !== uuid &&
  424. msgObj.token &&
  425. !eMIs.has(msgObj.token) &&
  426. !(
  427. msgObj.data.time &&
  428. msgObj.data.time < state.messagesCallbackTime
  429. )
  430. ) {
  431. eMIs.add(msgObj.token)
  432. state.messagesCallback(msgObj.data)
  433. }
  434. })
  435. return state
  436. },
  437. close: function (channelState) {
  438. ;(listener = channelState.listener),
  439. window.removeEventListener("storage", listener)
  440. var listener
  441. },
  442. onMessage: function (channelState, fn, time) {
  443. channelState.messagesCallbackTime = time
  444. channelState.messagesCallback = fn
  445. },
  446. postMessage: function (channelState, messageJson) {
  447. return new Promise(function (res) {
  448. sleep().then(function () {
  449. var key = storageKey(channelState.channelName),
  450. writeObj = {
  451. token: randomToken(),
  452. time: new Date().getTime(),
  453. data: messageJson,
  454. uuid: channelState.uuid,
  455. },
  456. value = JSON.stringify(writeObj)
  457. getLocalStorage().setItem(key, value)
  458. var ev = document.createEvent("Event")
  459. ev.initEvent("storage", !0, !0)
  460. ev.key = key
  461. ev.newValue = value
  462. window.dispatchEvent(ev)
  463. res()
  464. })
  465. })
  466. },
  467. canBeUsed: localstorage_canBeUsed,
  468. type: "localstorage",
  469. averageResponseTime: function () {
  470. var userAgent = navigator.userAgent.toLowerCase()
  471. return userAgent.includes("safari") && !userAgent.includes("chrome")
  472. ? 240
  473. : 120
  474. },
  475. microSeconds,
  476. }
  477. var simulate_microSeconds = microSeconds,
  478. SIMULATE_CHANNELS = new Set()
  479. const simulate = {
  480. create: function (channelName) {
  481. var state = { name: channelName, messagesCallback: null }
  482. SIMULATE_CHANNELS.add(state)
  483. return state
  484. },
  485. close: function (channelState) {
  486. SIMULATE_CHANNELS.delete(channelState)
  487. },
  488. onMessage: function (channelState, fn) {
  489. channelState.messagesCallback = fn
  490. },
  491. postMessage: function (channelState, messageJson) {
  492. return new Promise(function (res) {
  493. return setTimeout(function () {
  494. Array.from(SIMULATE_CHANNELS)
  495. .filter(function (channel) {
  496. return channel.name === channelState.name
  497. })
  498. .filter(function (channel) {
  499. return channel !== channelState
  500. })
  501. .filter(function (channel) {
  502. return !!channel.messagesCallback
  503. })
  504. .forEach(function (channel) {
  505. return channel.messagesCallback(messageJson)
  506. })
  507. res()
  508. }, 5)
  509. })
  510. },
  511. canBeUsed: function () {
  512. return !0
  513. },
  514. type: "simulate",
  515. averageResponseTime: function () {
  516. return 5
  517. },
  518. microSeconds: simulate_microSeconds,
  519. }
  520. var METHODS = [methods_native, indexed_db, localstorage]
  521. if (isNode) {
  522. var NodeMethod = __webpack_require__(633)
  523. "function" == typeof NodeMethod.canBeUsed && METHODS.push(NodeMethod)
  524. }
  525. var ENFORCED_OPTIONS,
  526. broadcast_channel_BroadcastChannel = function (name, options) {
  527. this.name = name
  528. ENFORCED_OPTIONS && (options = ENFORCED_OPTIONS)
  529. this.options = options_fillOptionsWithDefaults(options)
  530. this.method = (function (options) {
  531. var chooseMethods = []
  532. .concat(options.methods, METHODS)
  533. .filter(Boolean)
  534. if (options.type) {
  535. if ("simulate" === options.type) return simulate
  536. var ret = chooseMethods.find(function (m) {
  537. return m.type === options.type
  538. })
  539. if (ret) return ret
  540. throw new Error("method-type " + options.type + " not found")
  541. }
  542. options.webWorkerSupport ||
  543. isNode ||
  544. (chooseMethods = chooseMethods.filter(function (m) {
  545. return "idb" !== m.type
  546. }))
  547. var useMethod = chooseMethods.find(function (method) {
  548. return method.canBeUsed()
  549. })
  550. if (useMethod) return useMethod
  551. throw new Error(
  552. "No useable methode found:" +
  553. JSON.stringify(
  554. METHODS.map(function (m) {
  555. return m.type
  556. })
  557. )
  558. )
  559. })(this.options)
  560. this._iL = !1
  561. this._onML = null
  562. this._addEL = { message: [], internal: [] }
  563. this._uMP = new Set()
  564. this._befC = []
  565. this._prepP = null
  566. !(function (channel) {
  567. var maybePromise = channel.method.create(
  568. channel.name,
  569. channel.options
  570. )
  571. if (
  572. ((obj = maybePromise), obj && "function" == typeof obj.then)
  573. ) {
  574. channel._prepP = maybePromise
  575. maybePromise.then(function (s) {
  576. channel._state = s
  577. })
  578. } else channel._state = maybePromise
  579. var obj
  580. })(this)
  581. }
  582. broadcast_channel_BroadcastChannel._pubkey = !0
  583. broadcast_channel_BroadcastChannel.prototype = {
  584. postMessage: function (msg) {
  585. if (this.closed)
  586. throw new Error(
  587. "BroadcastChannel.postMessage(): Cannot post message after channel has closed"
  588. )
  589. return _post(this, "message", msg)
  590. },
  591. postInternal: function (msg) {
  592. return _post(this, "internal", msg)
  593. },
  594. set onmessage(fn) {
  595. var listenObj = { time: this.method.microSeconds(), fn }
  596. _removeListenerObject(this, "message", this._onML)
  597. if (fn && "function" == typeof fn) {
  598. this._onML = listenObj
  599. _addListenerObject(this, "message", listenObj)
  600. } else this._onML = null
  601. },
  602. addEventListener: function (type, fn) {
  603. _addListenerObject(this, type, {
  604. time: this.method.microSeconds(),
  605. fn,
  606. })
  607. },
  608. removeEventListener: function (type, fn) {
  609. _removeListenerObject(
  610. this,
  611. type,
  612. this._addEL[type].find(function (obj) {
  613. return obj.fn === fn
  614. })
  615. )
  616. },
  617. close: function () {
  618. var _this = this
  619. if (!this.closed) {
  620. this.closed = !0
  621. var awaitPrepare = this._prepP ? this._prepP : Promise.resolve()
  622. this._onML = null
  623. this._addEL.message = []
  624. return awaitPrepare
  625. .then(function () {
  626. return Promise.all(Array.from(_this._uMP))
  627. })
  628. .then(function () {
  629. return Promise.all(
  630. _this._befC.map(function (fn) {
  631. return fn()
  632. })
  633. )
  634. })
  635. .then(function () {
  636. return _this.method.close(_this._state)
  637. })
  638. }
  639. },
  640. get type() {
  641. return this.method.type
  642. },
  643. get isClosed() {
  644. return this.closed
  645. },
  646. }
  647. function _post(broadcastChannel, type, msg) {
  648. var msgObj = {
  649. time: broadcastChannel.method.microSeconds(),
  650. type,
  651. data: msg,
  652. }
  653. return (
  654. broadcastChannel._prepP
  655. ? broadcastChannel._prepP
  656. : Promise.resolve()
  657. ).then(function () {
  658. var sendPromise = broadcastChannel.method.postMessage(
  659. broadcastChannel._state,
  660. msgObj
  661. )
  662. broadcastChannel._uMP.add(sendPromise)
  663. sendPromise.catch().then(function () {
  664. return broadcastChannel._uMP.delete(sendPromise)
  665. })
  666. return sendPromise
  667. })
  668. }
  669. function _hasMessageListeners(channel) {
  670. return (
  671. channel._addEL.message.length > 0 ||
  672. channel._addEL.internal.length > 0
  673. )
  674. }
  675. function _addListenerObject(channel, type, obj) {
  676. channel._addEL[type].push(obj)
  677. !(function (channel) {
  678. if (!channel._iL && _hasMessageListeners(channel)) {
  679. var listenerFn = function (msgObj) {
  680. channel._addEL[msgObj.type].forEach(function (obj) {
  681. msgObj.time >= obj.time && obj.fn(msgObj.data)
  682. })
  683. },
  684. time = channel.method.microSeconds()
  685. if (channel._prepP)
  686. channel._prepP.then(function () {
  687. channel._iL = !0
  688. channel.method.onMessage(channel._state, listenerFn, time)
  689. })
  690. else {
  691. channel._iL = !0
  692. channel.method.onMessage(channel._state, listenerFn, time)
  693. }
  694. }
  695. })(channel)
  696. }
  697. function _removeListenerObject(channel, type, obj) {
  698. channel._addEL[type] = channel._addEL[type].filter(function (o) {
  699. return o !== obj
  700. })
  701. !(function (channel) {
  702. if (channel._iL && !_hasMessageListeners(channel)) {
  703. channel._iL = !1
  704. var time = channel.method.microSeconds()
  705. channel.method.onMessage(channel._state, null, time)
  706. }
  707. })(channel)
  708. }
  709. const external_DeepDiff_namespaceObject = DeepDiff
  710. var function_getMonoid = function (M) {
  711. var S,
  712. getSemigroupM =
  713. ((S = M),
  714. function () {
  715. return {
  716. concat: function (f, g) {
  717. return function (a) {
  718. return S.concat(f(a), g(a))
  719. }
  720. },
  721. }
  722. })
  723. return function () {
  724. return {
  725. concat: getSemigroupM().concat,
  726. empty: function () {
  727. return M.empty
  728. },
  729. }
  730. }
  731. }
  732. function function_identity(a) {
  733. return a
  734. }
  735. function constant(a) {
  736. return function () {
  737. return a
  738. }
  739. }
  740. var constUndefined = constant(void 0)
  741. function function_flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
  742. switch (arguments.length) {
  743. case 1:
  744. return ab
  745. case 2:
  746. return function () {
  747. return bc(ab.apply(this, arguments))
  748. }
  749. case 3:
  750. return function () {
  751. return cd(bc(ab.apply(this, arguments)))
  752. }
  753. case 4:
  754. return function () {
  755. return de(cd(bc(ab.apply(this, arguments))))
  756. }
  757. case 5:
  758. return function () {
  759. return ef(de(cd(bc(ab.apply(this, arguments)))))
  760. }
  761. case 6:
  762. return function () {
  763. return fg(ef(de(cd(bc(ab.apply(this, arguments))))))
  764. }
  765. case 7:
  766. return function () {
  767. return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))
  768. }
  769. case 8:
  770. return function () {
  771. return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))))
  772. }
  773. case 9:
  774. return function () {
  775. return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))))
  776. }
  777. }
  778. }
  779. function function_pipe(
  780. a,
  781. ab,
  782. bc,
  783. cd,
  784. de,
  785. ef,
  786. fg,
  787. gh,
  788. hi,
  789. ij,
  790. jk,
  791. kl,
  792. lm,
  793. mn,
  794. no,
  795. op,
  796. pq,
  797. qr,
  798. rs,
  799. st
  800. ) {
  801. switch (arguments.length) {
  802. case 1:
  803. return a
  804. case 2:
  805. return ab(a)
  806. case 3:
  807. return bc(ab(a))
  808. case 4:
  809. return cd(bc(ab(a)))
  810. case 5:
  811. return de(cd(bc(ab(a))))
  812. case 6:
  813. return ef(de(cd(bc(ab(a)))))
  814. case 7:
  815. return fg(ef(de(cd(bc(ab(a))))))
  816. case 8:
  817. return gh(fg(ef(de(cd(bc(ab(a)))))))
  818. case 9:
  819. return hi(gh(fg(ef(de(cd(bc(ab(a))))))))
  820. case 10:
  821. return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))
  822. case 11:
  823. return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))
  824. case 12:
  825. return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))
  826. case 13:
  827. return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))
  828. case 14:
  829. return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))
  830. case 15:
  831. return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  832. case 16:
  833. return op(
  834. no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  835. )
  836. case 17:
  837. return pq(
  838. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  839. )
  840. case 18:
  841. return qr(
  842. pq(
  843. op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))
  844. )
  845. )
  846. case 19:
  847. return rs(
  848. qr(
  849. pq(
  850. op(
  851. no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))
  852. )
  853. )
  854. )
  855. )
  856. case 20:
  857. return st(
  858. rs(
  859. qr(
  860. pq(
  861. op(
  862. no(
  863. mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))
  864. )
  865. )
  866. )
  867. )
  868. )
  869. )
  870. }
  871. }
  872. var isSome = function (fa) {
  873. return "Some" === fa._tag
  874. },
  875. none = { _tag: "None" },
  876. some = function (a) {
  877. return { _tag: "Some", value: a }
  878. },
  879. internal_isNonEmpty = function (as) {
  880. return as.length > 0
  881. },
  882. head = function (as) {
  883. return as[0]
  884. },
  885. emptyReadonlyArray = [],
  886. Predicate_not =
  887. (Object.prototype.hasOwnProperty,
  888. function (predicate) {
  889. return function (a) {
  890. return !predicate(a)
  891. }
  892. })
  893. function map(F, G) {
  894. return function (f) {
  895. return function (fa) {
  896. return F.map(fa, function (ga) {
  897. return G.map(ga, f)
  898. })
  899. }
  900. }
  901. }
  902. function flap(F) {
  903. return function (a) {
  904. return function (fab) {
  905. return F.map(fab, function (f) {
  906. return f(a)
  907. })
  908. }
  909. }
  910. }
  911. function bindTo(F) {
  912. return function (name) {
  913. return function (fa) {
  914. return F.map(fa, function (a) {
  915. var _a
  916. return ((_a = {})[name] = a), _a
  917. })
  918. }
  919. }
  920. }
  921. function Functor_getFunctorComposition(F, G) {
  922. var _map = map(F, G)
  923. return {
  924. map: function (fga, f) {
  925. return function_pipe(fga, _map(f))
  926. },
  927. }
  928. }
  929. var separated = function (left, right) {
  930. return { left, right }
  931. },
  932. Separated_map = function (f) {
  933. return function (fa) {
  934. return separated(Separated_left(fa), f(Separated_right(fa)))
  935. }
  936. },
  937. Separated_left =
  938. (flap({
  939. URI: "Separated",
  940. map: function (fa, f) {
  941. return function_pipe(fa, Separated_map(f))
  942. },
  943. }),
  944. function (s) {
  945. return s.left
  946. }),
  947. Separated_right = function (s) {
  948. return s.right
  949. }
  950. function wiltDefault(T, C) {
  951. return function (F) {
  952. var traverseF = T.traverse(F)
  953. return function (wa, f) {
  954. return F.map(traverseF(wa, f), C.separate)
  955. }
  956. }
  957. }
  958. function witherDefault(T, C) {
  959. return function (F) {
  960. var traverseF = T.traverse(F)
  961. return function (wa, f) {
  962. return F.map(traverseF(wa, f), C.compact)
  963. }
  964. }
  965. }
  966. var Option_none = none,
  967. Option_some = some
  968. function fromPredicate(predicate) {
  969. return function (a) {
  970. return predicate(a) ? Option_some(a) : Option_none
  971. }
  972. }
  973. var getLeft = function (ma) {
  974. return "Right" === ma._tag ? Option_none : Option_some(ma.left)
  975. },
  976. getRight = function (ma) {
  977. return "Left" === ma._tag ? Option_none : Option_some(ma.right)
  978. },
  979. Option_map = function (fa, f) {
  980. return function_pipe(fa, es6_Option_map(f))
  981. },
  982. _ap = function (fab, fa) {
  983. return function_pipe(fab, ap(fa))
  984. },
  985. _chain = function (ma, f) {
  986. return function_pipe(ma, chain(f))
  987. },
  988. _reduce = function (fa, b, f) {
  989. return function_pipe(fa, reduce(b, f))
  990. },
  991. _foldMap = function (M) {
  992. var foldMapM = foldMap(M)
  993. return function (fa, f) {
  994. return function_pipe(fa, foldMapM(f))
  995. }
  996. },
  997. _reduceRight = function (fa, b, f) {
  998. return function_pipe(fa, reduceRight(b, f))
  999. },
  1000. _traverse = function (F) {
  1001. var traverseF = traverse(F)
  1002. return function (ta, f) {
  1003. return function_pipe(ta, traverseF(f))
  1004. }
  1005. },
  1006. _alt = function (fa, that) {
  1007. return function_pipe(fa, alt(that))
  1008. },
  1009. _filter = function (fa, predicate) {
  1010. return function_pipe(fa, filter(predicate))
  1011. },
  1012. _filterMap = function (fa, f) {
  1013. return function_pipe(fa, filterMap(f))
  1014. },
  1015. _extend = function (wa, f) {
  1016. return function_pipe(wa, extend(f))
  1017. },
  1018. _partition = function (fa, predicate) {
  1019. return function_pipe(fa, partition(predicate))
  1020. },
  1021. _partitionMap = function (fa, f) {
  1022. return function_pipe(fa, partitionMap(f))
  1023. },
  1024. getEq = function (E) {
  1025. return {
  1026. equals: function (x, y) {
  1027. return (
  1028. x === y ||
  1029. (Option_isNone(x)
  1030. ? Option_isNone(y)
  1031. : !Option_isNone(y) && E.equals(x.value, y.value))
  1032. )
  1033. },
  1034. }
  1035. },
  1036. es6_Option_map = function (f) {
  1037. return function (fa) {
  1038. return Option_isNone(fa) ? Option_none : Option_some(f(fa.value))
  1039. }
  1040. },
  1041. Option_Functor = { URI: "Option", map: Option_map },
  1042. of = Option_some,
  1043. ap = function (fa) {
  1044. return function (fab) {
  1045. return Option_isNone(fab) || Option_isNone(fa)
  1046. ? Option_none
  1047. : Option_some(fab.value(fa.value))
  1048. }
  1049. },
  1050. Apply = { URI: "Option", map: Option_map, ap: _ap },
  1051. chain = function (f) {
  1052. return function (ma) {
  1053. return Option_isNone(ma) ? Option_none : f(ma.value)
  1054. }
  1055. },
  1056. reduce = function (b, f) {
  1057. return function (fa) {
  1058. return Option_isNone(fa) ? b : f(b, fa.value)
  1059. }
  1060. },
  1061. foldMap = function (M) {
  1062. return function (f) {
  1063. return function (fa) {
  1064. return Option_isNone(fa) ? M.empty : f(fa.value)
  1065. }
  1066. }
  1067. },
  1068. reduceRight = function (b, f) {
  1069. return function (fa) {
  1070. return Option_isNone(fa) ? b : f(fa.value, b)
  1071. }
  1072. },
  1073. alt = function (that) {
  1074. return function (fa) {
  1075. return Option_isNone(fa) ? that() : fa
  1076. }
  1077. },
  1078. zero = function () {
  1079. return Option_none
  1080. },
  1081. extend = function (f) {
  1082. return function (wa) {
  1083. return Option_isNone(wa) ? Option_none : Option_some(f(wa))
  1084. }
  1085. },
  1086. compact = chain(function_identity),
  1087. defaultSeparated = separated(Option_none, Option_none),
  1088. separate = function (ma) {
  1089. return Option_isNone(ma)
  1090. ? defaultSeparated
  1091. : separated(getLeft(ma.value), getRight(ma.value))
  1092. },
  1093. Compactable = { URI: "Option", compact, separate },
  1094. filter = function (predicate) {
  1095. return function (fa) {
  1096. return Option_isNone(fa)
  1097. ? Option_none
  1098. : predicate(fa.value)
  1099. ? fa
  1100. : Option_none
  1101. }
  1102. },
  1103. filterMap = function (f) {
  1104. return function (fa) {
  1105. return Option_isNone(fa) ? Option_none : f(fa.value)
  1106. }
  1107. },
  1108. partition = function (predicate) {
  1109. return function (fa) {
  1110. return separated(
  1111. _filter(fa, Predicate_not(predicate)),
  1112. _filter(fa, predicate)
  1113. )
  1114. }
  1115. },
  1116. partitionMap = function (f) {
  1117. return function_flow(es6_Option_map(f), separate)
  1118. },
  1119. traverse = function (F) {
  1120. return function (f) {
  1121. return function (ta) {
  1122. return Option_isNone(ta)
  1123. ? F.of(Option_none)
  1124. : F.map(f(ta.value), Option_some)
  1125. }
  1126. }
  1127. },
  1128. sequence = function (F) {
  1129. return function (ta) {
  1130. return Option_isNone(ta)
  1131. ? F.of(Option_none)
  1132. : F.map(ta.value, Option_some)
  1133. }
  1134. },
  1135. Traversable = {
  1136. URI: "Option",
  1137. map: Option_map,
  1138. reduce: _reduce,
  1139. foldMap: _foldMap,
  1140. reduceRight: _reduceRight,
  1141. traverse: _traverse,
  1142. sequence,
  1143. },
  1144. _wither = witherDefault(Traversable, Compactable),
  1145. _wilt = wiltDefault(Traversable, Compactable),
  1146. throwError = function () {
  1147. return Option_none
  1148. },
  1149. Option_isSome = isSome,
  1150. Option_isNone = function (fa) {
  1151. return "None" === fa._tag
  1152. },
  1153. matchW = function (onNone, onSome) {
  1154. return function (ma) {
  1155. return Option_isNone(ma) ? onNone() : onSome(ma.value)
  1156. }
  1157. },
  1158. match = matchW,
  1159. getOrElseW = function (onNone) {
  1160. return function (ma) {
  1161. return Option_isNone(ma) ? onNone() : ma.value
  1162. }
  1163. },
  1164. getOrElse = getOrElseW,
  1165. fromNullable = function (a) {
  1166. return null == a ? Option_none : Option_some(a)
  1167. },
  1168. chainNullableK = function (f) {
  1169. return function (ma) {
  1170. return Option_isNone(ma) ? Option_none : fromNullable(f(ma.value))
  1171. }
  1172. },
  1173. toUndefined = match(constUndefined, function_identity)
  1174. of(emptyReadonlyArray)
  1175. var Option_option = {
  1176. URI: "Option",
  1177. map: Option_map,
  1178. of,
  1179. ap: _ap,
  1180. chain: _chain,
  1181. reduce: _reduce,
  1182. foldMap: _foldMap,
  1183. reduceRight: _reduceRight,
  1184. traverse: _traverse,
  1185. sequence,
  1186. zero,
  1187. alt: _alt,
  1188. extend: _extend,
  1189. compact,
  1190. separate,
  1191. filter: _filter,
  1192. filterMap: _filterMap,
  1193. partition: _partition,
  1194. partitionMap: _partitionMap,
  1195. wither: _wither,
  1196. wilt: _wilt,
  1197. throwError,
  1198. }
  1199. function Apply_apSecond(A) {
  1200. return function (second) {
  1201. return function (first) {
  1202. return A.ap(
  1203. A.map(first, function () {
  1204. return function (b) {
  1205. return b
  1206. }
  1207. }),
  1208. second
  1209. )
  1210. }
  1211. }
  1212. }
  1213. function OptionT_some(F) {
  1214. return function_flow(Option_some, F.of)
  1215. }
  1216. function OptionT_zero(F) {
  1217. return constant(F.of(Option_none))
  1218. }
  1219. function fromF(F) {
  1220. return function (ma) {
  1221. return F.map(ma, Option_some)
  1222. }
  1223. }
  1224. function OptionT_chain(M) {
  1225. var zeroM = OptionT_zero(M)
  1226. return function (f) {
  1227. return function (ma) {
  1228. return M.chain(
  1229. ma,
  1230. match(function () {
  1231. return zeroM()
  1232. }, f)
  1233. )
  1234. }
  1235. }
  1236. }
  1237. function Compactable_compact(F, G) {
  1238. return function (fga) {
  1239. return F.map(fga, G.compact)
  1240. }
  1241. }
  1242. function Compactable_separate(F, C, G) {
  1243. var _compact = Compactable_compact(F, C),
  1244. _map = map(F, G)
  1245. return function (fge) {
  1246. return separated(
  1247. _compact(function_pipe(fge, _map(getLeft))),
  1248. _compact(function_pipe(fge, _map(getRight)))
  1249. )
  1250. }
  1251. }
  1252. function Filterable_filter(F, G) {
  1253. return function (predicate) {
  1254. return function (fga) {
  1255. return F.map(fga, function (ga) {
  1256. return G.filter(ga, predicate)
  1257. })
  1258. }
  1259. }
  1260. }
  1261. function Filterable_filterMap(F, G) {
  1262. return function (f) {
  1263. return function (fga) {
  1264. return F.map(fga, function (ga) {
  1265. return G.filterMap(ga, f)
  1266. })
  1267. }
  1268. }
  1269. }
  1270. function Chain_chainFirst(M) {
  1271. return function (f) {
  1272. return function (first) {
  1273. return M.chain(first, function (a) {
  1274. return M.map(f(a), function () {
  1275. return a
  1276. })
  1277. })
  1278. }
  1279. }
  1280. }
  1281. var M,
  1282. apM,
  1283. mapM,
  1284. chainM,
  1285. altM,
  1286. foldM,
  1287. getOrElseM,
  1288. zeroM,
  1289. IO_map = function (ma, f) {
  1290. return function () {
  1291. return f(ma())
  1292. }
  1293. },
  1294. IO_ap = function (mab, ma) {
  1295. return function () {
  1296. return mab()(ma())
  1297. }
  1298. },
  1299. IO_chain = function (ma, f) {
  1300. return function () {
  1301. return f(ma())()
  1302. }
  1303. },
  1304. _chainRec = function (a, f) {
  1305. return function () {
  1306. for (var e = f(a)(); "Left" === e._tag; ) e = f(e.left)()
  1307. return e.right
  1308. }
  1309. },
  1310. es6_IO_map = function (f) {
  1311. return function (fa) {
  1312. return IO_map(fa, f)
  1313. }
  1314. },
  1315. IO_of = constant,
  1316. es6_IO_chain = function (f) {
  1317. return function (ma) {
  1318. return IO_chain(ma, f)
  1319. }
  1320. },
  1321. IO_Functor = { URI: "IO", map: IO_map },
  1322. IO_Apply = (flap(IO_Functor), { URI: "IO", map: IO_map, ap: IO_ap }),
  1323. IO_apSecond = Apply_apSecond(IO_Apply),
  1324. IO_Chain = { URI: "IO", map: IO_map, ap: IO_ap, chain: IO_chain },
  1325. IO_chainFirst = Chain_chainFirst(IO_Chain),
  1326. fromIO = function_identity,
  1327. IO_ApT = IO_of(emptyReadonlyArray),
  1328. IO_traverseReadonlyArrayWithIndex = function (f) {
  1329. var g = (function (f) {
  1330. return function (as) {
  1331. return function () {
  1332. for (var out = [f(0, head(as))()], i = 1; i < as.length; i++)
  1333. out.push(f(i, as[i])())
  1334. return out
  1335. }
  1336. }
  1337. })(f)
  1338. return function (as) {
  1339. return internal_isNonEmpty(as) ? g(as) : IO_ApT
  1340. }
  1341. },
  1342. IO_sequenceArray = (function (f) {
  1343. return IO_traverseReadonlyArrayWithIndex(function (_, a) {
  1344. return f(a)
  1345. })
  1346. })(function_identity),
  1347. IO_io = {
  1348. URI: "IO",
  1349. map: IO_map,
  1350. of: IO_of,
  1351. ap: IO_ap,
  1352. chain: IO_chain,
  1353. fromIO,
  1354. chainRec: _chainRec,
  1355. },
  1356. __assign = function () {
  1357. return (__assign =
  1358. Object.assign ||
  1359. function (t) {
  1360. for (var s, i = 1, n = arguments.length; i < n; i++) {
  1361. s = arguments[i]
  1362. for (var p in s)
  1363. Object.prototype.hasOwnProperty.call(s, p) && (t[p] = s[p])
  1364. }
  1365. return t
  1366. }).apply(this, arguments)
  1367. },
  1368. T =
  1369. ((apM = (function (F) {
  1370. return (function (F, G) {
  1371. return function (fa) {
  1372. return function (fab) {
  1373. return F.ap(
  1374. F.map(fab, function (gab) {
  1375. return function (ga) {
  1376. return G.ap(gab, ga)
  1377. }
  1378. }),
  1379. fa
  1380. )
  1381. }
  1382. }
  1383. })(F, Apply)
  1384. })((M = IO_io))),
  1385. (mapM = (function (F) {
  1386. return map(F, Option_Functor)
  1387. })(M)),
  1388. (chainM = OptionT_chain(M)),
  1389. (altM = (function (M) {
  1390. var _some = OptionT_some(M)
  1391. return function (second) {
  1392. return function (first) {
  1393. return M.chain(first, match(second, _some))
  1394. }
  1395. }
  1396. })(M)),
  1397. (foldM = (function (M) {
  1398. return function (onNone, onSome) {
  1399. return function (ma) {
  1400. return M.chain(ma, match(onNone, onSome))
  1401. }
  1402. }
  1403. })(M)),
  1404. (getOrElseM = (function (M) {
  1405. return function (onNone) {
  1406. return function (fa) {
  1407. return M.chain(fa, match(onNone, M.of))
  1408. }
  1409. }
  1410. })(M)),
  1411. (zeroM = OptionT_zero(M)),
  1412. {
  1413. map: function (fa, f) {
  1414. return function_pipe(fa, mapM(f))
  1415. },
  1416. ap: function (fab, fa) {
  1417. return function_pipe(fab, apM(fa))
  1418. },
  1419. of: OptionT_some(M),
  1420. chain: function (ma, f) {
  1421. return function_pipe(ma, chainM(f))
  1422. },
  1423. alt: function (fa, that) {
  1424. return function_pipe(fa, altM(that))
  1425. },
  1426. fold: function (fa, onNone, onSome) {
  1427. return function_pipe(fa, foldM(onNone, onSome))
  1428. },
  1429. getOrElse: function (fa, onNone) {
  1430. return function_pipe(fa, getOrElseM(onNone))
  1431. },
  1432. fromM: fromF(M),
  1433. none: function () {
  1434. return zeroM()
  1435. },
  1436. }),
  1437. F = (function (F, G) {
  1438. var map = Functor_getFunctorComposition(F, G).map,
  1439. _compact = Compactable_compact(F, G),
  1440. _separate = Compactable_separate(F, G, G),
  1441. _filter = Filterable_filter(F, G),
  1442. _filterMap = Filterable_filterMap(F, G),
  1443. _partition = (function (F, G) {
  1444. var _filter = Filterable_filter(F, G)
  1445. return function (predicate) {
  1446. var left = _filter(Predicate_not(predicate)),
  1447. right = _filter(predicate)
  1448. return function (fgb) {
  1449. return separated(left(fgb), right(fgb))
  1450. }
  1451. }
  1452. })(F, G),
  1453. _partitionMap = (function (F, G) {
  1454. var _filterMap = Filterable_filterMap(F, G)
  1455. return function (f) {
  1456. return function (fga) {
  1457. return separated(
  1458. function_pipe(
  1459. fga,
  1460. _filterMap(function (a) {
  1461. return getLeft(f(a))
  1462. })
  1463. ),
  1464. function_pipe(
  1465. fga,
  1466. _filterMap(function (a) {
  1467. return getRight(f(a))
  1468. })
  1469. )
  1470. )
  1471. }
  1472. }
  1473. })(F, G)
  1474. return {
  1475. map,
  1476. compact: _compact,
  1477. separate: _separate,
  1478. filter: function (fga, f) {
  1479. return function_pipe(fga, _filter(f))
  1480. },
  1481. filterMap: function (fga, f) {
  1482. return function_pipe(fga, _filterMap(f))
  1483. },
  1484. partition: function (fga, p) {
  1485. return function_pipe(fga, _partition(p))
  1486. },
  1487. partitionMap: function (fga, f) {
  1488. return function_pipe(fga, _partitionMap(f))
  1489. },
  1490. }
  1491. })(IO_io, Option_option),
  1492. IOOption_some = (T.none(), T.of),
  1493. IOOption_fromIO = T.fromM,
  1494. fromOption = IO_of,
  1495. IOOption_map = function (f) {
  1496. return function (fa) {
  1497. return T.map(fa, f)
  1498. }
  1499. },
  1500. IOOption_chain = function (f) {
  1501. return function (ma) {
  1502. return T.chain(ma, f)
  1503. }
  1504. },
  1505. IOOption_chainFirst = function (f) {
  1506. return function (ma) {
  1507. return T.chain(ma, function (a) {
  1508. return T.map(f(a), function () {
  1509. return a
  1510. })
  1511. })
  1512. }
  1513. },
  1514. IOOption_chainOptionK = function (f) {
  1515. return IOOption_chain(
  1516. (function (f) {
  1517. return function () {
  1518. for (var a = [], _i = 0; _i < arguments.length; _i++)
  1519. a[_i] = arguments[_i]
  1520. return fromOption(f.apply(void 0, a))
  1521. }
  1522. })(f)
  1523. )
  1524. },
  1525. IOOption_filter =
  1526. (F.compact,
  1527. F.separate,
  1528. function (predicate) {
  1529. return function (fa) {
  1530. return F.filter(fa, predicate)
  1531. }
  1532. }),
  1533. eqStrict =
  1534. (T.map,
  1535. T.map,
  1536. T.ap,
  1537. T.map,
  1538. T.ap,
  1539. T.map,
  1540. T.ap,
  1541. T.chain,
  1542. T.map,
  1543. T.alt,
  1544. T.map,
  1545. T.ap,
  1546. T.alt,
  1547. T.map,
  1548. F.filter,
  1549. F.filterMap,
  1550. F.partition,
  1551. F.partitionMap,
  1552. __assign(
  1553. {
  1554. URI: "IOOption",
  1555. of: IOOption_some,
  1556. ap: T.ap,
  1557. chain: T.chain,
  1558. alt: T.alt,
  1559. fromIO: IOOption_fromIO,
  1560. },
  1561. F
  1562. ),
  1563. {
  1564. equals: function (a, b) {
  1565. return a === b
  1566. },
  1567. }),
  1568. ReadonlyNonEmptyArray_spreadArray = function (to, from) {
  1569. for (var i = 0, il = from.length, j = to.length; i < il; i++, j++)
  1570. to[j] = from[i]
  1571. return to
  1572. },
  1573. ReadonlyNonEmptyArray_empty = emptyReadonlyArray,
  1574. ReadonlyNonEmptyArray_isNonEmpty = internal_isNonEmpty,
  1575. isOutOfBound = function (i, as) {
  1576. return i < 0 || i >= as.length
  1577. },
  1578. appendW = function (end) {
  1579. return function (init) {
  1580. return ReadonlyNonEmptyArray_spreadArray(
  1581. ReadonlyNonEmptyArray_spreadArray([], init),
  1582. [end]
  1583. )
  1584. }
  1585. },
  1586. append = appendW,
  1587. uniq = function (E) {
  1588. return function (as) {
  1589. if (1 === as.length) return as
  1590. for (
  1591. var out = [ReadonlyNonEmptyArray_head(as)],
  1592. _loop_1 = function (a) {
  1593. out.every(function (o) {
  1594. return !E.equals(o, a)
  1595. }) && out.push(a)
  1596. },
  1597. _i = 0,
  1598. rest_1 = ReadonlyNonEmptyArray_tail(as);
  1599. _i < rest_1.length;
  1600. _i++
  1601. ) {
  1602. _loop_1(rest_1[_i])
  1603. }
  1604. return out
  1605. }
  1606. },
  1607. makeBy = function (f) {
  1608. return function (n) {
  1609. for (
  1610. var j = Math.max(0, Math.floor(n)), out = [f(0)], i = 1;
  1611. i < j;
  1612. i++
  1613. )
  1614. out.push(f(i))
  1615. return out
  1616. }
  1617. }
  1618. var ReadonlyNonEmptyArray_map = function (fa, f) {
  1619. return function_pipe(fa, es6_ReadonlyNonEmptyArray_map(f))
  1620. },
  1621. es6_ReadonlyNonEmptyArray_map = function (f) {
  1622. return mapWithIndex(function (_, a) {
  1623. return f(a)
  1624. })
  1625. },
  1626. mapWithIndex = function (f) {
  1627. return function (as) {
  1628. for (
  1629. var out = [f(0, ReadonlyNonEmptyArray_head(as))], i = 1;
  1630. i < as.length;
  1631. i++
  1632. )
  1633. out.push(f(i, as[i]))
  1634. return out
  1635. }
  1636. },
  1637. extract = head,
  1638. ReadonlyNonEmptyArray_Functor = {
  1639. URI: "ReadonlyNonEmptyArray",
  1640. map: ReadonlyNonEmptyArray_map,
  1641. },
  1642. ReadonlyNonEmptyArray_head =
  1643. (flap(ReadonlyNonEmptyArray_Functor), extract),
  1644. ReadonlyNonEmptyArray_tail = function (as) {
  1645. return as.slice(1)
  1646. }
  1647. var isEmpty = function (as) {
  1648. return 0 === as.length
  1649. },
  1650. ReadonlyArray_isNonEmpty = ReadonlyNonEmptyArray_isNonEmpty,
  1651. ReadonlyArray_append = append,
  1652. ReadonlyArray_makeBy = function (n, f) {
  1653. return n <= 0 ? ReadonlyArray_empty : makeBy(f)(n)
  1654. }
  1655. var ReadonlyArray_isOutOfBound = isOutOfBound
  1656. var findIndex = function (predicate) {
  1657. return function (as) {
  1658. for (var i = 0; i < as.length; i++)
  1659. if (predicate(as[i])) return some(i)
  1660. return none
  1661. }
  1662. }
  1663. var ReadonlyArray_reverse = function (as) {
  1664. return as.length <= 1 ? as : as.slice().reverse()
  1665. }
  1666. var ReadonlyArray_map = function (fa, f) {
  1667. return function_pipe(fa, es6_ReadonlyArray_map(f))
  1668. },
  1669. ReadonlyArray_reduce = function (fa, b, f) {
  1670. return function_pipe(fa, es6_ReadonlyArray_reduce(b, f))
  1671. },
  1672. ReadonlyArray_foldMap = function (M) {
  1673. var foldMapM = es6_ReadonlyArray_foldMap(M)
  1674. return function (fa, f) {
  1675. return function_pipe(fa, foldMapM(f))
  1676. }
  1677. },
  1678. ReadonlyArray_reduceRight = function (fa, b, f) {
  1679. return function_pipe(fa, es6_ReadonlyArray_reduceRight(b, f))
  1680. },
  1681. ReadonlyArray_traverse = function (F) {
  1682. var traverseF = es6_ReadonlyArray_traverse(F)
  1683. return function (ta, f) {
  1684. return function_pipe(ta, traverseF(f))
  1685. }
  1686. },
  1687. ReadonlyArray_zero = function () {
  1688. return ReadonlyArray_empty
  1689. },
  1690. es6_ReadonlyArray_chain = function (f) {
  1691. return function (ma) {
  1692. return function_pipe(
  1693. ma,
  1694. (function (f) {
  1695. return function (as) {
  1696. if (isEmpty(as)) return ReadonlyArray_empty
  1697. for (var out = [], i = 0; i < as.length; i++)
  1698. out.push.apply(out, f(i, as[i]))
  1699. return out
  1700. }
  1701. })(function (_, a) {
  1702. return f(a)
  1703. })
  1704. )
  1705. }
  1706. },
  1707. es6_ReadonlyArray_map = function (f) {
  1708. return function (fa) {
  1709. return fa.map(function (a) {
  1710. return f(a)
  1711. })
  1712. }
  1713. },
  1714. es6_ReadonlyArray_mapWithIndex = function (f) {
  1715. return function (fa) {
  1716. return fa.map(function (a, i) {
  1717. return f(i, a)
  1718. })
  1719. }
  1720. },
  1721. ReadonlyArray_separate = function (fa) {
  1722. for (
  1723. var left = [], right = [], _i = 0, fa_1 = fa;
  1724. _i < fa_1.length;
  1725. _i++
  1726. ) {
  1727. var e = fa_1[_i]
  1728. "Left" === e._tag ? left.push(e.left) : right.push(e.right)
  1729. }
  1730. return separated(left, right)
  1731. },
  1732. es6_ReadonlyArray_filter = function (predicate) {
  1733. return function (as) {
  1734. return as.filter(predicate)
  1735. }
  1736. },
  1737. filterMapWithIndex = function (f) {
  1738. return function (fa) {
  1739. for (var out = [], i = 0; i < fa.length; i++) {
  1740. var optionB = f(i, fa[i])
  1741. isSome(optionB) && out.push(optionB.value)
  1742. }
  1743. return out
  1744. }
  1745. },
  1746. es6_ReadonlyArray_filterMap = function (f) {
  1747. return filterMapWithIndex(function (_, a) {
  1748. return f(a)
  1749. })
  1750. },
  1751. ReadonlyArray_compact =
  1752. es6_ReadonlyArray_filterMap(function_identity),
  1753. es6_ReadonlyArray_foldMapWithIndex = function (M) {
  1754. return function (f) {
  1755. return function (fa) {
  1756. return fa.reduce(function (b, a, i) {
  1757. return M.concat(b, f(i, a))
  1758. }, M.empty)
  1759. }
  1760. }
  1761. },
  1762. es6_ReadonlyArray_reduce = function (b, f) {
  1763. return es6_ReadonlyArray_reduceWithIndex(b, function (_, b, a) {
  1764. return f(b, a)
  1765. })
  1766. },
  1767. es6_ReadonlyArray_foldMap = function (M) {
  1768. var foldMapWithIndexM = es6_ReadonlyArray_foldMapWithIndex(M)
  1769. return function (f) {
  1770. return foldMapWithIndexM(function (_, a) {
  1771. return f(a)
  1772. })
  1773. }
  1774. },
  1775. es6_ReadonlyArray_reduceWithIndex = function (b, f) {
  1776. return function (fa) {
  1777. for (var len = fa.length, out = b, i = 0; i < len; i++)
  1778. out = f(i, out, fa[i])
  1779. return out
  1780. }
  1781. },
  1782. es6_ReadonlyArray_reduceRight = function (b, f) {
  1783. return es6_ReadonlyArray_reduceRightWithIndex(
  1784. b,
  1785. function (_, a, b) {
  1786. return f(a, b)
  1787. }
  1788. )
  1789. },
  1790. es6_ReadonlyArray_reduceRightWithIndex = function (b, f) {
  1791. return function (fa) {
  1792. return fa.reduceRight(function (b, a, i) {
  1793. return f(i, a, b)
  1794. }, b)
  1795. }
  1796. },
  1797. es6_ReadonlyArray_traverse = function (F) {
  1798. var traverseWithIndexF = es6_ReadonlyArray_traverseWithIndex(F)
  1799. return function (f) {
  1800. return traverseWithIndexF(function (_, a) {
  1801. return f(a)
  1802. })
  1803. }
  1804. },
  1805. ReadonlyArray_sequence = function (F) {
  1806. return function (ta) {
  1807. return ReadonlyArray_reduce(
  1808. ta,
  1809. F.of(ReadonlyArray_zero()),
  1810. function (fas, fa) {
  1811. return F.ap(
  1812. F.map(fas, function (as) {
  1813. return function (a) {
  1814. return function_pipe(as, ReadonlyArray_append(a))
  1815. }
  1816. }),
  1817. fa
  1818. )
  1819. }
  1820. )
  1821. }
  1822. },
  1823. es6_ReadonlyArray_traverseWithIndex = function (F) {
  1824. return function (f) {
  1825. return es6_ReadonlyArray_reduceWithIndex(
  1826. F.of(ReadonlyArray_zero()),
  1827. function (i, fbs, a) {
  1828. return F.ap(
  1829. F.map(fbs, function (bs) {
  1830. return function (b) {
  1831. return function_pipe(bs, ReadonlyArray_append(b))
  1832. }
  1833. }),
  1834. f(i, a)
  1835. )
  1836. }
  1837. )
  1838. }
  1839. },
  1840. ReadonlyArray_Functor = {
  1841. URI: "ReadonlyArray",
  1842. map: ReadonlyArray_map,
  1843. },
  1844. ReadonlyArray_Compactable =
  1845. (flap(ReadonlyArray_Functor),
  1846. {
  1847. URI: "ReadonlyArray",
  1848. compact: ReadonlyArray_compact,
  1849. separate: ReadonlyArray_separate,
  1850. }),
  1851. ReadonlyArray_Traversable = {
  1852. URI: "ReadonlyArray",
  1853. map: ReadonlyArray_map,
  1854. reduce: ReadonlyArray_reduce,
  1855. foldMap: ReadonlyArray_foldMap,
  1856. reduceRight: ReadonlyArray_reduceRight,
  1857. traverse: ReadonlyArray_traverse,
  1858. sequence: ReadonlyArray_sequence,
  1859. },
  1860. toArray =
  1861. (witherDefault(
  1862. ReadonlyArray_Traversable,
  1863. ReadonlyArray_Compactable
  1864. ),
  1865. wiltDefault(ReadonlyArray_Traversable, ReadonlyArray_Compactable),
  1866. function (as) {
  1867. return as.slice()
  1868. }),
  1869. ReadonlyArray_empty = ReadonlyNonEmptyArray_empty,
  1870. ReadonlyArray_some = function (predicate) {
  1871. return function (as) {
  1872. return as.some(predicate)
  1873. }
  1874. },
  1875. ReadonlyArray_bindTo = bindTo(ReadonlyArray_Functor)
  1876. const external_rxjs_namespaceObject = rxjs,
  1877. package_namespaceObject_i8 = "1.15.6",
  1878. appendLog =
  1879. log =>
  1880. (a, ...b) =>
  1881. function_pipe(
  1882. [...log, `${a}${b.length > 0 ? ": " : ""}${b.join(", ")}`],
  1883. x => (x.length > 1e3 ? x.slice(0, 100) : x)
  1884. ),
  1885. external_jsep_namespaceObject = jsep
  1886. var external_jsep_default = __webpack_require__.n(
  1887. external_jsep_namespaceObject
  1888. ),
  1889. u = {
  1890. "||": function (r, e) {
  1891. return r || e
  1892. },
  1893. "&&": function (r, e) {
  1894. return r && e
  1895. },
  1896. "|": function (r, e) {
  1897. return r | e
  1898. },
  1899. "^": function (r, e) {
  1900. return r ^ e
  1901. },
  1902. "&": function (r, e) {
  1903. return r & e
  1904. },
  1905. "==": function (r, e) {
  1906. return r == e
  1907. },
  1908. "!=": function (r, e) {
  1909. return r != e
  1910. },
  1911. "===": function (r, e) {
  1912. return r === e
  1913. },
  1914. "!==": function (r, e) {
  1915. return r !== e
  1916. },
  1917. "<": function (r, e) {
  1918. return r < e
  1919. },
  1920. ">": function (r, e) {
  1921. return r > e
  1922. },
  1923. "<=": function (r, e) {
  1924. return r <= e
  1925. },
  1926. ">=": function (r, e) {
  1927. return r >= e
  1928. },
  1929. "<<": function (r, e) {
  1930. return r << e
  1931. },
  1932. ">>": function (r, e) {
  1933. return r >> e
  1934. },
  1935. ">>>": function (r, e) {
  1936. return r >>> e
  1937. },
  1938. "+": function (r, e) {
  1939. return r + e
  1940. },
  1941. "-": function (r, e) {
  1942. return r - e
  1943. },
  1944. "*": function (r, e) {
  1945. return r * e
  1946. },
  1947. "/": function (r, e) {
  1948. return r / e
  1949. },
  1950. "%": function (r, e) {
  1951. return r % e
  1952. },
  1953. },
  1954. i = {
  1955. "-": function (r) {
  1956. return -r
  1957. },
  1958. "+": function (r) {
  1959. return +r
  1960. },
  1961. "~": function (r) {
  1962. return ~r
  1963. },
  1964. "!": function (r) {
  1965. return !r
  1966. },
  1967. }
  1968. function s(r, e) {
  1969. return r.map(function (r) {
  1970. return a(r, e)
  1971. })
  1972. }
  1973. function c(r, e) {
  1974. var n,
  1975. t = a(r.object, e)
  1976. if (
  1977. ((n = r.computed ? a(r.property, e) : r.property.name),
  1978. /^__proto__|prototype|constructor$/.test(n))
  1979. )
  1980. throw Error('Access to member "' + n + '" disallowed.')
  1981. return [t, t[n]]
  1982. }
  1983. function a(r, e) {
  1984. var n = r
  1985. switch (n.type) {
  1986. case "ArrayExpression":
  1987. return s(n.elements, e)
  1988. case "BinaryExpression":
  1989. return u[n.operator](a(n.left, e), a(n.right, e))
  1990. case "CallExpression":
  1991. var t, o, l
  1992. if (
  1993. ("MemberExpression" === n.callee.type
  1994. ? ((t = (l = c(n.callee, e))[0]), (o = l[1]))
  1995. : (o = a(n.callee, e)),
  1996. "function" != typeof o)
  1997. )
  1998. return
  1999. return o.apply(t, s(n.arguments, e))
  2000. case "ConditionalExpression":
  2001. return a(n.test, e) ? a(n.consequent, e) : a(n.alternate, e)
  2002. case "Identifier":
  2003. return e[n.name]
  2004. case "Literal":
  2005. return n.value
  2006. case "LogicalExpression":
  2007. return "||" === n.operator
  2008. ? a(n.left, e) || a(n.right, e)
  2009. : "&&" === n.operator
  2010. ? a(n.left, e) && a(n.right, e)
  2011. : u[n.operator](a(n.left, e), a(n.right, e))
  2012. case "MemberExpression":
  2013. return c(n, e)[1]
  2014. case "ThisExpression":
  2015. return e
  2016. case "UnaryExpression":
  2017. return i[n.operator](a(n.argument, e))
  2018. default:
  2019. return
  2020. }
  2021. }
  2022. const fycKey = key => `FYC_${key}`,
  2023. stringsArgs = [
  2024. [],
  2025. x => x.split(/\r\n|\n/).filter(s => "" !== s),
  2026. x => x.join("\n"),
  2027. ],
  2028. sc = (k, d) =>
  2029. (async (key, defaultVal) => ({
  2030. gmKey: key,
  2031. val: (await GM.getValue(key)) ?? defaultVal,
  2032. defaultVal,
  2033. toGm: x => x,
  2034. }))(fycKey(k), d),
  2035. ic = (k, d, i, g) =>
  2036. (async (key, defaultVal, toItem, toGm) => {
  2037. const val = await GM.getValue(key)
  2038. return {
  2039. gmKey: key,
  2040. val: void 0 !== val ? toItem(val) : defaultVal,
  2041. defaultVal,
  2042. toGm,
  2043. }
  2044. })(fycKey(k), d, i, g),
  2045. chatApp = () =>
  2046. function_pipe(
  2047. fromNullable(document.querySelector("#chatframe")),
  2048. filter(x => {
  2049. const state = x.contentDocument?.readyState
  2050. return "loading" === state || "complete" === state
  2051. }),
  2052. chainNullableK(x => x.contentDocument),
  2053. alt(() => Option_some(document)),
  2054. chainNullableK(x => x.querySelector("yt-live-chat-app"))
  2055. ),
  2056. observePair = con => {
  2057. const subject = new external_rxjs_namespaceObject.Subject()
  2058. return { subject, observer: new con(lib(subject)) }
  2059. }
  2060. var Eq = {
  2061. equals: function (first, second) {
  2062. return first === second
  2063. },
  2064. }
  2065. const external_Swal_namespaceObject = Swal
  2066. var external_Swal_default = __webpack_require__.n(
  2067. external_Swal_namespaceObject
  2068. )
  2069. const addBanButton_button = document.createElement("button")
  2070. addBanButton_button.classList.add(
  2071. "style-scope",
  2072. "yt-icon-button",
  2073. "fyc_button"
  2074. )
  2075. Object.assign(addBanButton_button.style, {
  2076. padding: "0px",
  2077. width: "20px",
  2078. height: "20px",
  2079. fill: "#fff",
  2080. })
  2081. addBanButton_button.setAttribute(
  2082. "aria-label",
  2083. "NGに入れる(Ban this user)"
  2084. )
  2085. addBanButton_button.innerHTML =
  2086. '<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>'
  2087. const addBanButton = (chat, id, getConfig, setConfig) =>
  2088. chat.children.namedItem("card")
  2089. ? () => {}
  2090. : () => {
  2091. const clone = addBanButton_button.cloneNode(!0)
  2092. clone.onclick = function_pipe(
  2093. getConfig.bannedUsers,
  2094. IOOption_fromIO,
  2095. IOOption_filter(x => !x.includes(id)),
  2096. IOOption_map(
  2097. function_flow(
  2098. (function (E) {
  2099. var f = uniq(E)
  2100. return function (as) {
  2101. return ReadonlyArray_isNonEmpty(as) ? f(as) : as
  2102. }
  2103. })(Eq),
  2104. ReadonlyArray_append(id),
  2105. toArray
  2106. )
  2107. ),
  2108. IOOption_chain(x =>
  2109. IOOption_fromIO(() => {
  2110. setConfig.bannedUsers(x)
  2111. external_Swal_default()
  2112. .mixin({
  2113. toast: !0,
  2114. position: "bottom-left",
  2115. timer: 2500,
  2116. timerProgressBar: !0,
  2117. showConfirmButton: !1,
  2118. didOpen: toast => {
  2119. toast.addEventListener(
  2120. "pointerenter",
  2121. external_Swal_default().stopTimer
  2122. )
  2123. toast.addEventListener(
  2124. "pointerleave",
  2125. external_Swal_default().resumeTimer
  2126. )
  2127. },
  2128. })
  2129. .fire({
  2130. title: `Added Banned User: ${id}`,
  2131. icon: "success",
  2132. })
  2133. })
  2134. ),
  2135. IO_apSecond(() => {
  2136. chat.style.display = "none"
  2137. })
  2138. )
  2139. chat.querySelector("#content #message")?.append(clone)
  2140. },
  2141. getChatFontSize = mainState =>
  2142. Math.round(
  2143. ((Math.max(mainState.getConfig.fontSize() - 0.2, 0.01) *
  2144. mainState.playerRect.height) /
  2145. mainState.getConfig.laneCount()) *
  2146. (mainState.getConfig.flowY2() - mainState.getConfig.flowY1()) *
  2147. 100
  2148. ) / 100
  2149. var equalsDefault = function (compare) {
  2150. return function (first, second) {
  2151. return first === second || 0 === compare(first, second)
  2152. }
  2153. },
  2154. Ord_fromCompare = function (compare) {
  2155. return {
  2156. equals: equalsDefault(compare),
  2157. compare: function (first, second) {
  2158. return first === second ? 0 : compare(first, second)
  2159. },
  2160. }
  2161. },
  2162. Ord_contramap = function (f) {
  2163. return function (fa) {
  2164. return Ord_fromCompare(function (first, second) {
  2165. return fa.compare(f(first), f(second))
  2166. })
  2167. }
  2168. }
  2169. constant(0)
  2170. var number_Eq = {
  2171. equals: function (first, second) {
  2172. return first === second
  2173. },
  2174. },
  2175. number_Ord = {
  2176. equals: number_Eq.equals,
  2177. compare: function (first, second) {
  2178. return first < second ? -1 : first > second ? 1 : 0
  2179. },
  2180. }
  2181. const external_window_micro_memoize_namespaceObject =
  2182. window["micro-memoize"]
  2183. var external_window_micro_memoize_default = __webpack_require__.n(
  2184. external_window_micro_memoize_namespaceObject
  2185. )
  2186. const getFlowChatProgress = chat =>
  2187. function_pipe(
  2188. chat.animation,
  2189. chainNullableK(x => x.currentTime),
  2190. getOrElse(() => 0)
  2191. ) / chat.animationDuration,
  2192. getFlowChatRect = (chat, mainState) => {
  2193. const x =
  2194. mainState.playerRect.width -
  2195. (chat.width + mainState.playerRect.width) *
  2196. getFlowChatProgress(chat)
  2197. return new DOMRect(x, chat.y, chat.width, chat.height)
  2198. },
  2199. getChatLane = (flowChat, progress, flowChats) => mainState => {
  2200. const playerWidth = mainState.playerRect.width,
  2201. chatRect = getFlowChatRect(flowChat, mainState),
  2202. chatWidth = chatRect.width,
  2203. chatHeight = chatRect.height,
  2204. chatX = chatRect.x,
  2205. chatIndex = flowChats.indexOf(flowChat),
  2206. movingChats = function_pipe(
  2207. flowChats,
  2208. (function (n) {
  2209. return function (as) {
  2210. return ReadonlyArray_isOutOfBound(n, as)
  2211. ? as
  2212. : 0 === n
  2213. ? ReadonlyArray_empty
  2214. : as.slice(0, n)
  2215. }
  2216. })(chatIndex >= 0 ? chatIndex : -1),
  2217. es6_ReadonlyArray_filter(
  2218. chat => !chat.animationEnded && chat.width > 0
  2219. ),
  2220. (function (O) {
  2221. return function (as) {
  2222. return as.length <= 1 ? as : as.slice().sort(O.compare)
  2223. }
  2224. })(Ord_contramap(x => x.lane)(number_Ord))
  2225. ),
  2226. tooCloseTo = external_window_micro_memoize_default()(
  2227. i => {
  2228. const otherRect = getFlowChatRect(movingChats[i], mainState),
  2229. otherWidth = otherRect.width,
  2230. otherX = otherRect.x,
  2231. gap =
  2232. (chatHeight * otherWidth * chatWidth) ** 0.333 *
  2233. mainState.getConfig.minSpacing()
  2234. return (
  2235. (playerWidth - otherX) / (playerWidth + otherWidth) -
  2236. progress <
  2237. (chatWidth + gap) / (playerWidth + chatWidth) ||
  2238. otherX + otherWidth + gap > chatX
  2239. )
  2240. },
  2241. { maxSize: 1e3 }
  2242. ),
  2243. occupyInfo = [
  2244. ...movingChats.map((x, i) => ({
  2245. tooClose: () => tooCloseTo(i),
  2246. lane: x.lane,
  2247. })),
  2248. { tooClose: () => !0, lane: mainState.getConfig.laneCount() },
  2249. ],
  2250. index = occupyInfo.findIndex(x => x.lane >= flowChat.lane),
  2251. rightFreeLane = function_pipe(
  2252. occupyInfo.slice(index),
  2253. ((predicate = x => x.tooClose()),
  2254. function (as) {
  2255. for (var i = 0; i < as.length; i++)
  2256. if (predicate(as[i])) return some(as[i])
  2257. return none
  2258. }),
  2259. es6_Option_map(x => x.lane),
  2260. getOrElse(() => mainState.getConfig.laneCount())
  2261. )
  2262. var predicate
  2263. const leftFreeLane = function_pipe(
  2264. occupyInfo.slice(0, index),
  2265. (function (predicate) {
  2266. return function (as) {
  2267. for (var i = as.length - 1; i >= 0; i--)
  2268. if (predicate(as[i])) return some(as[i])
  2269. return none
  2270. }
  2271. })(x => x.tooClose()),
  2272. es6_Option_map(x => x.lane),
  2273. getOrElse(() => -1)
  2274. ),
  2275. formerLaneInterval = Math.min(
  2276. flowChat.lane - leftFreeLane,
  2277. rightFreeLane - flowChat.lane,
  2278. 1
  2279. )
  2280. return function_pipe(
  2281. occupyInfo,
  2282. es6_ReadonlyArray_reduce(
  2283. { maxInterval: 0, maxIntervalLane: 0, lastLane: -1 },
  2284. ({ maxInterval, maxIntervalLane, lastLane }, info) =>
  2285. maxInterval > 0.999 || !info.tooClose()
  2286. ? { maxInterval, maxIntervalLane, lastLane }
  2287. : (() => {
  2288. const nextLane = info.lane,
  2289. interLane = Math.min(
  2290. Math.max((lastLane + nextLane) / 2, 0),
  2291. mainState.getConfig.laneCount() - 1
  2292. ),
  2293. newInterval = Math.min(
  2294. interLane - lastLane,
  2295. nextLane - interLane,
  2296. 1
  2297. )
  2298. return newInterval - maxInterval > 0.001
  2299. ? {
  2300. maxInterval: newInterval,
  2301. maxIntervalLane: Math.max(
  2302. lastLane + newInterval,
  2303. 0
  2304. ),
  2305. lastLane: nextLane,
  2306. }
  2307. : { maxInterval, maxIntervalLane, lastLane: nextLane }
  2308. })()
  2309. ),
  2310. x => ({
  2311. lane:
  2312. Math.abs(formerLaneInterval - x.maxInterval) < 0.001
  2313. ? flowChat.lane
  2314. : x.maxIntervalLane,
  2315. interval: x.maxInterval,
  2316. })
  2317. )
  2318. },
  2319. intervalTooSmall = interval => getConfig =>
  2320. getConfig.noOverlap() && interval < 0.999,
  2321. external_m_namespaceObject = m
  2322. var external_m_default = __webpack_require__.n(
  2323. external_m_namespaceObject
  2324. )
  2325. const textStyle = { fontFamily: "inherit" },
  2326. chatNode = (chat, mainState) => {
  2327. const { getConfig } = mainState,
  2328. data = chat.getData(getConfig)
  2329. return external_m_default()(
  2330. "span",
  2331. {
  2332. style: {
  2333. fontSize: `${getChatFontSize(mainState)}px`,
  2334. visibility: getConfig.displayChats() ? "visible" : "hidden",
  2335. color:
  2336. "owner" === data.authorType
  2337. ? getConfig.ownerColor()
  2338. : "moderator" === data.authorType
  2339. ? getConfig.moderatorColor()
  2340. : "member" === data.authorType
  2341. ? getConfig.memberColor()
  2342. : getConfig.color(),
  2343. fontWeight: getConfig.fontWeight().toString(),
  2344. fontFamily: getConfig.font(),
  2345. opacity: getConfig.chatOpacity().toString(),
  2346. ...function_pipe(
  2347. getConfig.shadowFontWeight(),
  2348. x => `${x}px`,
  2349. x => ({
  2350. textShadow: `-${x} -${x} #0009, ${x} -${x} #0009, -${x} ${x} #0009, ${x} ${x} #0009`,
  2351. })
  2352. ),
  2353. },
  2354. },
  2355. function_pipe(
  2356. [
  2357. function_pipe(
  2358. data.authorName,
  2359. filter(x => x.visible),
  2360. es6_Option_map(x =>
  2361. external_m_default()(
  2362. "span",
  2363. {
  2364. style: {
  2365. color: toUndefined(data.textColor),
  2366. fontSize: "0.84em",
  2367. ...textStyle,
  2368. },
  2369. },
  2370. `${x.content}: `
  2371. )
  2372. )
  2373. ),
  2374. function_pipe(
  2375. data.messageElement,
  2376. es6_Option_map(x =>
  2377. ((message, getConfig) => {
  2378. const eleWin =
  2379. message.ownerDocument.defaultView ?? window,
  2380. maxChatLength = getConfig.maxChatLength()
  2381. return function_pipe(
  2382. Array.from(message.childNodes),
  2383. es6_ReadonlyArray_reduce(
  2384. { vnodes: [], length: 0 },
  2385. ({ vnodes, length }, node) => {
  2386. return length >= maxChatLength
  2387. ? { vnodes, length }
  2388. : !getConfig.textOnly() &&
  2389. node instanceof eleWin.HTMLImageElement
  2390. ? {
  2391. vnodes: [
  2392. ...vnodes,
  2393. external_m_default()("img", {
  2394. style: {
  2395. height: "1em",
  2396. width: "1em",
  2397. verticalAlign: "text-top",
  2398. },
  2399. src: node.src,
  2400. alt: node.alt,
  2401. }),
  2402. ],
  2403. length: length + 1,
  2404. }
  2405. : function_pipe(
  2406. node.textContent ?? "",
  2407. ((start = 0),
  2408. (end = maxChatLength),
  2409. function (s) {
  2410. return s.slice(start, end)
  2411. }),
  2412. x =>
  2413. node instanceof eleWin.HTMLAnchorElement
  2414. ? {
  2415. vnodes: [
  2416. ...vnodes,
  2417. external_m_default()(
  2418. "span",
  2419. {
  2420. style: {
  2421. fontSize: "0.84em",
  2422. textDecoration: "underline",
  2423. ...textStyle,
  2424. },
  2425. },
  2426. x
  2427. ),
  2428. ],
  2429. length: length + x.length,
  2430. }
  2431. : {
  2432. vnodes: [
  2433. ...vnodes,
  2434. external_m_default().fragment(
  2435. {},
  2436. x
  2437. ),
  2438. ],
  2439. length: length + x.length,
  2440. }
  2441. )
  2442. var start, end
  2443. }
  2444. )
  2445. )
  2446. })(x, getConfig)
  2447. ),
  2448. es6_Option_map(x =>
  2449. external_m_default()(
  2450. "span",
  2451. {
  2452. style: {
  2453. color: toUndefined(data.textColor),
  2454. ...textStyle,
  2455. },
  2456. },
  2457. x.vnodes
  2458. )
  2459. )
  2460. ),
  2461. function_pipe(
  2462. data.paymentInfo,
  2463. filter(x => x.visible),
  2464. es6_Option_map(x =>
  2465. external_m_default()(
  2466. "span",
  2467. {
  2468. style: {
  2469. color: toUndefined(data.paidColor),
  2470. fontSize: "0.84em",
  2471. ...textStyle,
  2472. },
  2473. },
  2474. external_m_default()(
  2475. "strong",
  2476. { style: textStyle },
  2477. x.content
  2478. )
  2479. )
  2480. )
  2481. ),
  2482. ],
  2483. ReadonlyArray_compact,
  2484. toArray
  2485. )
  2486. )
  2487. },
  2488. renderChat = chat => mainState => () =>
  2489. external_m_default().render(
  2490. chat.element,
  2491. chatNode(chat, mainState)
  2492. ),
  2493. external_window_hash_it_namespaceObject = window["hash-it"]
  2494. var external_window_hash_it_default = __webpack_require__.n(
  2495. external_window_hash_it_namespaceObject
  2496. )
  2497. const getLaneY = (lane, mainState) =>
  2498. mainState.playerRect.height *
  2499. ((lane / mainState.getConfig.laneCount() + 0.005) *
  2500. (mainState.getConfig.flowY2() - mainState.getConfig.flowY1()) +
  2501. mainState.getConfig.flowY1()),
  2502. setChatPlayState = chat => mainState =>
  2503. function_pipe(
  2504. chat,
  2505. fromPredicate(x => !x.animationEnded),
  2506. x => x,
  2507. fromOption,
  2508. IOOption_chainOptionK(x => x.animation),
  2509. IOOption_chainFirst(x =>
  2510. IOOption_fromIO(
  2511. mainState.chatPlaying ? () => x.play() : () => x.pause()
  2512. )
  2513. ),
  2514. IOOption_chain(x =>
  2515. IOOption_fromIO(() => {
  2516. x.playbackRate = mainState.getConfig.flowSpeed() / 15
  2517. })
  2518. )
  2519. ),
  2520. getWidth = external_window_micro_memoize_default()(
  2521. ele => ele?.getBoundingClientRect().width ?? 0,
  2522. {
  2523. maxSize: 2e3,
  2524. transformKey: args => args.map(external_window_hash_it_default()),
  2525. }
  2526. ),
  2527. setChatAnimation = (chat, chats) => mainState =>
  2528. function_pipe(
  2529. { fontSize: getChatFontSize(mainState) },
  2530. IO_of,
  2531. IO_chainFirst(x => () => {
  2532. chat.element.style.transform = `translate(${
  2533. mainState.playerRect.width
  2534. }px, -${2 * x.fontSize}px)`
  2535. }),
  2536. IOOption_fromIO,
  2537. IOOption_filter(() => !chat.animationEnded),
  2538. IOOption_chainFirst(x =>
  2539. IOOption_fromIO(() => {
  2540. chat.animationDuration = 6400
  2541. chat.width = getWidth(chat.element.firstElementChild)
  2542. chat.height = x.fontSize
  2543. })
  2544. ),
  2545. IOOption_map(() => ({ progress: getFlowChatProgress(chat) })),
  2546. IOOption_map(x => ({
  2547. ...x,
  2548. ...getChatLane(chat, x.progress, chats)(mainState),
  2549. })),
  2550. IOOption_chain(ctx =>
  2551. intervalTooSmall(ctx.interval)(mainState.getConfig)
  2552. ? function_pipe(
  2553. chat.animation,
  2554. fromOption,
  2555. IOOption_chain(x =>
  2556. IOOption_fromIO(() => {
  2557. x.finish()
  2558. chat.animation = Option_none
  2559. })
  2560. ),
  2561. es6_IO_map(() => Option_none)
  2562. )
  2563. : IOOption_some(ctx)
  2564. ),
  2565. IOOption_chainFirst(x =>
  2566. IOOption_fromIO(() => {
  2567. chat.lane = x.lane
  2568. })
  2569. ),
  2570. IOOption_map(x => ({
  2571. ...x,
  2572. laneY: getLaneY(chat.lane, mainState),
  2573. })),
  2574. IOOption_chain(ctx =>
  2575. function_pipe(
  2576. [
  2577. function_pipe(
  2578. chat.animation,
  2579. fromOption,
  2580. IOOption_chain(x => IOOption_fromIO(() => x.cancel()))
  2581. ),
  2582. function_pipe(
  2583. [
  2584. [mainState.playerRect.width, ctx.laneY],
  2585. [-chat.width, ctx.laneY],
  2586. ],
  2587. es6_ReadonlyArray_map(
  2588. es6_ReadonlyArray_map(x => `${x}px`)
  2589. ),
  2590. es6_ReadonlyArray_map(
  2591. ([x, y]) => `translate(${x}, ${y})`
  2592. ),
  2593. ReadonlyArray_bindTo("transform"),
  2594. toArray,
  2595. x =>
  2596. chat.element.animate(x, {
  2597. duration: 6400,
  2598. easing: mainState.getConfig.timingFunction(),
  2599. }),
  2600. x => {
  2601. x.onfinish = () => {
  2602. chat.animationEnded = !0
  2603. }
  2604. chat.y = ctx.laneY
  2605. const newTime = 6400 * ctx.progress
  2606. x.currentTime = newTime
  2607. return x
  2608. },
  2609. Option_some,
  2610. x => () => {
  2611. chat.animation = x
  2612. },
  2613. IO_apSecond(setChatPlayState(chat)(mainState))
  2614. ),
  2615. ],
  2616. IO_sequenceArray,
  2617. IOOption_fromIO
  2618. )
  2619. ),
  2620. es6_IO_map(Option_isSome)
  2621. ),
  2622. emptyElement = document.createElement("span")
  2623. var Semigroup_concatAll = function (M) {
  2624. return function (startWith) {
  2625. return function (as) {
  2626. return as.reduce(function (a, acc) {
  2627. return M.concat(a, acc)
  2628. }, startWith)
  2629. }
  2630. }
  2631. },
  2632. semigroupVoid = (function (a) {
  2633. return {
  2634. concat: function () {
  2635. return a
  2636. },
  2637. }
  2638. })(void 0)
  2639. var Monoid_concatAll = function (M) {
  2640. return Semigroup_concatAll(M)(M.empty)
  2641. },
  2642. MonoidAll =
  2643. (semigroupVoid.concat,
  2644. {
  2645. concat: function (first, second) {
  2646. return first && second
  2647. },
  2648. empty: !0,
  2649. }),
  2650. MonoidAny = {
  2651. concat: function (first, second) {
  2652. return first || second
  2653. },
  2654. empty: !1,
  2655. }
  2656. const operators = {
  2657. flip: x => b => a => x(a)(b),
  2658. flow: fns => function_flow(...fns),
  2659. and: Monoid_concatAll(MonoidAll),
  2660. or: Monoid_concatAll(MonoidAny),
  2661. RA: { some: ReadonlyArray_some, compact: ReadonlyArray_compact },
  2662. O: {
  2663. exists: function (predicate) {
  2664. return function (ma) {
  2665. return !Option_isNone(ma) && predicate(ma.value)
  2666. }
  2667. },
  2668. },
  2669. allPreds: Monoid_concatAll(function_getMonoid(MonoidAll)()),
  2670. anyPreds: Monoid_concatAll(function_getMonoid(MonoidAny)()),
  2671. inText: text => x => text.content.includes(x),
  2672. eqText: text => x => text.content === x,
  2673. matchedByText: text => x =>
  2674. Boolean(text.content.match(RegExp(x, "u"))),
  2675. isVisible: x => x.visible,
  2676. },
  2677. checkBannedWords = (data, mainState, mainLog) =>
  2678. function_pipe(
  2679. data,
  2680. fromPredicate(() =>
  2681. function_pipe(
  2682. mainState.filterExp,
  2683. es6_Option_map(x =>
  2684. a(
  2685. x,
  2686. (data => ({
  2687. ...operators,
  2688. authorName: data.authorName,
  2689. message: data.message,
  2690. messageText: data.messageText,
  2691. paymentInfo: data.paymentInfo,
  2692. authorID: function_pipe(
  2693. data.authorID,
  2694. es6_Option_map(x => ({ visible: !1, content: x }))
  2695. ),
  2696. }))(data)
  2697. )
  2698. ),
  2699. getOrElse(() => !1)
  2700. )
  2701. ),
  2702. es6_Option_map(x => [
  2703. function_pipe(
  2704. x.message,
  2705. es6_Option_map(m => m.content)
  2706. ),
  2707. function_pipe(
  2708. x.paymentInfo,
  2709. es6_Option_map(p => p.content)
  2710. ),
  2711. ]),
  2712. es6_Option_map(es6_ReadonlyArray_map(getOrElse(() => ""))),
  2713. match(
  2714. () => () => !1,
  2715. x => () => {
  2716. mainLog(`Banned: ${JSON.stringify(x)}`)
  2717. return !0
  2718. }
  2719. )
  2720. )(),
  2721. assert_lib = check.assert,
  2722. tapNonNull = x => {
  2723. assert_lib(null != x)
  2724. return x
  2725. },
  2726. onChatFieldMutate = (
  2727. chatScrn,
  2728. flowChats,
  2729. mainState,
  2730. setConfig,
  2731. mainLog
  2732. ) =>
  2733. function_flow(
  2734. es6_ReadonlyArray_chain(e => Array.from(e.addedNodes)),
  2735. es6_ReadonlyArray_filter(x => x.children.length > 0),
  2736. ReadonlyArray_reverse,
  2737. es6_ReadonlyArray_map(chat => () => {
  2738. const getData = (chat => {
  2739. const chatType = chat.querySelector(
  2740. ".yt-live-chat-ticker-paid-message-item-renderer"
  2741. )
  2742. ? "ticker"
  2743. : chat.querySelector(
  2744. ".yt-live-chat-membership-item-renderer"
  2745. )
  2746. ? "membership"
  2747. : chat.querySelector(
  2748. ".yt-live-chat-viewer-engagement-message-renderer"
  2749. )
  2750. ? "engagement"
  2751. : "normal",
  2752. isPaid =
  2753. "ticker" === chatType ||
  2754. Boolean(chat.querySelector("#card")),
  2755. paymentInfo = function_pipe(
  2756. fromNullable(
  2757. isPaid
  2758. ? chat.querySelector(
  2759. [
  2760. "#purchase-amount",
  2761. "#purchase-amount-chip",
  2762. "#content>#text",
  2763. ].join(",")
  2764. )?.textContent
  2765. : void 0
  2766. ),
  2767. es6_Option_map(x => ({ visible: !0, content: x }))
  2768. ),
  2769. authorType = chat.querySelector(".owner")
  2770. ? "owner"
  2771. : chat.querySelector(".moderator")
  2772. ? "moderator"
  2773. : chat.querySelector(".member")
  2774. ? "member"
  2775. : "normal",
  2776. messageElement = fromNullable(
  2777. chat.querySelector("#message")
  2778. ),
  2779. isPaidNormal =
  2780. !!Option_isSome(paymentInfo) &&
  2781. Boolean(
  2782. chat.querySelector(
  2783. ".yt-live-chat-paid-message-renderer"
  2784. )
  2785. ),
  2786. isPaidSticker =
  2787. !(!Option_isSome(paymentInfo) || isPaidNormal) &&
  2788. Boolean(
  2789. chat.querySelector(
  2790. ".yt-live-chat-paid-sticker-renderer"
  2791. )
  2792. ),
  2793. textColor = fromNullable(
  2794. isPaidNormal
  2795. ? window
  2796. .getComputedStyle(
  2797. tapNonNull(chat.querySelector("#header"))
  2798. )
  2799. .getPropertyValue("background-color")
  2800. : isPaidSticker
  2801. ? window
  2802. .getComputedStyle(chat)
  2803. .getPropertyValue(
  2804. "--yt-live-chat-paid-sticker-chip-background-color"
  2805. )
  2806. : void 0
  2807. ),
  2808. paidColor = fromNullable(
  2809. isPaidNormal
  2810. ? window
  2811. .getComputedStyle(
  2812. tapNonNull(chat.querySelector("#content"))
  2813. )
  2814. .getPropertyValue("background-color")
  2815. : isPaidSticker
  2816. ? window
  2817. .getComputedStyle(chat)
  2818. .getPropertyValue(
  2819. "--yt-live-chat-paid-sticker-background-color"
  2820. )
  2821. : void 0
  2822. ),
  2823. authorPhotoMatches = chat
  2824. .querySelector(["#author-photo", "img"].join(" "))
  2825. ?.src.match(/ytc\/(.*)=/),
  2826. authorID = fromNullable(
  2827. authorPhotoMatches?.[authorPhotoMatches.length - 1]
  2828. ),
  2829. authorName = fromNullable(
  2830. chat.querySelector("#author-name")?.textContent
  2831. ),
  2832. message = function_pipe(
  2833. messageElement,
  2834. es6_Option_map(x => ({
  2835. visible: !0,
  2836. content: x.innerHTML,
  2837. }))
  2838. ),
  2839. messageText = function_pipe(
  2840. messageElement,
  2841. es6_Option_map(x => ({
  2842. visible: !0,
  2843. content: x.textContent ?? "",
  2844. }))
  2845. )
  2846. return getConfig => ({
  2847. chatType,
  2848. authorType,
  2849. authorID,
  2850. authorName: function_pipe(
  2851. authorName,
  2852. es6_Option_map(x => ({
  2853. visible:
  2854. ("moderator" === authorType &&
  2855. getConfig.displayModName()) ||
  2856. (Option_isSome(paymentInfo) &&
  2857. getConfig.displaySuperChatAuthor()),
  2858. content: x,
  2859. }))
  2860. ),
  2861. messageElement,
  2862. message,
  2863. messageText,
  2864. paymentInfo,
  2865. textColor,
  2866. paidColor,
  2867. })
  2868. })(chat),
  2869. { getConfig } = mainState,
  2870. data = getData(getConfig)
  2871. ;(checkBannedWords(data, mainState, mainLog)
  2872. ? () => {
  2873. chat.style.display = "none"
  2874. }
  2875. : function_pipe(
  2876. [
  2877. function_pipe(
  2878. void 0,
  2879. fromPredicate(getConfig.createChats),
  2880. filter(() => "normal" === data.chatType),
  2881. fromOption,
  2882. IOOption_chain(() =>
  2883. IOOption_fromIO(
  2884. ((getData, flowChats, chatScrn, mainState) =>
  2885. function_pipe(
  2886. {
  2887. getData,
  2888. element: emptyElement,
  2889. lane: -1,
  2890. animation: Option_none,
  2891. animationDuration: 0,
  2892. animationEnded: !1,
  2893. width: 2,
  2894. height: getChatFontSize(mainState),
  2895. y: 0,
  2896. },
  2897. x =>
  2898. getChatLane(x, 0, flowChats)(mainState)
  2899. .interval,
  2900. intervalTooSmall,
  2901. x => x(mainState.getConfig)
  2902. )
  2903. ? () => {}
  2904. : () => {
  2905. const offScreenIndex = function_pipe(
  2906. flowChats,
  2907. findIndex(
  2908. chat =>
  2909. chat.animationEnded ||
  2910. flowChats.length >=
  2911. mainState.getConfig.maxChatCount()
  2912. )
  2913. ),
  2914. element = function_pipe(
  2915. offScreenIndex,
  2916. es6_Option_map(
  2917. x => flowChats[x].element
  2918. ),
  2919. getOrElseW(() =>
  2920. document.createElement("span")
  2921. )
  2922. )
  2923. function_pipe(
  2924. offScreenIndex,
  2925. match(
  2926. () => () => {
  2927. external_log_default().debug(
  2928. "CreateFlowChat"
  2929. )
  2930. chatScrn.append(element)
  2931. },
  2932. i =>
  2933. function_pipe(
  2934. () =>
  2935. flowChats.splice(i, 1)[0]
  2936. .animation,
  2937. IOOption_chain(oldAnimation =>
  2938. IOOption_fromIO(() =>
  2939. oldAnimation.cancel()
  2940. )
  2941. )
  2942. )
  2943. )
  2944. )()
  2945. const flowChat = {
  2946. getData,
  2947. element,
  2948. lane: -1,
  2949. animation: Option_none,
  2950. animationDuration: 0,
  2951. animationEnded: !1,
  2952. width: 2,
  2953. height: getChatFontSize(mainState),
  2954. y: 0,
  2955. }
  2956. element.classList.add("fyc_chat")
  2957. function_pipe(
  2958. mainState,
  2959. IO_of,
  2960. IO_chainFirst(renderChat(flowChat)),
  2961. es6_IO_chain(
  2962. setChatAnimation(flowChat, flowChats)
  2963. ),
  2964. es6_IO_chain(x =>
  2965. x
  2966. ? () => flowChats.push(flowChat)
  2967. : () => flowChat.element.remove()
  2968. )
  2969. )()
  2970. })(getData, flowChats, chatScrn, mainState)
  2971. )
  2972. )
  2973. ),
  2974. function_pipe(
  2975. data.authorID,
  2976. fromOption,
  2977. IOOption_filter(getConfig.createBanButton),
  2978. IOOption_chain(x =>
  2979. IOOption_fromIO(
  2980. addBanButton(chat, x, getConfig, setConfig)
  2981. )
  2982. ),
  2983. es6_IO_map(() => Option_some(void 0)),
  2984. IOOption_filter(getConfig.simplifyChatField),
  2985. IOOption_chain(() =>
  2986. IOOption_fromIO(
  2987. (chat =>
  2988. chat.querySelector(
  2989. ".style-scope.yt-live-chat-paid-message-renderer"
  2990. )
  2991. ? () => {}
  2992. : function_pipe(
  2993. [
  2994. "#author-photo",
  2995. "yt-live-chat-author-chip.style-scope.yt-live-chat-text-message-renderer",
  2996. ],
  2997. es6_ReadonlyArray_map(x =>
  2998. fromNullable(chat.querySelector(x))
  2999. ),
  3000. ReadonlyArray_compact,
  3001. es6_ReadonlyArray_map(x => () => {
  3002. x.style.display = "none"
  3003. }),
  3004. ReadonlyArray_append(() => {
  3005. chat.style.borderBottom =
  3006. "1px solid var(--yt-spec-text-secondary)"
  3007. }),
  3008. IO_sequenceArray
  3009. ))(chat)
  3010. )
  3011. )
  3012. ),
  3013. ],
  3014. IO_sequenceArray
  3015. ))()
  3016. }),
  3017. IO_sequenceArray
  3018. ),
  3019. removeOldChats = (flowChats, maxChatCount) => {
  3020. flowChats.sort((a, b) =>
  3021. a.animationEnded === b.animationEnded
  3022. ? 0
  3023. : a.animationEnded
  3024. ? -1
  3025. : 1
  3026. )
  3027. flowChats
  3028. .splice(0, Math.max(0, flowChats.length - maxChatCount))
  3029. .forEach(x => {
  3030. external_log_default().debug("RemoveChat")
  3031. x.element.remove()
  3032. })
  3033. }
  3034. var EMPTY_OBJ = {},
  3035. EMPTY_ARR = [],
  3036. id = a => a,
  3037. hyperapp_map = EMPTY_ARR.map,
  3038. isArray = Array.isArray,
  3039. enqueue =
  3040. "undefined" != typeof requestAnimationFrame
  3041. ? requestAnimationFrame
  3042. : setTimeout,
  3043. createClass = obj => {
  3044. var out = ""
  3045. if ("string" == typeof obj) return obj
  3046. if (isArray(obj))
  3047. for (var tmp, k = 0; k < obj.length; k++)
  3048. (tmp = createClass(obj[k])) && (out += (out && " ") + tmp)
  3049. else for (var k in obj) obj[k] && (out += (out && " ") + k)
  3050. return out
  3051. },
  3052. shouldRestart = (a, b) => {
  3053. for (var k in { ...a, ...b })
  3054. if ("function" == typeof (isArray(a[k]) ? a[k][0] : a[k]))
  3055. b[k] = a[k]
  3056. else if (a[k] !== b[k]) return !0
  3057. },
  3058. getKey = vdom => (null == vdom ? vdom : vdom.key),
  3059. patchProperty = (node, key, oldValue, newValue, listener, isSvg) => {
  3060. if ("key" === key);
  3061. else if ("style" === key)
  3062. for (var k in { ...oldValue, ...newValue }) {
  3063. oldValue =
  3064. null == newValue || null == newValue[k] ? "" : newValue[k]
  3065. "-" === k[0]
  3066. ? node[key].setProperty(k, oldValue)
  3067. : (node[key][k] = oldValue)
  3068. }
  3069. else
  3070. "o" === key[0] && "n" === key[1]
  3071. ? ((node.events || (node.events = {}))[(key = key.slice(2))] =
  3072. newValue)
  3073. ? oldValue || node.addEventListener(key, listener)
  3074. : node.removeEventListener(key, listener)
  3075. : !isSvg && "list" !== key && "form" !== key && key in node
  3076. ? (node[key] = null == newValue ? "" : newValue)
  3077. : null == newValue ||
  3078. !1 === newValue ||
  3079. ("class" === key && !(newValue = createClass(newValue)))
  3080. ? node.removeAttribute(key)
  3081. : node.setAttribute(key, newValue)
  3082. },
  3083. createNode = (vdom, listener, isSvg) => {
  3084. var props = vdom.props,
  3085. node =
  3086. 3 === vdom.type
  3087. ? document.createTextNode(vdom.tag)
  3088. : (isSvg = isSvg || "svg" === vdom.tag)
  3089. ? document.createElementNS(
  3090. "http://www.w3.org/2000/svg",
  3091. vdom.tag,
  3092. { is: props.is }
  3093. )
  3094. : document.createElement(vdom.tag, { is: props.is })
  3095. for (var k in props)
  3096. patchProperty(node, k, null, props[k], listener, isSvg)
  3097. for (var i = 0; i < vdom.children.length; i++)
  3098. node.appendChild(
  3099. createNode(
  3100. (vdom.children[i] = maybeVNode(vdom.children[i])),
  3101. listener,
  3102. isSvg
  3103. )
  3104. )
  3105. return (vdom.node = node)
  3106. },
  3107. patch = (parent, node, oldVNode, newVNode, listener, isSvg) => {
  3108. if (oldVNode === newVNode);
  3109. else if (
  3110. null != oldVNode &&
  3111. 3 === oldVNode.type &&
  3112. 3 === newVNode.type
  3113. )
  3114. oldVNode.tag !== newVNode.tag && (node.nodeValue = newVNode.tag)
  3115. else if (null == oldVNode || oldVNode.tag !== newVNode.tag) {
  3116. node = parent.insertBefore(
  3117. createNode((newVNode = maybeVNode(newVNode)), listener, isSvg),
  3118. node
  3119. )
  3120. null != oldVNode && parent.removeChild(oldVNode.node)
  3121. } else {
  3122. var tmpVKid,
  3123. oldVKid,
  3124. oldKey,
  3125. newKey,
  3126. oldProps = oldVNode.props,
  3127. newProps = newVNode.props,
  3128. oldVKids = oldVNode.children,
  3129. newVKids = newVNode.children,
  3130. oldHead = 0,
  3131. newHead = 0,
  3132. oldTail = oldVKids.length - 1,
  3133. newTail = newVKids.length - 1
  3134. isSvg = isSvg || "svg" === newVNode.tag
  3135. for (var i in { ...oldProps, ...newProps })
  3136. ("value" === i || "selected" === i || "checked" === i
  3137. ? node[i]
  3138. : oldProps[i]) !== newProps[i] &&
  3139. patchProperty(
  3140. node,
  3141. i,
  3142. oldProps[i],
  3143. newProps[i],
  3144. listener,
  3145. isSvg
  3146. )
  3147. for (
  3148. ;
  3149. newHead <= newTail &&
  3150. oldHead <= oldTail &&
  3151. null != (oldKey = getKey(oldVKids[oldHead])) &&
  3152. oldKey === getKey(newVKids[newHead]);
  3153.  
  3154. )
  3155. patch(
  3156. node,
  3157. oldVKids[oldHead].node,
  3158. oldVKids[oldHead],
  3159. (newVKids[newHead] = maybeVNode(
  3160. newVKids[newHead++],
  3161. oldVKids[oldHead++]
  3162. )),
  3163. listener,
  3164. isSvg
  3165. )
  3166. for (
  3167. ;
  3168. newHead <= newTail &&
  3169. oldHead <= oldTail &&
  3170. null != (oldKey = getKey(oldVKids[oldTail])) &&
  3171. oldKey === getKey(newVKids[newTail]);
  3172.  
  3173. )
  3174. patch(
  3175. node,
  3176. oldVKids[oldTail].node,
  3177. oldVKids[oldTail],
  3178. (newVKids[newTail] = maybeVNode(
  3179. newVKids[newTail--],
  3180. oldVKids[oldTail--]
  3181. )),
  3182. listener,
  3183. isSvg
  3184. )
  3185. if (oldHead > oldTail)
  3186. for (; newHead <= newTail; )
  3187. node.insertBefore(
  3188. createNode(
  3189. (newVKids[newHead] = maybeVNode(newVKids[newHead++])),
  3190. listener,
  3191. isSvg
  3192. ),
  3193. (oldVKid = oldVKids[oldHead]) && oldVKid.node
  3194. )
  3195. else if (newHead > newTail)
  3196. for (; oldHead <= oldTail; )
  3197. node.removeChild(oldVKids[oldHead++].node)
  3198. else {
  3199. var keyed = {},
  3200. newKeyed = {}
  3201. for (i = oldHead; i <= oldTail; i++)
  3202. null != (oldKey = oldVKids[i].key) &&
  3203. (keyed[oldKey] = oldVKids[i])
  3204. for (; newHead <= newTail; ) {
  3205. oldKey = getKey((oldVKid = oldVKids[oldHead]))
  3206. newKey = getKey(
  3207. (newVKids[newHead] = maybeVNode(newVKids[newHead], oldVKid))
  3208. )
  3209. if (
  3210. newKeyed[oldKey] ||
  3211. (null != newKey && newKey === getKey(oldVKids[oldHead + 1]))
  3212. ) {
  3213. null == oldKey && node.removeChild(oldVKid.node)
  3214. oldHead++
  3215. } else if (null == newKey || 1 === oldVNode.type) {
  3216. if (null == oldKey) {
  3217. patch(
  3218. node,
  3219. oldVKid && oldVKid.node,
  3220. oldVKid,
  3221. newVKids[newHead],
  3222. listener,
  3223. isSvg
  3224. )
  3225. newHead++
  3226. }
  3227. oldHead++
  3228. } else {
  3229. if (oldKey === newKey) {
  3230. patch(
  3231. node,
  3232. oldVKid.node,
  3233. oldVKid,
  3234. newVKids[newHead],
  3235. listener,
  3236. isSvg
  3237. )
  3238. newKeyed[newKey] = !0
  3239. oldHead++
  3240. } else if (null != (tmpVKid = keyed[newKey])) {
  3241. patch(
  3242. node,
  3243. node.insertBefore(
  3244. tmpVKid.node,
  3245. oldVKid && oldVKid.node
  3246. ),
  3247. tmpVKid,
  3248. newVKids[newHead],
  3249. listener,
  3250. isSvg
  3251. )
  3252. newKeyed[newKey] = !0
  3253. } else
  3254. patch(
  3255. node,
  3256. oldVKid && oldVKid.node,
  3257. null,
  3258. newVKids[newHead],
  3259. listener,
  3260. isSvg
  3261. )
  3262. newHead++
  3263. }
  3264. }
  3265. for (; oldHead <= oldTail; )
  3266. null == getKey((oldVKid = oldVKids[oldHead++])) &&
  3267. node.removeChild(oldVKid.node)
  3268. for (var i in keyed)
  3269. null == newKeyed[i] && node.removeChild(keyed[i].node)
  3270. }
  3271. }
  3272. return (newVNode.node = node)
  3273. },
  3274. maybeVNode = (newVNode, oldVNode) =>
  3275. !0 !== newVNode && !1 !== newVNode && newVNode
  3276. ? "function" == typeof newVNode.tag
  3277. ? ((!oldVNode ||
  3278. null == oldVNode.memo ||
  3279. ((a, b) => {
  3280. for (var k in a) if (a[k] !== b[k]) return !0
  3281. for (var k in b) if (a[k] !== b[k]) return !0
  3282. })(oldVNode.memo, newVNode.memo)) &&
  3283. ((oldVNode = newVNode.tag(newVNode.memo)).memo =
  3284. newVNode.memo),
  3285. oldVNode)
  3286. : newVNode
  3287. : hyperapp_text(""),
  3288. recycleNode = node =>
  3289. 3 === node.nodeType
  3290. ? hyperapp_text(node.nodeValue, node)
  3291. : createVNode(
  3292. node.nodeName.toLowerCase(),
  3293. EMPTY_OBJ,
  3294. hyperapp_map.call(node.childNodes, recycleNode),
  3295. 1,
  3296. node
  3297. ),
  3298. createVNode = (tag, props, children, type, node) => ({
  3299. tag,
  3300. props,
  3301. key: props.key,
  3302. children,
  3303. type,
  3304. node,
  3305. }),
  3306. hyperapp_text = (value, node) =>
  3307. createVNode(value, EMPTY_OBJ, EMPTY_ARR, 3, node),
  3308. h = (tag, props, children = EMPTY_ARR) =>
  3309. createVNode(tag, props, isArray(children) ? children : [children]),
  3310. app = ({
  3311. node,
  3312. view,
  3313. subscriptions,
  3314. dispatch = id,
  3315. init = EMPTY_OBJ,
  3316. }) => {
  3317. var state,
  3318. busy,
  3319. vdom = node && recycleNode(node),
  3320. subs = [],
  3321. update = newState => {
  3322. if (state !== newState) {
  3323. null == (state = newState) &&
  3324. (dispatch = subscriptions = render = id)
  3325. subscriptions &&
  3326. (subs = ((oldSubs, newSubs = EMPTY_ARR, dispatch) => {
  3327. for (
  3328. var oldSub, newSub, subs = [], i = 0;
  3329. i < oldSubs.length || i < newSubs.length;
  3330. i++
  3331. ) {
  3332. oldSub = oldSubs[i]
  3333. newSub = newSubs[i]
  3334. subs.push(
  3335. newSub && !0 !== newSub
  3336. ? !oldSub ||
  3337. newSub[0] !== oldSub[0] ||
  3338. shouldRestart(newSub[1], oldSub[1])
  3339. ? [
  3340. newSub[0],
  3341. newSub[1],
  3342. (oldSub && oldSub[2](),
  3343. newSub[0](dispatch, newSub[1])),
  3344. ]
  3345. : oldSub
  3346. : oldSub && oldSub[2]()
  3347. )
  3348. }
  3349. return subs
  3350. })(subs, subscriptions(state), dispatch))
  3351. view && !busy && enqueue(render, (busy = !0))
  3352. }
  3353. },
  3354. render = () =>
  3355. (node = patch(
  3356. node.parentNode,
  3357. node,
  3358. vdom,
  3359. (vdom = view(state)),
  3360. listener,
  3361. (busy = !1)
  3362. )),
  3363. listener = function (event) {
  3364. dispatch(this.events[event.type], event)
  3365. }
  3366. return (
  3367. (dispatch = dispatch((action, props) =>
  3368. "function" == typeof action
  3369. ? dispatch(action(state, props))
  3370. : isArray(action)
  3371. ? "function" == typeof action[0]
  3372. ? dispatch(action[0], action[1])
  3373. : action
  3374. .slice(1)
  3375. .map(
  3376. fx => fx && !0 !== fx && fx[0](dispatch, fx[1]),
  3377. update(action[0])
  3378. )
  3379. : update(action)
  3380. ))(init),
  3381. dispatch
  3382. )
  3383. }
  3384. const src_defaultSettingText = {
  3385. setting: ["Settings", "設定"],
  3386. font: ["Font", "フォント"],
  3387. color: ["Color(Normal)", "色(通常)"],
  3388. ownerColor: ["Color(Owner)", "色(オーナー)"],
  3389. moderatorColor: ["Color(Moderator)", "色(モデレーター)"],
  3390. memberColor: ["Color(Member)", "色(メンバー)"],
  3391. feedback: ["Feedback", "バグ報告と要望"],
  3392. eventLog: ["Event log", "イベントログ"],
  3393. giveFeedback: [
  3394. "Give your feedbacks here(Please attach the event log if they're bug related)",
  3395. "バグ報告、要望はこちら(バグの場合は、イベントログを添付してください)",
  3396. ],
  3397. chatOpacity: ["Opacity", "不透明度"],
  3398. fontSize: ["Size", "サイズ"],
  3399. fontWeight: ["Weight", "太さ"],
  3400. shadowFontWeight: ["Weight(Shadow)", "太さ(影)"],
  3401. flowSpeed: ["Speed", "速度"],
  3402. maxChatCount: ["Max number of chats", "最大表示数"],
  3403. maxChatLength: ["Max number of characters", "最大文字数"],
  3404. laneCount: ["Number of rows", "行数"],
  3405. bannedWords: ["Banned Words", "NGワード"],
  3406. bannedWordRegexs: ["Banned Words(Regex)", "NGワード(正規表現)"],
  3407. bannedUsers: ["Banned Users", "NGユーザー"],
  3408. simplifyChatField: ["Simplify", "簡略化する"],
  3409. createBanButton: ["Show ban button", "NGボタンを表示する"],
  3410. displayModName: [
  3411. "Show moderator's name",
  3412. "モデレータの名前を表示する",
  3413. ],
  3414. displaySuperChatAuthor: [
  3415. "Show super chat author",
  3416. "スパチャの作成者を表示する",
  3417. ],
  3418. createChats: ["Display flowing chats", "チャットを流す"],
  3419. textOnly: [
  3420. "Text only(ignore emojis)",
  3421. "文字のみ(絵文字を無視する)",
  3422. ],
  3423. error: ["Error", "エラー"],
  3424. video: ["Video", "画面"],
  3425. chatField: ["Chat Window", "チャット欄"],
  3426. useStepTiming: ["Move chat in steps", "チャットを段階的に動かす"],
  3427. timingStepCount: ["└Step Count", "└段階数"],
  3428. chatFilter: ["Chat Filter", "チャットフィルター"],
  3429. flowChat: ["Flow Chat", "チャット流れ"],
  3430. clearFlowChats: [
  3431. "Clear Flowing Chats",
  3432. "流れるチャットをクリアする",
  3433. ],
  3434. flowNewChatIf: [
  3435. "A new chat will appear if all of the followings are met:",
  3436. "新しいチャットは以下のすべてを満たす場合に流れます:",
  3437. ],
  3438. noOverlap: ["└Chats won't overlap", "└他のチャットと重ならない"],
  3439. minSpacing: ["Min spacing between chats", "チャットの最小間隔"],
  3440. fieldScale: ["Scale", "拡大率"],
  3441. copy: ["Copy", "コピーする"],
  3442. showChat: ["Show chats", "チャット非表示"],
  3443. hideChat: ["Hide chats", "チャット表示"],
  3444. flowY1: ["Flow area top edge", "流れ範囲の上端"],
  3445. flowY2: ["Flow area bottom edge", "流れ範囲の下端"],
  3446. colorShadow: ["Color(Shadow)", "色(影)"],
  3447. },
  3448. getLang = lang => key =>
  3449. src_defaultSettingText[key]["FYC_EN" === lang ? 0 : 1],
  3450. tapIs = (constructor, x) => {
  3451. assert_lib(x instanceof constructor)
  3452. return x
  3453. },
  3454. getValue = e => {
  3455. const target = e.currentTarget ?? e.__target
  3456. if (
  3457. target instanceof HTMLSelectElement ||
  3458. target instanceof HTMLTextAreaElement ||
  3459. target instanceof HTMLInputElement
  3460. )
  3461. return target.value
  3462. throw Error("Event target type isn't acceptable.")
  3463. },
  3464. ui_option = (value, label, selected) =>
  3465. h("option", { value, selected }, hyperapp_text(label)),
  3466. rangeRow = (min, max, step, value, editing, action) =>
  3467. h("div", {}, [
  3468. h("input", {
  3469. style: { width: "150px", verticalAlign: "middle" },
  3470. type: "range",
  3471. min,
  3472. max,
  3473. step,
  3474. value,
  3475. oninput: action.onchange,
  3476. }),
  3477. h("input", {
  3478. style: {
  3479. width: "30px",
  3480. backgroundColor: "transparent",
  3481. color: "inherit",
  3482. borderWidth: "1px",
  3483. verticalAlign: "middle",
  3484. },
  3485. inputmode: "decimal",
  3486. value: editing
  3487. ? value
  3488. : Number.parseFloat(value)
  3489. .toFixed(4)
  3490. .replace(/\.?0+$/, ""),
  3491. ...action,
  3492. }),
  3493. ]),
  3494. settingRow = (label, content) =>
  3495. h("div", {}, [
  3496. h("span", {}, hyperapp_text(label)),
  3497. h("div", {}, content),
  3498. ]),
  3499. tabContainer = (style, labels, tabs, mainTab, ontabSelect) =>
  3500. h("div", {}, [
  3501. h(
  3502. "div",
  3503. {},
  3504. labels.map((x, i) =>
  3505. h(
  3506. "span",
  3507. {
  3508. style: {
  3509. ...style.label,
  3510. ...(mainTab === i ? style.labelFocus : {}),
  3511. display: "inline-block",
  3512. },
  3513. onpointerdown: [ontabSelect, i],
  3514. },
  3515. hyperapp_text(x)
  3516. )
  3517. )
  3518. ),
  3519. h(
  3520. "div",
  3521. { style: { ...style.container, overflow: "hidden auto" } },
  3522. h(
  3523. "div",
  3524. { style: { ...style.tab } },
  3525. tabs.find((_, i) => i === mainTab)?.()
  3526. )
  3527. ),
  3528. ]),
  3529. style = {
  3530. resize: "horizontal",
  3531. boxSizing: "border-box",
  3532. width: "100%",
  3533. },
  3534. textAreaRow = (rows, value, readOnly, action) =>
  3535. h("textarea", { rows, value, readOnly, style, ...action }),
  3536. textColorRow = (color, textStyle, action) =>
  3537. h("div", {}, [
  3538. h("input", {
  3539. style: { width: "36px", verticalAlign: "middle" },
  3540. type: "color",
  3541. value: color,
  3542. oninput: action.onchange,
  3543. }),
  3544. h("input", {
  3545. style: { verticalAlign: "middle", width: "5.5em" },
  3546. maxlength: 20,
  3547. value: color,
  3548. ...action,
  3549. }),
  3550. h(
  3551. "span",
  3552. { style: { ...textStyle, color } },
  3553. hyperapp_text("Aa1あア亜")
  3554. ),
  3555. ]),
  3556. panelBoxStyle = width => ({ flex: `0 0 ${width}px`, margin: "2px" }),
  3557. textRowStyle = { width: "70%", boxSizing: "border-box" },
  3558. langs = [
  3559. ["FYC_EN", "English"],
  3560. ["FYC_JA", "日本語"],
  3561. ],
  3562. exampleTextStyle = s => ({
  3563. fontFamily: s.font,
  3564. fontWeight: s.fontWeight.toString(),
  3565. }),
  3566. computed = {
  3567. useStepTiming: s => Boolean(s.timingFunction.match(/^steps\(.+/)),
  3568. },
  3569. stepTiming = stepCount => `steps(${stepCount}, jump-end)`,
  3570. settingPanel = command => {
  3571. const { setConfig, act } = command,
  3572. configFx = (k, v) => [() => setConfig[k](v), void 0],
  3573. setState = {
  3574. flowY1: (s, v) => {
  3575. const flowY2 = Math.max(s.flowY2, v + 0.05)
  3576. return [
  3577. { ...s, flowY1: v, flowY2 },
  3578. configFx("flowY1", v),
  3579. configFx("flowY2", flowY2),
  3580. ]
  3581. },
  3582. flowY2: (s, v) => {
  3583. const flowY1 = Math.min(s.flowY1, v - 0.05)
  3584. return [
  3585. { ...s, flowY2: v, flowY1 },
  3586. configFx("flowY2", v),
  3587. configFx("flowY1", flowY1),
  3588. ]
  3589. },
  3590. timingStepCount: (s, v) => {
  3591. const timingFunction = stepTiming(v)
  3592. return [
  3593. { ...s, timingStepCount: v, timingFunction },
  3594. configFx("timingFunction", timingFunction),
  3595. ]
  3596. },
  3597. bannedWordRegexs: (s, v) =>
  3598. function_pipe(
  3599. v,
  3600. es6_ReadonlyArray_reduce(
  3601. { valid: !0, error: "" },
  3602. (acc, cur) => {
  3603. try {
  3604. RegExp(cur, "u")
  3605. return acc
  3606. } catch (e) {
  3607. return {
  3608. valid: !1,
  3609. error: `${acc.error}${e} in ${cur};`,
  3610. }
  3611. }
  3612. }
  3613. ),
  3614. x => [
  3615. {
  3616. ...s,
  3617. bannedWordRegexs: v,
  3618. bannedWordRegexsError: x.error,
  3619. bannedWordRegexsValid: x.valid,
  3620. },
  3621. ...(x.valid ? [configFx("bannedWordRegexs", v)] : []),
  3622. ]
  3623. ),
  3624. },
  3625. setComputed = {
  3626. useStepTiming: (s, v) => {
  3627. const timingFunction = v
  3628. ? stepTiming(s.timingStepCount)
  3629. : "linear"
  3630. return [
  3631. { ...s, timingFunction },
  3632. configFx("timingFunction", timingFunction),
  3633. ]
  3634. },
  3635. },
  3636. doAct = {
  3637. copy: async s => {
  3638. GM.setClipboard(s.eventLog.join("\n"))
  3639. },
  3640. clearFlowChats: async s => {
  3641. act.clearFlowChats()
  3642. },
  3643. },
  3644. getTrueState = (k, s) => (k in computed ? computed[k](s) : s[k]),
  3645. getState = (k, s) =>
  3646. s.editingInput.id === k
  3647. ? s.editingInput.committedState
  3648. : getTrueState(k, s),
  3649. updateAt = (k, v, s) =>
  3650. k in setComputed
  3651. ? setComputed[k](s, v)
  3652. : k in setState
  3653. ? setState[k](s, v)
  3654. : [
  3655. { ...s, [k]: v },
  3656. ...(k in setConfig ? [configFx(k, v)] : []),
  3657. ],
  3658. updateString = key => (s, e) =>
  3659. function_pipe(getValue(e), x => updateAt(key, x, s)),
  3660. updateNumber = key => (s, e) =>
  3661. function_pipe(getValue(e), parseFloat, x =>
  3662. updateAt(key, x, s)
  3663. ),
  3664. updateInt = key => (s, e) =>
  3665. function_pipe(
  3666. getValue(e),
  3667. x => parseInt(x, 10),
  3668. x => updateAt(key, x, s)
  3669. ),
  3670. updateBool = key => (s, e) =>
  3671. function_pipe(
  3672. (e => tapIs(HTMLInputElement, e.currentTarget).checked)(e),
  3673. x => updateAt(key, x, s)
  3674. ),
  3675. updateStrings = key => (s, e) =>
  3676. function_pipe(
  3677. getValue(e),
  3678. x => x.split(/\r\n|\n/).filter(str => "" !== str),
  3679. x => updateAt(key, x, s)
  3680. ),
  3681. editAction = (key, onchange) => ({
  3682. onfocus: (s, e) =>
  3683. updateAt(
  3684. "editingInput",
  3685. {
  3686. id: key,
  3687. committedState: getTrueState(key, s),
  3688. value: getValue(e),
  3689. },
  3690. s
  3691. ),
  3692. onblur: s =>
  3693. updateAt(
  3694. "editingInput",
  3695. { id: "", committedState: "", value: "" },
  3696. s
  3697. ),
  3698. oninput: (s, e) =>
  3699. updateAt(
  3700. "editingInput",
  3701. {
  3702. id: key,
  3703. committedState: s.editingInput.committedState,
  3704. value: getValue(e),
  3705. },
  3706. s
  3707. ),
  3708. onchange: (s, e) => {
  3709. const [s1, ...es1] = onchange(key)(s, e),
  3710. x =
  3711. s1.editingInput.id === key
  3712. ? {
  3713. id: key,
  3714. committedState: getTrueState(key, s1),
  3715. value: getValue(e),
  3716. }
  3717. : s1.editingInput,
  3718. [s2, ...es2] = updateAt("editingInput", x, s1)
  3719. return [s2, ...es1, ...es2]
  3720. },
  3721. }),
  3722. getEditValue = (s, k, t) =>
  3723. s.editingInput.id === k
  3724. ? s.editingInput.value
  3725. : t(getState(k, s))
  3726. return state => {
  3727. const getText = getLang(state.lang),
  3728. checkboxNode = label =>
  3729. ((label, checked, onchange) =>
  3730. h(
  3731. "div",
  3732. {},
  3733. h("label", {}, [
  3734. hyperapp_text(label),
  3735. h("input", { type: "checkbox", checked, onchange }),
  3736. ])
  3737. ))(
  3738. getText(label),
  3739. getState(label, state),
  3740. updateBool(label)
  3741. ),
  3742. textColorNode = label =>
  3743. settingRow(getText(label), [
  3744. textColorRow(
  3745. getEditValue(state, label, x => x),
  3746. exampleTextStyle(state),
  3747. editAction(label, updateString)
  3748. ),
  3749. ]),
  3750. intNode = (label, min, max, step) =>
  3751. settingRow(getText(label), [
  3752. rangeRow(
  3753. min,
  3754. max,
  3755. step,
  3756. getEditValue(state, label, x => x.toString()),
  3757. state.editingInput.id === label,
  3758. editAction(label, updateInt)
  3759. ),
  3760. ]),
  3761. numberNode = (label, min, max, step) =>
  3762. settingRow(getText(label), [
  3763. rangeRow(
  3764. min,
  3765. max,
  3766. step,
  3767. getEditValue(state, label, x => x.toString()),
  3768. state.editingInput.id === label,
  3769. editAction(label, updateNumber)
  3770. ),
  3771. ]),
  3772. buttonNode = label =>
  3773. h(
  3774. "button",
  3775. {
  3776. type: "button",
  3777. onclick: s => [s, [() => doAct[label](s), void 0]],
  3778. },
  3779. hyperapp_text(getText(label))
  3780. ),
  3781. textAreaNode = (label, rows) =>
  3782. settingRow(getText(label), [
  3783. textAreaRow(
  3784. rows,
  3785. getEditValue(state, label, x => x.join("\n")),
  3786. !1,
  3787. editAction(label, updateStrings)
  3788. ),
  3789. ]),
  3790. currentFonts = [
  3791. ["", "Default", "デフォルト"],
  3792. ["arial", "Arial", "Arial"],
  3793. ["arial black", "Arial Black", "Arial Black"],
  3794. ["arial narrow", "Arial Narrow", "Arial Narrow"],
  3795. ["Century", "Century", "Century"],
  3796. ["Comic Sans MS", "Comic Sans MS", "Comic Sans MS"],
  3797. ["Courier", "Courier", "Courier"],
  3798. ["cursive", "cursive", "cursive"],
  3799. ["fantasy", "fantasy", "fantasy"],
  3800. ["Impact", "Impact", "Impact"],
  3801. ["Meiryo", "Meiryo", "メイリオ"],
  3802. ["Meiryo UI", "Meiryo UI", "メイリオ UI"],
  3803. ["monospace", "monospace", "monospace"],
  3804. ["Monotype Corsiva", "Monotype Corsiva", "Monotype Corsiva"],
  3805. ["MS PGothic", "MS PGothic", "MS Pゴシック"],
  3806. ["MS Gothic", "MS Gothic", "MS ゴシック"],
  3807. ["MS Sans Serif", "MS Sans Serif", "MS Sans Serif"],
  3808. ["MS Serif", "MS Serif", "MS Serif"],
  3809. ["MS UI Gothic", "MS UI Gothic", "MS UI Gothic"],
  3810. ["sans-serif", "Sans-serif", "Sans-serif"],
  3811. ["serif", "Serif", "Serif"],
  3812. ["Times New Roman", "Times New Roman", "Times New Roman"],
  3813. ["Yu Gothic", "Yu Gothic", "遊ゴシック"],
  3814. ["YuGothic", "YuGothic", "游ゴシック体"],
  3815. [state.font, "Custom", "カスタム"],
  3816. ]
  3817. const logPageLength =
  3818. Math.trunc(getState("eventLog", state).length / 100) + 1
  3819. return state.showPanel
  3820. ? h(
  3821. "div",
  3822. {
  3823. class: "fyc_panel",
  3824. style: {
  3825. backgroundColor: "rgba(30,30,30,0.9)",
  3826. zIndex: "10000",
  3827. position: "absolute",
  3828. bottom: "40px",
  3829. right: "0px",
  3830. color: "#fff",
  3831. fontSize: "14px",
  3832. width: "660px",
  3833. border: "solid 1px #666",
  3834. fontFamily: "MS PGothic",
  3835. lineHeight: "1.2",
  3836. },
  3837. },
  3838. [
  3839. h(
  3840. "div",
  3841. { style: { float: "right", margin: "3px 3px 0 0" } },
  3842. [
  3843. hyperapp_text("🌐"),
  3844. h(
  3845. "select",
  3846. { onchange: updateString("lang") },
  3847. langs.map(x => ui_option(...x, x[0] === state.lang))
  3848. ),
  3849. ]
  3850. ),
  3851. tabContainer(
  3852. {
  3853. container: { height: "364px" },
  3854. label: { padding: "6px" },
  3855. labelFocus: { background: "#666" },
  3856. tab: { display: "flex", padding: "6px" },
  3857. },
  3858. [
  3859. getText("flowChat"),
  3860. getText("chatFilter"),
  3861. getText("chatField"),
  3862. getText("feedback"),
  3863. ],
  3864. [
  3865. () => [
  3866. h("div", { style: panelBoxStyle(212) }, [
  3867. settingRow(getText("font"), [
  3868. h(
  3869. "select",
  3870. {
  3871. style: textRowStyle,
  3872. onchange: updateString("font"),
  3873. },
  3874. function_pipe(
  3875. currentFonts,
  3876. findIndex(x => x[0] === state.font),
  3877. getOrElse(() => 0),
  3878. index =>
  3879. currentFonts.map((x, i) =>
  3880. ui_option(
  3881. x[0],
  3882. "FYC_JA" === state.lang ? x[2] : x[1],
  3883. i === index
  3884. )
  3885. )
  3886. )
  3887. ),
  3888. ]),
  3889. h("input", {
  3890. style: textRowStyle,
  3891. maxlength: 20,
  3892. value: state.font,
  3893. oninput: updateString("font"),
  3894. }),
  3895. textColorNode("color"),
  3896. textColorNode("ownerColor"),
  3897. textColorNode("moderatorColor"),
  3898. textColorNode("memberColor"),
  3899. ]),
  3900. h("div", { style: panelBoxStyle(212) }, [
  3901. numberNode("chatOpacity", 0, 1, 0.05),
  3902. numberNode("fontSize", 0.3, 2, 0.05),
  3903. numberNode("fontWeight", 10, 1e3, 10),
  3904. numberNode("shadowFontWeight", 0, 3, 0.1),
  3905. numberNode("flowSpeed", 1, 50, 1),
  3906. intNode("maxChatCount", 5, 200, 5),
  3907. intNode("maxChatLength", 5, 200, 5),
  3908. intNode("laneCount", 1, 25, 1),
  3909. ]),
  3910. h("div", { style: panelBoxStyle(212) }, [
  3911. numberNode("flowY1", 0, 0.95, 0.05),
  3912. numberNode("flowY2", 0.05, 1, 0.05),
  3913. numberNode("minSpacing", 0, 2.5, 0.1),
  3914. checkboxNode("useStepTiming"),
  3915. h(
  3916. "div",
  3917. {
  3918. style: {
  3919. ...(getState("useStepTiming", state)
  3920. ? {}
  3921. : { opacity: "0.5" }),
  3922. },
  3923. },
  3924. intNode("timingStepCount", 1, 400, 1)
  3925. ),
  3926. checkboxNode("createChats"),
  3927. checkboxNode("displayModName"),
  3928. checkboxNode("displaySuperChatAuthor"),
  3929. checkboxNode("textOnly"),
  3930. h(
  3931. "span",
  3932. {},
  3933. hyperapp_text(getText("flowNewChatIf"))
  3934. ),
  3935. checkboxNode("noOverlap"),
  3936. buttonNode("clearFlowChats"),
  3937. ]),
  3938. ],
  3939. () => [
  3940. h(
  3941. "div",
  3942. { style: panelBoxStyle(212) },
  3943. textAreaNode("bannedWords", 18)
  3944. ),
  3945. h(
  3946. "div",
  3947. { style: panelBoxStyle(212) },
  3948. settingRow(getText("bannedWordRegexs"), [
  3949. h(
  3950. "span",
  3951. {},
  3952. hyperapp_text(
  3953. state.bannedWordRegexsValid
  3954. ? ""
  3955. : `${getText("error")}: ${
  3956. state.bannedWordRegexsError
  3957. }`
  3958. )
  3959. ),
  3960. textAreaRow(
  3961. 18,
  3962. getEditValue(state, "bannedWordRegexs", x =>
  3963. x.join("\n")
  3964. ),
  3965. !1,
  3966. editAction("bannedWordRegexs", updateStrings)
  3967. ),
  3968. ])
  3969. ),
  3970. h(
  3971. "div",
  3972. { style: panelBoxStyle(212) },
  3973. textAreaNode("bannedUsers", 18)
  3974. ),
  3975. ],
  3976. () => [
  3977. h("div", { style: panelBoxStyle(644) }, [
  3978. numberNode("fieldScale", 0.7, 1.5, 0.05),
  3979. checkboxNode("simplifyChatField"),
  3980. checkboxNode("createBanButton"),
  3981. ]),
  3982. ],
  3983. () => [
  3984. h("div", { style: panelBoxStyle(644) }, [
  3985. h(
  3986. "div",
  3987. { style: { float: "right" } },
  3988. h(
  3989. "a",
  3990. {
  3991. style: { color: "#f0f" },
  3992. href: "https://greasyfork.org/en/scripts/411442-flow-youtube-chat/feedback",
  3993. target: "_blank",
  3994. },
  3995. hyperapp_text(getText("giveFeedback"))
  3996. )
  3997. ),
  3998. h("div", {}, [
  3999. h(
  4000. "span",
  4001. {},
  4002. hyperapp_text(getText("eventLog"))
  4003. ),
  4004. buttonNode("copy"),
  4005. tabContainer(
  4006. {
  4007. container: { height: "276px" },
  4008. label: {
  4009. padding: "4px",
  4010. width: "2em",
  4011. textAlign: "center",
  4012. },
  4013. labelFocus: { background: "#666" },
  4014. tab: {
  4015. display: "flex",
  4016. flexDirection: "column",
  4017. padding: "6px",
  4018. },
  4019. },
  4020. function_pipe(
  4021. ReadonlyArray_makeBy(logPageLength, i =>
  4022. i.toString()
  4023. )
  4024. ),
  4025. function_pipe(
  4026. ReadonlyArray_makeBy(
  4027. logPageLength,
  4028. i => () =>
  4029. function_pipe(
  4030. getState("eventLog", state).slice(
  4031. 100 * i,
  4032. 100 * (i + 1)
  4033. ),
  4034. es6_ReadonlyArray_mapWithIndex(
  4035. (j, x) =>
  4036. h(
  4037. "div",
  4038. { style: { display: "flex" } },
  4039. [
  4040. h(
  4041. "div",
  4042. {
  4043. style: {
  4044. userSelect: "none",
  4045. flex: "0 0 2em",
  4046. },
  4047. },
  4048. [hyperapp_text(100 * i + j)]
  4049. ),
  4050. h(
  4051. "div",
  4052. {
  4053. style: {
  4054. background:
  4055. j % 2 == 0
  4056. ? "#fff"
  4057. : "#ddd",
  4058. color: "#000",
  4059. flex: "auto",
  4060. wordBreak: "break-all",
  4061. padding: "0 2px",
  4062. },
  4063. },
  4064. [hyperapp_text(x)]
  4065. ),
  4066. ]
  4067. )
  4068. )
  4069. )
  4070. )
  4071. ),
  4072. getState("logTab", state),
  4073. (s, n) => updateAt("logTab", n, s)
  4074. ),
  4075. ]),
  4076. ]),
  4077. ],
  4078. ],
  4079. getState("mainTab", state),
  4080. (s, n) => updateAt("mainTab", n, s)
  4081. ),
  4082. ]
  4083. )
  4084. : h("div", {})
  4085. }
  4086. },
  4087. togglePanel = (x, e) => [
  4088. { ...x, showPanel: !x.showPanel },
  4089. [
  4090. x.showPanel
  4091. ? () => tapIs(HTMLElement, e.currentTarget).blur()
  4092. : () => {},
  4093. void 0,
  4094. ],
  4095. ],
  4096. simpleWrap = (comp, init) => {
  4097. const node = document.createElement(comp.tag)
  4098. return { node, dispatch: app({ init, view: comp.view, node }) }
  4099. },
  4100. initialize = async () => {
  4101. const userConfig = await (async () => ({
  4102. lang: await sc("LANG", "FYC_EN"),
  4103. font: await sc("FONT", "MS PGothic"),
  4104. chatOpacity: await sc("OPACITY", 0.8),
  4105. color: await sc("COLOR", "#ffffff"),
  4106. ownerColor: await sc("COLOR_OWNER", "#ffd600"),
  4107. moderatorColor: await sc("COLOR_MODERATOR", "#a74fff"),
  4108. memberColor: await sc("COLOR_MEMBER", "#9fffff"),
  4109. fontSize: await sc("SIZE", 1),
  4110. fontWeight: await sc("WEIGHT", 730),
  4111. shadowFontWeight: await sc("WEIGHT_SHADOW", 1),
  4112. maxChatCount: await sc("LIMIT", 40),
  4113. flowSpeed: await sc("SPEED", 18),
  4114. maxChatLength: await sc("MAX", 100),
  4115. laneCount: await sc("LANE_DIV", 12),
  4116. bannedWords: await ic("NG_WORDS", ...stringsArgs),
  4117. bannedWordRegexs: await ic("NG_REG_WORDS", ...stringsArgs),
  4118. bannedUsers: await ic("NG_USERS", ...stringsArgs),
  4119. createChats: await sc("TOGGLE_CREATE_COMMENTS", !0),
  4120. noOverlap: await sc("NO_OVERLAP", !0),
  4121. createBanButton: await sc("NG_BUTTON", !0),
  4122. simplifyChatField: await sc("SIMPLE_CHAT_FIELD", !1),
  4123. displayModName: await sc("DISPLAY_MODERATOR_NAME", !0),
  4124. displaySuperChatAuthor: await sc(
  4125. "DISPLAY_SUPER_CHAT_AUTHOR",
  4126. !0
  4127. ),
  4128. textOnly: await sc("TEXT_ONLY", !1),
  4129. timingFunction: await sc("TIMING_FUNCTION", "linear"),
  4130. displayChats: await sc("DISPLAY_COMMENTS", !0),
  4131. minSpacing: await sc("MIN_SPACING", 0.5),
  4132. fieldScale: await sc("FIELD_SCALE", 1),
  4133. flowY1: await sc("flowY1", 0),
  4134. flowY2: await sc("flowY2", 1),
  4135. colorShadow: await sc("clrShadow", "#9fffff"),
  4136. }))(),
  4137. configKeys = Object.keys(userConfig),
  4138. getConfig = function_pipe(
  4139. configKeys,
  4140. es6_ReadonlyArray_map(x => [x, () => userConfig[x].val]),
  4141. Object.fromEntries
  4142. ),
  4143. mainState = {
  4144. chatPlaying: !0,
  4145. playerRect: new DOMRect(24, 80, 839, 472),
  4146. filterExp: Option_none,
  4147. getConfig,
  4148. },
  4149. configSubject = function_pipe(
  4150. configKeys,
  4151. es6_ReadonlyArray_map(x => [
  4152. x,
  4153. new external_rxjs_namespaceObject.Subject(),
  4154. ]),
  4155. Object.fromEntries
  4156. ),
  4157. channel = new broadcast_channel_BroadcastChannel(
  4158. "fyc-0615654655528523"
  4159. ),
  4160. setConfigPlain = function_pipe(
  4161. configKeys,
  4162. es6_ReadonlyArray_map(x => [
  4163. x,
  4164. async val => {
  4165. userConfig[x].val = val
  4166. configSubject[x].next(val)
  4167. },
  4168. ]),
  4169. Object.fromEntries
  4170. ),
  4171. setConfig = function_pipe(
  4172. configKeys,
  4173. es6_ReadonlyArray_map(x => [
  4174. x,
  4175. async val => {
  4176. setConfigPlain[x](val)
  4177. const item = userConfig[x]
  4178. channel.postMessage([x, val])
  4179. GM.setValue(item.gmKey, item.toGm(val))
  4180. },
  4181. ]),
  4182. Object.fromEntries
  4183. ),
  4184. reinitSubject = new external_rxjs_namespaceObject.Subject(),
  4185. reinitialize = () => {
  4186. requestAnimationFrame(() => lib(reinitSubject)())
  4187. },
  4188. chatScreen = (() => {
  4189. const element = document.createElement("div")
  4190. element.style.pointerEvents = "none"
  4191. element.style.zIndex = "30"
  4192. return element
  4193. })(),
  4194. css = (() => {
  4195. const element = document.createElement("style")
  4196. element.innerHTML =
  4197. ".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 }"
  4198. return element
  4199. })(),
  4200. flowChats = [],
  4201. documentMutationPair = observePair(MutationObserver),
  4202. chatMutationPair = observePair(MutationObserver),
  4203. playerResizePair = observePair(ResizeObserver),
  4204. toggleChatButtonInit = {
  4205. lang: getConfig.lang(),
  4206. displayChats: getConfig.displayChats(),
  4207. },
  4208. wrappedToggleChatBtn = simpleWrap(
  4209. (setConfig => ({
  4210. tag: "button",
  4211. view: state => {
  4212. const label = getLang(state.lang)(
  4213. state.displayChats ? "hideChat" : "showChat"
  4214. )
  4215. return h(
  4216. "button",
  4217. {
  4218. class: "ytp-button",
  4219. style: {
  4220. background: "none",
  4221. border: "none",
  4222. cursor: "pointer",
  4223. float: "left",
  4224. fontSize: "1em",
  4225. height: "4em",
  4226. outline: "none",
  4227. overflow: "visible",
  4228. padding: "0 0 0em",
  4229. position: "relative",
  4230. width: "3em",
  4231. },
  4232. type: "button",
  4233. "aria-label": label,
  4234. title: label,
  4235. onclick: s => {
  4236. const displayChats = !s.displayChats
  4237. return [
  4238. { ...s, displayChats },
  4239. [
  4240. () => setConfig.displayChats(displayChats),
  4241. void 0,
  4242. ],
  4243. ]
  4244. },
  4245. },
  4246. [
  4247. h(
  4248. "svg",
  4249. { style: { width: "100%" }, viewBox: "0 0 36 36" },
  4250. [
  4251. h("path", {
  4252. class: "chat-button-path",
  4253. d: "m11 12h17q1 0 1 1v9q0 1-1 1h-1v2l-4-2h-12q-1 0-1-1v-9q0-1 1-1z",
  4254. fill: "#fff",
  4255. "fill-opacity": state.displayChats ? "1" : "0",
  4256. stroke: "#fff",
  4257. "stroke-width": "2",
  4258. }),
  4259. ]
  4260. ),
  4261. ]
  4262. )
  4263. },
  4264. }))(setConfig),
  4265. toggleChatButtonInit
  4266. ),
  4267. wrappedSetting = simpleWrap(
  4268. (command => {
  4269. const panel = settingPanel(command)
  4270. return {
  4271. tag: "span",
  4272. view: s => {
  4273. return h("span", { style: { display: "contents" } }, [
  4274. panel(s),
  4275. ((state = s),
  4276. h(
  4277. "button",
  4278. {
  4279. class: "fyc_button",
  4280. style: {
  4281. background: "rgba(0,0,0,0)",
  4282. marginLeft: "10px",
  4283. whiteSpace: "nowrap",
  4284. },
  4285. onclick: togglePanel,
  4286. },
  4287. [
  4288. h(
  4289. "svg",
  4290. {
  4291. preserveAspectRatio: "xMidYMid meet",
  4292. viewBox: "0 0 640 640",
  4293. width: "15",
  4294. height: "15",
  4295. style: { position: "relative", top: "1px" },
  4296. },
  4297. [
  4298. h(
  4299. "defs",
  4300. {},
  4301. h("path", {
  4302. id: "d1TbzTC1zI",
  4303. d: "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",
  4304. })
  4305. ),
  4306. h("use", {
  4307. href: "#d1TbzTC1zI",
  4308. opacity: "1",
  4309. fill: "var(--iron-icon-fill-color, currentcolor)",
  4310. "fill-opacity": "1",
  4311. }),
  4312. ]
  4313. ),
  4314. h(
  4315. "span",
  4316. {
  4317. style: {
  4318. position: "relative",
  4319. top: "-2px",
  4320. marginLeft: "8px,",
  4321. },
  4322. },
  4323. hyperapp_text(getLang(state.lang)("setting"))
  4324. ),
  4325. ]
  4326. )),
  4327. ])
  4328. var state
  4329. },
  4330. }
  4331. })({
  4332. setConfig,
  4333. act: {
  4334. clearFlowChats: async () => removeOldChats(flowChats, 0),
  4335. },
  4336. }),
  4337. (getConfig => ({
  4338. ...function_pipe(
  4339. Object.entries(getConfig),
  4340. es6_ReadonlyArray_map(([k, v]) => [k, v()]),
  4341. Object.fromEntries
  4342. ),
  4343. showPanel: !1,
  4344. bannedWordRegexsValid: !0,
  4345. bannedWordRegexsError: "",
  4346. mainTab: 0,
  4347. logTab: 0,
  4348. timingStepCount: parseInt(
  4349. getConfig.timingFunction().match(/^steps\((\d+),.+/)?.[1] ??
  4350. "150",
  4351. 10
  4352. ),
  4353. eventLog: [],
  4354. editingInput: { id: "", committedState: void 0, value: "" },
  4355. }))(getConfig)
  4356. ),
  4357. mainLog = (a, ...b) =>
  4358. wrappedSetting.dispatch(s => ({
  4359. ...s,
  4360. eventLog: appendLog(s.eventLog)(a, ...b),
  4361. })),
  4362. consoleLog = (a, ...b) =>
  4363. function_pipe(
  4364. () => mainLog(a, ...b),
  4365. IO_apSecond(() =>
  4366. external_log_default().info(
  4367. ...("string" == typeof a
  4368. ? [`【FYC ${a}`]
  4369. : ["【FYC】", a])
  4370. )
  4371. ),
  4372. IO_apSecond(
  4373. b.length > 0
  4374. ? () => external_log_default().info(...b)
  4375. : () => {}
  4376. )
  4377. )
  4378. mainLog("Version", package_namespaceObject_i8)
  4379. mainLog("User Agent", window.navigator.userAgent)
  4380. mainLog("UserConfig", JSON.stringify(userConfig))
  4381. const cs = function_pipe(
  4382. configSubject,
  4383. Object.entries,
  4384. es6_ReadonlyArray_map(([k, v]) => [
  4385. k,
  4386. v.pipe(
  4387. (0, external_rxjs_namespaceObject.tap)(x =>
  4388. function_pipe(
  4389. () => wrappedSetting.dispatch(s => ({ ...s, [k]: x })),
  4390. IO_apSecond(
  4391. k in toggleChatButtonInit
  4392. ? () =>
  4393. wrappedToggleChatBtn.dispatch(s => ({
  4394. ...s,
  4395. [k]: x,
  4396. }))
  4397. : () => {}
  4398. ),
  4399. requestAnimationFrame
  4400. )
  4401. )
  4402. ),
  4403. ]),
  4404. Object.fromEntries
  4405. ),
  4406. livePage = {
  4407. toggleChatBtnParent: () =>
  4408. fromNullable(document.querySelector(".ytp-right-controls")),
  4409. settingNextElement: () =>
  4410. fromNullable(
  4411. document.querySelector(
  4412. "#menu-container .dropdown-trigger.ytd-menu-renderer"
  4413. )
  4414. ),
  4415. player: () =>
  4416. fromNullable(document.querySelector("#movie_player")),
  4417. video: () =>
  4418. fromNullable(
  4419. document.querySelector(
  4420. "video.video-stream.html5-main-video"
  4421. )
  4422. ),
  4423. chatField: () =>
  4424. function_pipe(
  4425. chatApp(),
  4426. chainNullableK(x =>
  4427. x.querySelector("#items.yt-live-chat-item-list-renderer")
  4428. )
  4429. ),
  4430. chatTicker: () =>
  4431. function_pipe(
  4432. chatApp(),
  4433. chainNullableK(x =>
  4434. x.querySelector("#items.yt-live-chat-ticker-renderer")
  4435. )
  4436. ),
  4437. chatScroller: () =>
  4438. function_pipe(
  4439. chatApp(),
  4440. chainNullableK(x =>
  4441. x.querySelector(
  4442. "#item-scroller.yt-live-chat-item-list-renderer"
  4443. )
  4444. )
  4445. ),
  4446. offlineSlate: () =>
  4447. fromNullable(document.querySelector(".ytp-offline-slate")),
  4448. },
  4449. liveElementKeys = Object.keys(livePage),
  4450. live = function_pipe(
  4451. liveElementKeys,
  4452. es6_ReadonlyArray_map(x => {
  4453. return [
  4454. x,
  4455. ((key = x), { ele: Option_none, read: livePage[key] }),
  4456. ]
  4457. var key
  4458. }),
  4459. Object.fromEntries
  4460. ),
  4461. config$ = (0, external_rxjs_namespaceObject.merge)(
  4462. (0, external_rxjs_namespaceObject.merge)(
  4463. cs.bannedWordRegexs,
  4464. cs.bannedWords,
  4465. cs.bannedUsers
  4466. ).pipe(
  4467. (0, external_rxjs_namespaceObject.startWith)(void 0),
  4468. (0, external_rxjs_namespaceObject.tap)(() => {
  4469. mainState.filterExp = Option_some(
  4470. (getConfig =>
  4471. external_jsep_default()(
  4472. `\nor([\nRA.some(anyPreds([\n flip(flow([matchedByText, RA.some]))(${JSON.stringify(
  4473. getConfig.bannedWordRegexs()
  4474. )}),\n flip(flow([inText, RA.some]))(${JSON.stringify(
  4475. getConfig.bannedWords()
  4476. )})\n]))(RA.compact([\n messageText,\n paymentInfo\n])),\nO.exists(\n flip(flow([eqText, RA.some]))(${JSON.stringify(
  4477. getConfig.bannedUsers()
  4478. )})\n)(authorID)\n])\n`
  4479. ))(getConfig)
  4480. )
  4481. })
  4482. ),
  4483. cs.fieldScale.pipe(
  4484. (0, external_rxjs_namespaceObject.startWith)(
  4485. getConfig.fieldScale()
  4486. ),
  4487. (0, external_rxjs_namespaceObject.tap)(scale =>
  4488. function_pipe(
  4489. live.chatField.ele,
  4490. fromOption,
  4491. IOOption_chain(field =>
  4492. IOOption_fromIO(() =>
  4493. function_pipe(
  4494. [
  4495. function_pipe(
  4496. fromNullable(field.parentElement),
  4497. es6_Option_map(x => () => {
  4498. x.style.transformOrigin =
  4499. (scale >= 1 ? "top" : "bottom") + " left"
  4500. x.style.transform = `scale(${scale})`
  4501. x.style.width = 100 / scale + "%"
  4502. x.style.height = `${field.offsetHeight}px`
  4503. })
  4504. ),
  4505. function_pipe(
  4506. live.chatScroller.ele,
  4507. es6_Option_map(scroller => () => {
  4508. scroller.scrollTop = scroller.scrollHeight
  4509. })
  4510. ),
  4511. ],
  4512. ReadonlyArray_compact,
  4513. IO_sequenceArray
  4514. )
  4515. )
  4516. )
  4517. )()
  4518. )
  4519. ),
  4520. (0, external_rxjs_namespaceObject.merge)(
  4521. (0, external_rxjs_namespaceObject.merge)(
  4522. cs.font,
  4523. cs.fontSize,
  4524. cs.fontWeight,
  4525. cs.laneCount,
  4526. cs.minSpacing,
  4527. cs.flowY1,
  4528. cs.flowY2,
  4529. cs.textOnly
  4530. ).pipe(
  4531. (0, external_rxjs_namespaceObject.mapTo)({
  4532. render: !0,
  4533. setAnimation: !0,
  4534. })
  4535. ),
  4536. (0, external_rxjs_namespaceObject.merge)(
  4537. cs.color,
  4538. cs.ownerColor,
  4539. cs.moderatorColor,
  4540. cs.memberColor,
  4541. cs.chatOpacity,
  4542. cs.shadowFontWeight,
  4543. cs.displayChats
  4544. ).pipe(
  4545. (0, external_rxjs_namespaceObject.mapTo)({ render: !0 })
  4546. ),
  4547. (0, external_rxjs_namespaceObject.merge)(cs.flowSpeed).pipe(
  4548. (0, external_rxjs_namespaceObject.mapTo)({
  4549. setPlayState: !0,
  4550. })
  4551. ),
  4552. (0, external_rxjs_namespaceObject.merge)(
  4553. cs.maxChatCount.pipe(
  4554. (0, external_rxjs_namespaceObject.tap)(x =>
  4555. removeOldChats(flowChats, x)
  4556. )
  4557. ),
  4558. cs.noOverlap,
  4559. cs.timingFunction
  4560. ).pipe(
  4561. (0, external_rxjs_namespaceObject.mapTo)({
  4562. setAnimation: !0,
  4563. })
  4564. )
  4565. ).pipe(
  4566. (0, external_rxjs_namespaceObject.throttleTime)(180, void 0, {
  4567. leading: !0,
  4568. trailing: !0,
  4569. }),
  4570. (0, external_rxjs_namespaceObject.tap)(config =>
  4571. function_pipe(
  4572. flowChats,
  4573. es6_ReadonlyArray_filter(x => !x.animationEnded),
  4574. es6_ReadonlyArray_map(chat =>
  4575. function_pipe(
  4576. {
  4577. render: !1,
  4578. setAnimation: !1,
  4579. setPlayState: !1,
  4580. ...config,
  4581. },
  4582. x =>
  4583. function_pipe(
  4584. [
  4585. function_pipe(
  4586. renderChat(chat),
  4587. fromPredicate(() => x.render)
  4588. ),
  4589. function_pipe(
  4590. setChatAnimation(chat, flowChats),
  4591. fromPredicate(() => x.setAnimation),
  4592. alt(() =>
  4593. function_pipe(
  4594. setChatPlayState(chat),
  4595. fromPredicate(() => x.setPlayState)
  4596. )
  4597. )
  4598. ),
  4599. ],
  4600. ReadonlyArray_compact,
  4601. es6_ReadonlyArray_map(
  4602. (function (a) {
  4603. return function (f) {
  4604. return f(a)
  4605. }
  4606. })(mainState)
  4607. ),
  4608. IO_sequenceArray
  4609. )
  4610. )
  4611. ),
  4612. IO_sequenceArray
  4613. )()
  4614. )
  4615. ),
  4616. cs.lang,
  4617. cs.maxChatLength,
  4618. cs.simplifyChatField,
  4619. cs.createBanButton,
  4620. cs.createChats,
  4621. cs.displayModName,
  4622. cs.displaySuperChatAuthor,
  4623. cs.fieldScale,
  4624. cs.bannedWords,
  4625. cs.bannedWordRegexs,
  4626. cs.bannedUsers
  4627. ),
  4628. eq = getEq(eqStrict).equals
  4629. reinitSubject
  4630. .pipe(
  4631. (0, external_rxjs_namespaceObject.observeOn)(
  4632. external_rxjs_namespaceObject.asyncScheduler
  4633. ),
  4634. (0, external_rxjs_namespaceObject.delay)(100),
  4635. (0, external_rxjs_namespaceObject.tap)(consoleLog("Init")),
  4636. (0, external_rxjs_namespaceObject.switchMap)(() =>
  4637. (0, external_rxjs_namespaceObject.interval)(700).pipe(
  4638. (0, external_rxjs_namespaceObject.filter)(() =>
  4639. function_pipe(
  4640. liveElementKeys,
  4641. es6_ReadonlyArray_map(key =>
  4642. function_pipe(
  4643. live[key].read(),
  4644. fromPredicate(newEle => !eq(live[key].ele, newEle)),
  4645. es6_Option_map(x => () => {
  4646. live[key].ele = x
  4647. }),
  4648. es6_Option_map(
  4649. IO_apSecond(consoleLog(`${key} changed`))
  4650. )
  4651. )
  4652. ),
  4653. ReadonlyArray_compact,
  4654. IO_sequenceArray,
  4655. es6_IO_map(ReadonlyArray_isNonEmpty)
  4656. )()
  4657. ),
  4658. (0, external_rxjs_namespaceObject.startWith)(0)
  4659. )
  4660. ),
  4661. (0, external_rxjs_namespaceObject.tap)(
  4662. consoleLog("Loading...")
  4663. ),
  4664. (0, external_rxjs_namespaceObject.tap)(() => {
  4665. removeOldChats(flowChats, 0)
  4666. documentMutationPair.observer.disconnect()
  4667. documentMutationPair.observer.observe(document, {
  4668. childList: !0,
  4669. subtree: !0,
  4670. })
  4671. chatMutationPair.observer.disconnect()
  4672. playerResizePair.observer.disconnect()
  4673. document.head.append(css)
  4674. function_pipe(
  4675. [
  4676. function_pipe(
  4677. live.chatField.ele,
  4678. es6_Option_map(x => () => {
  4679. ;((chatField = x),
  4680. () =>
  4681. function_pipe(
  4682. fromNullable(chatField.parentElement),
  4683. es6_Option_map(x => () => {
  4684. x.style.overflow = "unset"
  4685. })
  4686. ))()
  4687. var chatField
  4688. chatMutationPair.observer.observe(x, {
  4689. childList: !0,
  4690. })
  4691. })
  4692. ),
  4693. function_pipe(
  4694. live.chatTicker.ele,
  4695. es6_Option_map(x => () => {
  4696. chatMutationPair.observer.observe(x, {
  4697. childList: !0,
  4698. })
  4699. })
  4700. ),
  4701. function_pipe(
  4702. live.player.ele,
  4703. es6_Option_map(x => () => {
  4704. playerResizePair.observer.observe(x)
  4705. x.insertAdjacentElement("afterbegin", chatScreen)
  4706. })
  4707. ),
  4708. function_pipe(
  4709. live.toggleChatBtnParent.ele,
  4710. es6_Option_map(x => () => {
  4711. x.append(wrappedToggleChatBtn.node)
  4712. })
  4713. ),
  4714. function_pipe(
  4715. live.settingNextElement.ele,
  4716. es6_Option_map(x => () => {
  4717. x.insertAdjacentElement(
  4718. "beforebegin",
  4719. wrappedSetting.node
  4720. )
  4721. })
  4722. ),
  4723. ],
  4724. ReadonlyArray_compact,
  4725. ReadonlyArray_append(
  4726. function_pipe(
  4727. live.video.ele,
  4728. filter(x => !x.paused),
  4729. alt(() => live.offlineSlate.ele),
  4730. Option_isSome,
  4731. x => () => {
  4732. mainState.chatPlaying = x
  4733. }
  4734. )
  4735. ),
  4736. IO_sequenceArray
  4737. )()
  4738. }),
  4739. (0, external_rxjs_namespaceObject.switchMap)(() =>
  4740. (0, external_rxjs_namespaceObject.merge)(
  4741. (0, external_rxjs_namespaceObject.fromEvent)(
  4742. channel,
  4743. "message"
  4744. ).pipe(
  4745. (0, external_rxjs_namespaceObject.tap)(([key, val]) =>
  4746. function_pipe(
  4747. [
  4748. "lang",
  4749. "bannedWords",
  4750. "bannedWordRegexs",
  4751. "bannedUsers",
  4752. "simplifyChatField",
  4753. "createBanButton",
  4754. "fieldScale",
  4755. ].includes(key),
  4756. x => (x ? () => setConfigPlain[key](val) : () => {})
  4757. )()
  4758. )
  4759. ),
  4760. ...function_pipe(
  4761. configKeys,
  4762. es6_ReadonlyArray_map(key =>
  4763. cs[key].pipe(
  4764. (0, external_rxjs_namespaceObject.startWith)(
  4765. getConfig[key]()
  4766. ),
  4767. (0, external_rxjs_namespaceObject.bufferCount)(2, 1),
  4768. (0, external_rxjs_namespaceObject.map)(([x, y]) =>
  4769. (0, external_DeepDiff_namespaceObject.diff)(x, y)
  4770. ),
  4771. (0, external_rxjs_namespaceObject.tap)(x =>
  4772. mainLog(
  4773. `Config ${key}`,
  4774. JSON.stringify(x, void 0, 2)
  4775. )
  4776. )
  4777. )
  4778. )
  4779. ),
  4780. config$,
  4781. function_pipe(
  4782. live.video.ele,
  4783. match(
  4784. () => external_rxjs_namespaceObject.EMPTY,
  4785. x => {
  4786. return ((video = x),
  4787. (0, external_rxjs_namespaceObject.merge)(
  4788. (0, external_rxjs_namespaceObject.fromEvent)(
  4789. video,
  4790. "playing"
  4791. ).pipe(
  4792. (0, external_rxjs_namespaceObject.mapTo)(!0)
  4793. ),
  4794. (0, external_rxjs_namespaceObject.fromEvent)(
  4795. video,
  4796. "waiting"
  4797. ).pipe(
  4798. (0, external_rxjs_namespaceObject.mapTo)(!1)
  4799. ),
  4800. (0, external_rxjs_namespaceObject.fromEvent)(
  4801. video,
  4802. "pause"
  4803. ).pipe((0, external_rxjs_namespaceObject.mapTo)(!1))
  4804. )).pipe(
  4805. (0, external_rxjs_namespaceObject.map)(
  4806. playing =>
  4807. playing || Option_isSome(live.offlineSlate.ele)
  4808. ),
  4809. (0, external_rxjs_namespaceObject.tap)(
  4810. chatPlaying => {
  4811. mainState.chatPlaying = chatPlaying
  4812. flowChats.forEach(chat =>
  4813. setChatPlayState(chat)(mainState)()
  4814. )
  4815. }
  4816. )
  4817. )
  4818. var video
  4819. }
  4820. )
  4821. ),
  4822. chatMutationPair.subject.pipe(
  4823. (0, external_rxjs_namespaceObject.map)(
  4824. onChatFieldMutate(
  4825. chatScreen,
  4826. flowChats,
  4827. mainState,
  4828. setConfig,
  4829. mainLog
  4830. )
  4831. ),
  4832. (0, external_rxjs_namespaceObject.tap)(x => x())
  4833. ),
  4834. documentMutationPair.subject.pipe(
  4835. (0, external_rxjs_namespaceObject.map)(
  4836. () => window.location.href
  4837. ),
  4838. (0, external_rxjs_namespaceObject.distinctUntilChanged)(),
  4839. (0, external_rxjs_namespaceObject.skip)(1),
  4840. (0, external_rxjs_namespaceObject.tap)(x => {
  4841. consoleLog("URL Changed", x)()
  4842. removeOldChats(flowChats, 0)
  4843. consoleLog("Wait for 1700ms...")()
  4844. }),
  4845. (0, external_rxjs_namespaceObject.delay)(1700),
  4846. (0, external_rxjs_namespaceObject.tap)(() =>
  4847. reinitialize()
  4848. )
  4849. ),
  4850. playerResizePair.subject.pipe(
  4851. (0, external_rxjs_namespaceObject.throttleTime)(
  4852. 500,
  4853. void 0,
  4854. { leading: !0, trailing: !0 }
  4855. ),
  4856. (0, external_rxjs_namespaceObject.startWith)([]),
  4857. (0, external_rxjs_namespaceObject.map)(
  4858. () => live.player.ele
  4859. ),
  4860. (0, external_rxjs_namespaceObject.map)(
  4861. es6_Option_map(x => x.getBoundingClientRect())
  4862. ),
  4863. (0, external_rxjs_namespaceObject.tap)(x =>
  4864. ((rect, flowChats, mainState, mainLog) =>
  4865. function_pipe(
  4866. rect,
  4867. match(
  4868. () => () => {},
  4869. x => () => {
  4870. mainLog("Resize detected")
  4871. mainState.playerRect = x
  4872. flowChats.forEach(chat => {
  4873. renderChat(chat)(mainState)()
  4874. setChatAnimation(chat, flowChats)(mainState)()
  4875. })
  4876. }
  4877. )
  4878. )())(x, flowChats, mainState, mainLog)
  4879. )
  4880. )
  4881. )
  4882. ),
  4883. (0, external_rxjs_namespaceObject.retryWhen)(e =>
  4884. e.pipe(
  4885. (0, external_rxjs_namespaceObject.tap)(
  4886. consoleLog("Errored", e)
  4887. ),
  4888. (0, external_rxjs_namespaceObject.delay)(5e3),
  4889. (0, external_rxjs_namespaceObject.tap)(x => {
  4890. consoleLog(x)()
  4891. reinitialize()
  4892. })
  4893. )
  4894. )
  4895. )
  4896. .subscribe({
  4897. error: x => consoleLog("Stream error", x)(),
  4898. complete: consoleLog("Stream complete"),
  4899. })
  4900. reinitialize()
  4901. }
  4902. ;(async () => {
  4903. external_log_namespaceObject.setLevel("info")
  4904. try {
  4905. await initialize()
  4906. } catch (error) {
  4907. external_log_namespaceObject.info("【FYC】 Error", error)
  4908. }
  4909. })()
  4910. },
  4911. 633: () => {},
  4912. },
  4913. __webpack_module_cache__ = {}
  4914. function __webpack_require__(moduleId) {
  4915. var cachedModule = __webpack_module_cache__[moduleId]
  4916. if (void 0 !== cachedModule) return cachedModule.exports
  4917. var module = (__webpack_module_cache__[moduleId] = { exports: {} })
  4918. __webpack_modules__[moduleId](module, module.exports, __webpack_require__)
  4919. return module.exports
  4920. }
  4921. __webpack_require__.n = module => {
  4922. var getter =
  4923. module && module.__esModule ? () => module.default : () => module
  4924. __webpack_require__.d(getter, { a: getter })
  4925. return getter
  4926. }
  4927. __webpack_require__.d = (exports, definition) => {
  4928. for (var key in definition)
  4929. __webpack_require__.o(definition, key) &&
  4930. !__webpack_require__.o(exports, key) &&
  4931. Object.defineProperty(exports, key, {
  4932. enumerable: !0,
  4933. get: definition[key],
  4934. })
  4935. }
  4936. __webpack_require__.o = (obj, prop) =>
  4937. Object.prototype.hasOwnProperty.call(obj, prop)
  4938. __webpack_require__(844)
  4939. })()