// ==UserScript==
// @name Flow Youtube Chat
// @version 1.13.4
// @description Youtubeのチャットをニコニコ風に画面上へ流すスクリプトです(再アップ,絵文字バグ修正済み)
// @match https://www.youtube.com/*
// @namespace FlowYoutubeChatScript
// @run-at document-end
// @grant GM.setValue
// @grant GM.getValue
// @grant GM.deleteValue
// @grant GM.listValues
// @noframes
// @license AGPL-3.0-or-later
// @require https://cdn.jsdelivr.net/npm/sweetalert2@10.10.1/dist/sweetalert2.all.min.js#sha384-OCBhaEdUu7BFgaeRVey2PDeHof2MSQRFe/e6S8Q3XrmSV7wrKpLmhPj8FOldGiaF
// @require https://unpkg.com/loglevel@1.7.0/dist/loglevel.min.js#sha384-7gGuWfek8Ql6j/uNDFrS0BCe4x2ZihD4B68w9Eu580OVHJBV+bl3rZmEWC7q5/Gj
// @require https://unpkg.com/rxjs@7.0.0-beta.10/dist/bundles/rxjs.umd.min.js#sha384-+BwV2u+ZJFwj586/3PlpsZdYS1U/+hT/zpjYSznHH4XzUJqgshDzZITJ+zGeWl//
// @downloadURL none
// ==/UserScript==
/* jshint esversion: 6 */
;(() => {
var __webpack_modules__ = {
494: function (module, exports, __webpack_require__) {
var __WEBPACK_AMD_DEFINE_RESULT__
!(function (globals) {
"use strict"
var messages,
predicates,
functions,
assert,
not,
maybe,
collections,
hasOwnProperty,
toString,
keys,
slice,
isArray,
neginf,
posinf,
haveSymbols,
haveMaps,
haveSets
function assigned(data) {
return null != data
}
function number(data) {
return "number" == typeof data && data > neginf && data < posinf
}
function integer(data) {
return "number" == typeof data && data % 1 == 0
}
function greater(lhs, rhs) {
return number(lhs) && lhs > rhs
}
function less(lhs, rhs) {
return number(lhs) && lhs < rhs
}
function greaterOrEqual(lhs, rhs) {
return number(lhs) && lhs >= rhs
}
function lessOrEqual(lhs, rhs) {
return number(lhs) && lhs <= rhs
}
function string(data) {
return "string" == typeof data
}
function nonEmptyString(data) {
return string(data) && "" !== data
}
function object(data) {
return "[object Object]" === toString.call(data)
}
function some(data, predicate) {
for (var key in data)
if (hasOwnProperty.call(data, key) && predicate(key, data[key]))
return !0
return !1
}
function instanceStrict(data, prototype) {
try {
return data instanceof prototype
} catch (error) {
return !1
}
}
function like(data, archetype) {
var name
for (name in archetype)
if (hasOwnProperty.call(archetype, name)) {
if (
!1 === hasOwnProperty.call(data, name) ||
typeof data[name] != typeof archetype[name]
)
return !1
if (
object(data[name]) &&
!1 === like(data[name], archetype[name])
)
return !1
}
return !0
}
function arrayLike(data) {
return assigned(data) && data.length >= 0
}
function iterable(data) {
return haveSymbols
? assigned(data) && isFunction(data[Symbol.iterator])
: arrayLike(data)
}
function contains(data, value) {
var iterator, iteration
if (!assigned(data)) return !1
if (haveSets && instanceStrict(data, Set)) return data.has(value)
if (string(data)) return -1 !== data.indexOf(value)
if (
haveSymbols &&
data[Symbol.iterator] &&
isFunction(data.values)
) {
iterator = data.values()
do {
if ((iteration = iterator.next()).value === value) return !0
} while (!iteration.done)
return !1
}
return some(data, function (key, dataValue) {
return dataValue === value
})
}
function containsKey(data, key) {
return (
!!assigned(data) &&
(haveMaps && instanceStrict(data, Map)
? data.has(key)
: !(iterable(data) && !number(+key)) && !!data[key])
)
}
function isFunction(data) {
return "function" == typeof data
}
function forEach(object, action) {
for (var key in object)
hasOwnProperty.call(object, key) && action(key, object[key])
}
function testArray(data, result) {
var i
for (i = 0; i < data.length; i += 1)
if (data[i] === result) return result
return !result
}
function testObject(data, result) {
var key, value
for (key in data)
if (hasOwnProperty.call(data, key)) {
if (
object((value = data[key])) &&
testObject(value, result) === result
)
return result
if (value === result) return result
}
return !result
}
function mixin(target, source) {
return (
forEach(source, function (key, value) {
target[key] = value
}),
target
)
}
function assertModifier(predicate, defaultMessage) {
return function () {
var args = arguments,
argCount = predicate.l || predicate.length,
message = args[argCount],
ErrorType = args[argCount + 1]
return (
assertImpl(
predicate.apply(null, args),
nonEmptyString(message)
? message
: defaultMessage
.replace("{a}", messageFormatter(args[0]))
.replace("{e}", messageFormatter(args[1]))
.replace("{e2}", messageFormatter(args[2]))
.replace("{t}", function () {
var arg = args[1]
return arg && arg.name ? arg.name : arg
}),
isFunction(ErrorType) ? ErrorType : TypeError
),
args[0]
)
}
}
function messageFormatter(arg) {
return function () {
return string(arg)
? '"' + arg.replace(/\\/g, "\\\\").replace(/"/g, '\\"') + '"'
: arg &&
!0 !== arg &&
arg.constructor &&
!instanceStrict(arg, RegExp) &&
"number" != typeof arg
? arg.constructor.name
: arg
}
}
function assertImpl(value, message, ErrorType) {
if (value) return value
throw new (ErrorType || Error)(message || "assert failed")
}
function notModifier(predicate) {
var modifiedPredicate = function () {
return notImpl(predicate.apply(null, arguments))
}
return (modifiedPredicate.l = predicate.length), modifiedPredicate
}
function notImpl(value) {
return !value
}
function ofModifier(target, type, predicate) {
var modifiedPredicate = function () {
var collection, args
if (
((collection = arguments[0]),
"maybe" === target && not.assigned(collection))
)
return !0
if (!type(collection)) return !1
;(collection = coerceCollection(type, collection)),
(args = slice.call(arguments, 1))
try {
collection.forEach(function (item) {
if (
("maybe" !== target || assigned(item)) &&
!predicate.apply(null, [item].concat(args))
)
throw 0
})
} catch (ignore) {
return !1
}
return !0
}
return (modifiedPredicate.l = predicate.length), modifiedPredicate
}
function coerceCollection(type, collection) {
switch (type) {
case arrayLike:
return slice.call(collection)
case object:
return keys(collection).map(function (key) {
return collection[key]
})
default:
return collection
}
}
function createModifiedPredicates(modifier, object) {
return createModifiedFunctions([modifier, predicates, object, ""])
}
function createModifiedFunctions(args) {
var modifier, messageModifier, object
return (
(modifier = args.shift()),
(messageModifier = args.pop()),
(object = args.pop()),
forEach(args.pop(), function (key, fn) {
var message = messages[key]
message &&
messageModifier &&
(message = message.replace("to", messageModifier + "to")),
Object.defineProperty(object, key, {
configurable: !1,
enumerable: !0,
writable: !1,
value: modifier.apply(null, args.concat(fn, message)),
})
}),
object
)
}
function createModifiedModifier(modifier, modified, messageModifier) {
return createModifiedFunctions([
modifier,
modified,
{},
messageModifier,
])
}
function createOfModifiers(base, modifier) {
collections.forEach(function (key) {
base[key].of = createModifiedModifier(
modifier,
predicates[key].of
)
})
}
;(messages = {}),
(predicates = {}),
[
{
n: "equal",
f: function (lhs, rhs) {
return lhs === rhs
},
s: "equal {e}",
},
{
n: "undefined",
f: function (data) {
return void 0 === data
},
s: "be undefined",
},
{
n: "null",
f: function (data) {
return null === data
},
s: "be null",
},
{ n: "assigned", f: assigned, s: "be assigned" },
{
n: "primitive",
f: function (data) {
var type
switch (data) {
case null:
case void 0:
case !1:
case !0:
return !0
}
return (
"string" === (type = typeof data) ||
"number" === type ||
(haveSymbols && "symbol" === type)
)
},
s: "be primitive type",
},
{ n: "contains", f: contains, s: "contain {e}" },
{
n: "in",
f: function (value, data) {
return contains(data, value)
},
s: "be in {e}",
},
{ n: "containsKey", f: containsKey, s: "contain key {e}" },
{
n: "keyIn",
f: function (key, data) {
return containsKey(data, key)
},
s: "be key in {e}",
},
{
n: "zero",
f: function (data) {
return 0 === data
},
s: "be 0",
},
{
n: "one",
f: function (data) {
return 1 === data
},
s: "be 1",
},
{
n: "infinity",
f: function (data) {
return data === neginf || data === posinf
},
s: "be infinity",
},
{ n: "number", f: number, s: "be Number" },
{ n: "integer", f: integer, s: "be integer" },
{
n: "float",
f: function (data) {
return number(data) && data % 1 != 0
},
s: "be non-integer number",
},
{
n: "even",
f: function (data) {
return "number" == typeof data && data % 2 == 0
},
s: "be even number",
},
{
n: "odd",
f: function (data) {
return integer(data) && data % 2 != 0
},
s: "be odd number",
},
{ n: "greater", f: greater, s: "be greater than {e}" },
{ n: "less", f: less, s: "be less than {e}" },
{
n: "between",
f: function (data, x, y) {
if (x < y) return greater(data, x) && data < y
return less(data, x) && data > y
},
s: "be between {e} and {e2}",
},
{
n: "greaterOrEqual",
f: greaterOrEqual,
s: "be greater than or equal to {e}",
},
{
n: "lessOrEqual",
f: lessOrEqual,
s: "be less than or equal to {e}",
},
{
n: "inRange",
f: function (data, x, y) {
if (x < y) return greaterOrEqual(data, x) && data <= y
return lessOrEqual(data, x) && data >= y
},
s: "be in the range {e} to {e2}",
},
{
n: "positive",
f: function (data) {
return greater(data, 0)
},
s: "be positive number",
},
{
n: "negative",
f: function (data) {
return less(data, 0)
},
s: "be negative number",
},
{ n: "string", f: string, s: "be String" },
{
n: "emptyString",
f: function (data) {
return "" === data
},
s: "be empty string",
},
{
n: "nonEmptyString",
f: nonEmptyString,
s: "be non-empty string",
},
{
n: "match",
f: function (data, regex) {
return string(data) && !!data.match(regex)
},
s: "match {e}",
},
{
n: "boolean",
f: function (data) {
return !1 === data || !0 === data
},
s: "be Boolean",
},
{ n: "object", f: object, s: "be Object" },
{
n: "emptyObject",
f: function (data) {
return (
object(data) &&
!some(data, function () {
return !0
})
)
},
s: "be empty object",
},
{
n: "nonEmptyObject",
f: function (data) {
return (
object(data) &&
some(data, function () {
return !0
})
)
},
s: "be non-empty object",
},
{
n: "instanceStrict",
f: instanceStrict,
s: "be instanceof {t}",
},
{
n: "thenable",
f: function (data) {
return assigned(data) && isFunction(data.then)
},
s: "be promise-like",
},
{
n: "instance",
f: function (data, prototype) {
try {
return (
instanceStrict(data, prototype) ||
data.constructor.name === prototype.name ||
toString.call(data) === "[object " + prototype.name + "]"
)
} catch (error) {
return !1
}
},
s: "be {t}",
},
{ n: "like", f: like, s: "be like {e}" },
{
n: "array",
f: function (data) {
return isArray(data)
},
s: "be Array",
},
{
n: "emptyArray",
f: function (data) {
return isArray(data) && 0 === data.length
},
s: "be empty array",
},
{
n: "nonEmptyArray",
f: function (data) {
return isArray(data) && data.length > 0
},
s: "be non-empty array",
},
{ n: "arrayLike", f: arrayLike, s: "be array-like" },
{ n: "iterable", f: iterable, s: "be iterable" },
{
n: "date",
f: function (data) {
return instanceStrict(data, Date) && integer(data.getTime())
},
s: "be valid Date",
},
{ n: "function", f: isFunction, s: "be Function" },
{
n: "hasLength",
f: function (data, length) {
return assigned(data) && data.length === length
},
s: "have length {e}",
},
{
n: "throws",
f: function (data) {
if (!isFunction(data)) return !1
try {
data()
} catch (error) {
return !0
}
return !1
},
s: "throw",
},
].map(function (data) {
var n = data.n
;(messages[n] = "assert failed: expected {a} to " + data.s),
(predicates[n] = data.f)
}),
(functions = {
map: function map(data, predicates) {
var result
result = isArray(data) ? [] : {}
if (isFunction(predicates))
forEach(data, function (key, value) {
result[key] = predicates(value)
})
else {
isArray(predicates) || assert.object(predicates)
var dataKeys = keys(data || {})
forEach(predicates, function (key, predicate) {
dataKeys.some(function (dataKey, index) {
return dataKey === key && (dataKeys.splice(index, 1), !0)
}),
isFunction(predicate)
? not.assigned(data)
? (result[key] = !!predicate.m)
: (result[key] = predicate(data[key]))
: (result[key] = map(data[key], predicate))
})
}
return result
},
all: function (data) {
if (isArray(data)) return testArray(data, !1)
return assert.object(data), testObject(data, !1)
},
any: function (data) {
if (isArray(data)) return testArray(data, !0)
return assert.object(data), testObject(data, !0)
},
}),
(collections = ["array", "arrayLike", "iterable", "object"]),
(hasOwnProperty = Object.prototype.hasOwnProperty),
(toString = Object.prototype.toString),
(keys = Object.keys),
(slice = Array.prototype.slice),
(isArray = Array.isArray),
(neginf = Number.NEGATIVE_INFINITY),
(posinf = Number.POSITIVE_INFINITY),
(haveSymbols = "function" == typeof Symbol),
(haveMaps = "function" == typeof Map),
(haveSets = "function" == typeof Set),
(functions = mixin(functions, predicates)),
(assert = createModifiedPredicates(assertModifier, assertImpl)),
(not = createModifiedPredicates(notModifier, notImpl)),
(maybe = createModifiedPredicates(
function (predicate) {
var modifiedPredicate = function () {
return (
!!not.assigned(arguments[0]) ||
predicate.apply(null, arguments)
)
}
return (
(modifiedPredicate.l = predicate.length),
(modifiedPredicate.m = !0),
modifiedPredicate
)
},
function (value) {
if (!1 === assigned(value)) return !0
return value
}
)),
(assert.not = createModifiedModifier(assertModifier, not, "not ")),
(assert.maybe = createModifiedModifier(
assertModifier,
maybe,
"maybe "
)),
collections.forEach(function (key) {
predicates[key].of = createModifiedFunctions([
ofModifier.bind(null, null),
predicates[key],
predicates,
{},
"",
])
}),
createOfModifiers(assert, assertModifier),
createOfModifiers(not, notModifier),
collections.forEach(function (key) {
;(maybe[key].of = createModifiedFunctions([
ofModifier.bind(null, "maybe"),
predicates[key],
predicates,
{},
"",
])),
(assert.maybe[key].of = createModifiedModifier(
assertModifier,
maybe[key].of
)),
(assert.not[key].of = createModifiedModifier(
assertModifier,
not[key].of
))
}),
(function (functions) {
void 0 ===
(__WEBPACK_AMD_DEFINE_RESULT__ = function () {
return functions
}.call(exports, __webpack_require__, exports, module)) ||
(module.exports = __WEBPACK_AMD_DEFINE_RESULT__)
})(mixin(functions, { assert, not, maybe }))
})()
},
228: module => {
"use strict"
const createAbortError = () => {
const error = new Error("Delay aborted")
return (error.name = "AbortError"), error
},
createDelay = ({
clearTimeout: defaultClear,
setTimeout: set,
willResolve,
}) => (ms, { value, signal } = {}) => {
if (signal && signal.aborted)
return Promise.reject(createAbortError())
let timeoutId, settle, rejectFn
const clear = defaultClear || clearTimeout,
signalListener = () => {
clear(timeoutId), rejectFn(createAbortError())
},
delayPromise = new Promise((resolve, reject) => {
;(settle = () => {
signal && signal.removeEventListener("abort", signalListener),
willResolve ? resolve(value) : reject(value)
}),
(rejectFn = reject),
(timeoutId = (set || setTimeout)(settle, ms))
})
return (
signal &&
signal.addEventListener("abort", signalListener, { once: !0 }),
(delayPromise.clear = () => {
clear(timeoutId), (timeoutId = null), settle()
}),
delayPromise
)
},
delay = createDelay({ willResolve: !0 })
;(delay.reject = createDelay({ willResolve: !1 })),
(delay.range = (minimum, maximum, options) =>
delay(
((minimum, maximum) =>
Math.floor(Math.random() * (maximum - minimum + 1) + minimum))(
minimum,
maximum
),
options
)),
(delay.createWithTimers = ({ clearTimeout, setTimeout }) => {
const delay = createDelay({
clearTimeout,
setTimeout,
willResolve: !0,
})
return (
(delay.reject = createDelay({
clearTimeout,
setTimeout,
willResolve: !1,
})),
delay
)
}),
(module.exports = delay),
(module.exports.default = delay)
},
},
__webpack_module_cache__ = {}
function __webpack_require__(moduleId) {
if (__webpack_module_cache__[moduleId])
return __webpack_module_cache__[moduleId].exports
var module = (__webpack_module_cache__[moduleId] = { exports: {} })
return (
__webpack_modules__[moduleId].call(
module.exports,
module,
module.exports,
__webpack_require__
),
module.exports
)
}
;(__webpack_require__.n = module => {
var getter =
module && module.__esModule ? () => module.default : () => module
return __webpack_require__.d(getter, { a: getter }), getter
}),
(__webpack_require__.d = (exports, definition) => {
for (var key in definition)
__webpack_require__.o(definition, key) &&
!__webpack_require__.o(exports, key) &&
Object.defineProperty(exports, key, {
enumerable: !0,
get: definition[key],
})
}),
(__webpack_require__.o = (obj, prop) =>
Object.prototype.hasOwnProperty.call(obj, prop)),
(() => {
"use strict"
const external_log_namespaceObject = log
var external_log_default = __webpack_require__.n(
external_log_namespaceObject
)
const external_rxjs_namespaceObject = rxjs,
external_rxjs_operators_namespaceObject = rxjs.operators,
livePage_getPlayer = () => {
var _a
return null !== (_a = document.querySelector("#movie_player")) &&
void 0 !== _a
? _a
: void 0
},
livePage_getMainVideo = () => {
var _a
return null !==
(_a = document.querySelector(
"video.video-stream.html5-main-video"
)) && void 0 !== _a
? _a
: void 0
},
livePage_getChatFrame = () => {
var _a
return null !== (_a = document.querySelector("#chatframe")) &&
void 0 !== _a
? _a
: void 0
},
livePage_getChatField = () => {
var _a, _b, _c
return null !==
(_c = (null !==
(_b =
null === (_a = document.querySelector("#chatframe")) ||
void 0 === _a
? void 0
: _a.contentDocument) && void 0 !== _b
? _b
: document
).querySelector(
"#items.style-scope.yt-live-chat-item-list-renderer"
)) && void 0 !== _c
? _c
: void 0
}
const assert_lib = __webpack_require__(494).assert,
tapIs = (constructor, x) => (assert_lib(x instanceof constructor), x),
changeChatAnimState = playing => {
var _a
tapIs(
CSSStyleRule,
null ===
(_a = document.styleSheets.item(
document.styleSheets.length - 1
)) || void 0 === _a
? void 0
: _a.cssRules.item(0)
).style.animationPlayState = playing ? "running" : "paused"
},
checkBannedRegexpWords = (chatData, userConfig) =>
userConfig.ngRegWords.some(word => {
const result = chatData.html.match(word)
return (
!!result &&
(external_log_default().debug(
`Banned Word: "${result}" in "${chatData.html}"`
),
!0)
)
}),
checkBannedUsers = (chatData, userConfig) =>
Boolean(chatData.authorID) &&
userConfig.ngUsers.some(user => {
var _a
const result =
null === (_a = chatData.authorID) || void 0 === _a
? void 0
: _a.match(user)
return (
!!result &&
(external_log_default().debug(
`Banned User: "${result}" in "${chatData.html}"`
),
!0)
)
}),
checkBannedWords = (chatData, userConfig) =>
userConfig.ngWords.some(
word =>
!!chatData.html.includes(word) &&
(external_log_default().debug(
`Banned Word: "${word}" in "${chatData.html}"`
),
!0)
),
tapNonNull = x => (assert_lib(null != x), x),
parseMessage = (lengthBefore, message, userConfig) => {
const { maxLength } = userConfig
let html = "",
length = lengthBefore
return (
message.innerHTML.split(//g).some(part => {
var _a, _b
if (
part.match(
["emoji", "yt-formatted-string", "style-scope"].join(" ")
)
) {
const src = part.match(/src="(\\.|[^"\\])*"/g),
size =
Math.round(
(userConfig.size - 0.2) *
((null !==
(_b =
null === (_a = livePage_getMainVideo()) ||
void 0 === _a
? void 0
: _a.clientHeight) && void 0 !== _b
? _b
: 0) /
userConfig.laneNum) *
100
) / 100
;(html += `
`), (length += 1)
} else
(html +=
part.length >= maxLength ? part.substr(0, maxLength) : part),
(length += part.length)
return length >= maxLength
}),
{ html, length }
)
},
convertChat = (chat, userConfig) => {
let html = "",
length = 0
const isMember = Boolean(chat.querySelector(".member"))
let authorID
const color = chat.querySelector(".owner")
? userConfig.colorOwner
: chat.querySelector(".moderator")
? userConfig.colorModerator
: isMember
? userConfig.colorMember
: userConfig.color
return (
Array.from(chat.children).forEach(child => {
var _a, _b, _c, _d, _e
const childID = child.id,
message = child.querySelector("#message")
if (
"content" === childID &&
(chat.querySelector(".moderator") &&
!0 === userConfig.displayModeratorName &&
(html += `${
null === (_a = child.querySelector("#author-name")) ||
void 0 === _a
? void 0
: _a.innerText
}: `),
message)
) {
const result = parseMessage(length, message, userConfig)
;(html += result.html), (length += result.length)
}
if ("author-photo" === childID) {
const matches = (
(null === (_b = child.lastElementChild) || void 0 === _b
? void 0
: _b.getAttribute("src")) || ""
).match(/ytc\/(.*)=/)
authorID =
null == matches ? void 0 : matches[matches.length - 1]
}
if ("card" === childID) {
const authorName = child.querySelector("#author-name"),
paidAmount =
child.querySelector("#purchase-amount") ||
child.querySelector("#purchase-amount-chip")
if (
child.className ===
["style-scope", "yt-live-chat-paid-message-renderer"].join(
" "
)
) {
const header = tapNonNull(child.querySelector("#header")),
content = child.querySelector("#content"),
headerColor = window
.getComputedStyle(header)
.getPropertyValue("background-color"),
paidColor = window
.getComputedStyle(content)
.getPropertyValue("background-color")
if (message) {
const result = parseMessage(length, message, userConfig)
;(html += `${
null == authorName ? void 0 : authorName.innerText
}: ${
result.html
}${
null == paidAmount ? void 0 : paidAmount.innerText
}`),
(length +=
result.length +
(null !==
(_c =
null == paidAmount
? void 0
: paidAmount.innerText.length) && void 0 !== _c
? _c
: 0))
}
authorID = void 0
}
if (
child.className ===
["style-scope", "yt-live-chat-paid-sticker-renderer"].join(
" "
)
) {
const headerColor = window
.getComputedStyle(chat)
.getPropertyValue(
"--yt-live-chat-paid-sticker-chip-background-color"
),
amountColor = window
.getComputedStyle(chat)
.getPropertyValue(
"--yt-live-chat-paid-sticker-background-color"
)
;(html += `${
null == authorName ? void 0 : authorName.innerText
}: `),
(html += `${
null == paidAmount ? void 0 : paidAmount.innerText
}`),
(length +=
null !==
(_e =
null ===
(_d =
null == paidAmount
? void 0
: paidAmount.innerText) || void 0 === _d
? void 0
: _d.length) && void 0 !== _e
? _e
: 0),
(authorID = void 0)
}
}
}),
{ html, length, color, isMine: !1, isMember, authorID }
)
},
getFlowingChats = () => document.querySelectorAll(".fyc_chat"),
createChat = (chatData, userConfig) => {
var _a, _b, _c
const screenHeight =
null !==
(_b =
null === (_a = livePage_getMainVideo()) || void 0 === _a
? void 0
: _a.clientHeight) && void 0 !== _b
? _b
: 0,
chatHTML = chatData.html,
chatLength = chatData.length,
chatColor = chatData.color,
chatIsMine = chatData.isMine,
chatSize =
Math.round(
(userConfig.size - 0.2) *
(screenHeight / userConfig.laneNum) *
100
) / 100,
chatSpeed = ((length, userConfig) =>
(720 / (Math.min(length, userConfig.maxLength) + 30)) *
(20 / userConfig.speed))(chatLength, userConfig),
chatLaneNum = ((chatData, userConfig) => {
var _a, _b
const screenWidth =
null !==
(_b =
null === (_a = livePage_getPlayer()) || void 0 === _a
? void 0
: _a.clientWidth) && void 0 !== _b
? _b
: 0,
chats = getFlowingChats(),
latestChatLength = chatData.length,
acceptableLane = new Array(2 * userConfig.laneNum - 1).fill(!0)
for (let i = 0; i < chats.length; i += 1) {
const chat = chats[i],
chatLane = Number.parseInt(
tapNonNull(chat.getAttribute("data-lane")),
10
),
rect = chat.getBoundingClientRect(),
chatX = rect.x + rect.width,
chatLength = chat.innerText.length,
chatBoxAdjustment =
(latestChatLength - chatLength >= 3 &&
chatX > 0.8 * screenWidth) ||
(latestChatLength - chatLength >= 10 &&
chatX > 0.4 * screenWidth)
? screenWidth - chatX + 70
: 0
acceptableLane[chatLane] &&
(acceptableLane[chatLane] = !(
chatX + chatBoxAdjustment >
screenWidth
))
}
let resultLaneNum = 0,
i = 0
for (; 0 === resultLaneNum; ) {
if (1 == acceptableLane[i]) {
;(resultLaneNum = i), (i = 0)
break
}
if (i > 3 * userConfig.laneNum - 1) {
;(resultLaneNum = 0), (i = 0)
break
}
0 == acceptableLane[i] && (resultLaneNum = 0), (i += 1)
}
return resultLaneNum
})(chatData, userConfig)
let html = ""
if (
((html += `${chatHTML}`),
document.querySelector(".fyc_chat_usable"))
) {
const element = document.querySelectorAll(".fyc_chat_usable")
element[element.length - 1].outerHTML = html
} else
external_log_default().debug("AppendChat"),
null === (_c = document.getElementById("fyc_chat_screen")) ||
void 0 === _c ||
_c.insertAdjacentHTML("beforeend", html)
},
external_Swal_namespaceObject = Swal
var external_Swal_default = __webpack_require__.n(
external_Swal_namespaceObject
)
const defaultToast = () =>
external_Swal_default().mixin({
toast: !0,
position: "bottom-left",
timer: 2500,
timerProgressBar: !0,
showConfirmButton: !1,
didOpen: toast => {
toast.addEventListener(
"mouseenter",
external_Swal_default().stopTimer
),
toast.addEventListener(
"mouseleave",
external_Swal_default().resumeTimer
)
},
}),
logFyc = (...x) => external_log_default().info(`【FYC】 ${x}`),
createNgButton = (chat, id, userConfig) => {
var _a, _b, _c
if (
null === (_a = chat.children.namedItem("content")) || void 0 === _a
? void 0
: _a.children.namedItem("fyc_ngbutton")
)
return
if (chat.children.namedItem("card")) return
const button = document.createElement("button")
button.classList.add("style-scope", "yt-icon-button", "fyc_button"),
(button.id = "fyc_ngbutton"),
(button.style.padding = "0px"),
(button.style.width = "20px"),
(button.style.height = "20px"),
button.setAttribute("aria-label", "NGに入れる"),
(button.innerHTML =
'