{"ScriptPreparationCode":"var text = \u0060Garena Free Fire\r\n\r\n\uD83D\uDCF1 Sobrevive al mejor Battle Royale dise\u00F1ado para m\u00F3viles.\r\n\uD83E\uDE82 50 jugadores caen en paraca\u00EDdas en un mapa donde deber\u00E1n enfrentarse para ser el \u00FAltimo en pie.\r\n\uD83D\uDC49 Disponible para Android, iOS y para PC y Mac con emulador.\r\n\r\n#FreeFire\r\n\r\nhttps://img.snibits.com/HYCVDi4.jpg\u0060","TestCases":[{"Name":"Original","Code":"const parse = (snippet) =\u003E {\r\n const isImage = (word) =\u003E {\r\n const pattern = /https:\\/\\/img\\.snibits\\.com\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isUrl = (word) =\u003E {\r\n const pattern = /https:\\/\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isTag = (word) =\u003E {\r\n const pattern = /#\\w/\r\n return word.match(pattern)\r\n }\r\n const isSpace = (word) =\u003E {\r\n const pattern = /https:\\/\\/snibits\\.com\\/space\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isYoutube = (word) =\u003E word.match(/https:\\/\\/youtu.be\\/\\w/)\r\n\r\n const getCleanedContent = (text) =\u003E {\r\n let imageCount = 0\r\n let url = null\r\n let content = text\r\n .split(\u0027\\n\u0027)\r\n .map((line) =\u003E\r\n line\r\n .split(/\\s/)\r\n .filter((word) =\u003E {\r\n if (isImage(word)) {\r\n imageCount\u002B\u002B\r\n }\r\n return !isImage(word) || imageCount \u003E 4\r\n })\r\n .join(\u0027 \u0027)\r\n )\r\n .join(\u0027\\n\u0027)\r\n .trim()\r\n let words = content.split(/\\s/)\r\n if (words.length \u003E 0) {\r\n const lastWord = words[words.length - 1]\r\n if ((isUrl(lastWord) \u0026\u0026 imageCount === 0) || isSpace(lastWord)) {\r\n const lines = content.split(\u0027\\n\u0027)\r\n let lastLine = lines[lines.length - 1].split(/\\s/)\r\n url = lastLine.pop()\r\n lines[lines.length - 1] = lastLine.join(\u0027 \u0027)\r\n content = lines.join(\u0027\\n\u0027).trim()\r\n }\r\n }\r\n return [content, url]\r\n }\r\n const [cleanedContent, url] = getCleanedContent(snippet.text)\r\n\r\n const getName = (snippet) =\u003E {\r\n let lines = cleanedContent.split(\u0027\\n\u0027)\r\n if (lines.length \u003E 0) {\r\n const line = lines[0].trim()\r\n if (line.length \u003C= 60 \u0026\u0026 ![\u0027.\u0027, \u0027:\u0027].includes(line[line.length - 1])) {\r\n return line\r\n }\r\n }\r\n return \u0027\u0027\r\n }\r\n const name = getName(snippet)\r\n\r\n const getTitle = (snippet) =\u003E {\r\n const limit = 60\r\n if (name) {\r\n return name\r\n }\r\n\r\n if (cleanedContent) {\r\n let title = cleanedContent.split(\u0027\\n\u0027)[0]\r\n if (title.length \u003E limit) {\r\n title = \u0060${title.substring(0, limit - 1)}\u2026\u0060\r\n }\r\n return title\r\n }\r\n\r\n return \u0027\u0027\r\n }\r\n const title = getTitle(snippet)\r\n\r\n const getImages = (snippet) =\u003E {\r\n return snippet.text\r\n .split(/\\s/)\r\n .filter((word) =\u003E isImage(word))\r\n .slice(0, 4)\r\n }\r\n const images = getImages(snippet)\r\n\r\n const getTags = (snippet) =\u003E {\r\n return snippet.text.split(/\\s/).filter((word) =\u003E isTag(word))\r\n }\r\n const tags = getTags(snippet)\r\n\r\n const getHtml = (snippet) =\u003E {\r\n const content = cleanedContent.replace(name, \u0027\u0027).trim()\r\n const limit = 27\r\n\r\n const parseWord = (word) =\u003E {\r\n if (isUrl(word)) {\r\n const url = word\r\n let displayUrl = word.replace(\u0027https://\u0027, \u0027\u0027)\r\n if (displayUrl.length \u003E limit) {\r\n displayUrl = \u0060${displayUrl.substring(0, limit - 1)}\u2026\u0060\r\n }\r\n return \u0060\u003Ca href=\u0022${url}\u0022 target=\u0022_blank\u0022 rel=\u0022nofollow\u0022 class=\u0022content-link\u0022\u003E${displayUrl}\u003C/a\u003E\u0060\r\n } else if (isTag(word)) {\r\n const tag = word.replace(\u0027#\u0027, \u0027\u0027)\r\n return \u0060\u003Ca href=\u0022/tag/${tag}\u0022\u003E#${tag}\u003C/a\u003E\u0060\r\n }\r\n return word\r\n }\r\n\r\n const parseLine = (line) =\u003E {\r\n const parsedLine = line.split(/\\s/).map((word) =\u003E parseWord(word))\r\n return parsedLine.join(\u0027 \u0027)\r\n }\r\n\r\n const lines = content.split(\u0027\\n\u0027)\r\n let parsedLines = lines.map((line) =\u003E parseLine(line))\r\n return parsedLines.join(\u0027\\n\u0027).trim()\r\n }\r\n const html = getHtml(snippet)\r\n\r\n const getCount = (snippet) =\u003E {\r\n const limit = 27\r\n const content = cleanedContent.replace(name, \u0027\u0027).trim()\r\n const lines = content.split(\u0027\\n\u0027)\r\n const parsedContent = lines\r\n .map((line) =\u003E\r\n line\r\n .split(/\\s/)\r\n .map((word) =\u003E {\r\n if (isUrl(word) || isImage(word)) {\r\n return \u0027x\u0027.repeat(limit)\r\n }\r\n return word\r\n })\r\n .join(\u0027 \u0027)\r\n )\r\n .join(\u0027\\n\u0027)\r\n\r\n return [...name].length \u002B [...parsedContent].length \u002B images.length * limit \u002B (url ? limit : 0)\r\n }\r\n const count = getCount(snippet)\r\n\r\n return { name, title, images, html, count, url, tags }\r\n}\r\n\r\n\r\nparse({text})","IsDeferred":false},{"Name":"Improved","Code":"const parse = (snippet) =\u003E {\r\n const isImage = (word) =\u003E {\r\n const pattern = /https:\\/\\/img\\.snibits\\.com\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isUrl = (word) =\u003E {\r\n const pattern = /https:\\/\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isTag = (word) =\u003E {\r\n const pattern = /#\\w/\r\n return word.match(pattern)\r\n }\r\n const isSpace = (word) =\u003E {\r\n const pattern = /https:\\/\\/snibits\\.com\\/space\\/\\w/\r\n return word.match(pattern)\r\n }\r\n const isYoutube = (word) =\u003E word.match(/https:\\/\\/youtu.be\\/\\w/)\r\n\r\n const getCleanedContent = (text) =\u003E {\r\n let imageCount = 0\r\n let url = null\r\n let content = text\r\n .split(\u0027\\n\u0027)\r\n .map((line) =\u003E\r\n line\r\n .split(/\\s/)\r\n .filter((word) =\u003E {\r\n if (isImage(word)) {\r\n imageCount\u002B\u002B\r\n }\r\n return !isImage(word) || imageCount \u003E 4\r\n })\r\n .join(\u0027 \u0027)\r\n )\r\n .join(\u0027\\n\u0027)\r\n .trim()\r\n let words = content.split(/\\s/)\r\n if (words.length \u003E 0) {\r\n const lastWord = words[words.length - 1]\r\n if ((isUrl(lastWord) \u0026\u0026 imageCount === 0) || isSpace(lastWord)) {\r\n const lines = content.split(\u0027\\n\u0027)\r\n let lastLine = lines[lines.length - 1].split(/\\s/)\r\n url = lastLine.pop()\r\n lines[lines.length - 1] = lastLine.join(\u0027 \u0027)\r\n content = lines.join(\u0027\\n\u0027).trim()\r\n }\r\n }\r\n return [content, url]\r\n }\r\n const [cleanedContent, url] = getCleanedContent(snippet.text)\r\n\r\n const getName = (snippet) =\u003E {\r\n let lines = cleanedContent.split(\u0027\\n\u0027)\r\n if (lines.length \u003E 0) {\r\n const line = lines[0].trim()\r\n if (line.length \u003C= 60 \u0026\u0026 ![\u0027.\u0027, \u0027:\u0027].includes(line[line.length - 1])) {\r\n return line\r\n }\r\n }\r\n return \u0027\u0027\r\n }\r\n const name = getName(snippet)\r\n\r\n const getTitle = (snippet) =\u003E {\r\n const limit = 60\r\n if (name) {\r\n return name\r\n }\r\n\r\n if (cleanedContent) {\r\n let title = cleanedContent.split(\u0027\\n\u0027)[0]\r\n if (title.length \u003E limit) {\r\n title = \u0060${title.substring(0, limit - 1)}\u2026\u0060\r\n }\r\n return title\r\n }\r\n\r\n return \u0027\u0027\r\n }\r\n const title = getTitle(snippet)\r\n\r\n const getImages = (snippet) =\u003E {\r\n return snippet.text\r\n .split(/\\s/)\r\n .filter((word) =\u003E isImage(word))\r\n .slice(0, 4)\r\n }\r\n const images = getImages(snippet)\r\n\r\n const getTags = (snippet) =\u003E {\r\n return snippet.text.split(/\\s/).filter((word) =\u003E isTag(word))\r\n }\r\n const tags = getTags(snippet)\r\n\r\n const getHtml = (snippet) =\u003E {\r\n const content = cleanedContent.replace(name, \u0027\u0027).trim()\r\n const limit = 27\r\n\r\n const parseWord = (word) =\u003E {\r\n if (isUrl(word)) {\r\n const url = word\r\n let displayUrl = word.replace(\u0027https://\u0027, \u0027\u0027)\r\n if (displayUrl.length \u003E limit) {\r\n displayUrl = \u0060${displayUrl.substring(0, limit - 1)}\u2026\u0060\r\n }\r\n return \u0060\u003Ca href=\u0022${url}\u0022 target=\u0022_blank\u0022 rel=\u0022nofollow\u0022 class=\u0022content-link\u0022\u003E${displayUrl}\u003C/a\u003E\u0060\r\n } else if (isTag(word)) {\r\n const tag = word.replace(\u0027#\u0027, \u0027\u0027)\r\n return \u0060\u003Ca href=\u0022/tag/${tag}\u0022\u003E#${tag}\u003C/a\u003E\u0060\r\n }\r\n return word\r\n }\r\n\r\n const parseLine = (line) =\u003E {\r\n const parsedLine = line.split(/\\s/).map((word) =\u003E parseWord(word))\r\n return parsedLine.join(\u0027 \u0027)\r\n }\r\n\r\n const lines = content.split(\u0027\\n\u0027)\r\n let parsedLines = lines.map((line) =\u003E parseLine(line))\r\n return parsedLines.join(\u0027\\n\u0027).trim()\r\n }\r\n const html = getHtml(snippet)\r\n\r\n const getCount = (snippet) =\u003E {\r\n const limit = 27\r\n const content = cleanedContent.replace(name, \u0027\u0027).trim()\r\n const lines = content.split(\u0027\\n\u0027)\r\n const parsedContent = lines\r\n .map((line) =\u003E\r\n line\r\n .split(/\\s/)\r\n .map((word) =\u003E {\r\n if (isUrl(word) || isImage(word)) {\r\n return \u0027x\u0027.repeat(limit)\r\n }\r\n return word\r\n })\r\n .join(\u0027 \u0027)\r\n )\r\n .join(\u0027\\n\u0027)\r\n\r\n return [...name].length \u002B [...parsedContent].length \u002B images.length * limit \u002B (url ? limit : 0)\r\n }\r\n const count = getCount(snippet)\r\n\r\n return { name, title, images, html, count, url, tags }\r\n}\r\n\r\n\r\nparse({text})","IsDeferred":false}]}