import { backdropLink, celebrationsEmoji, checkbox, footerButtons, multiPagePopup, popup, popupWithBottomButtons, settingsCategory, switcher } from "./elements.js"; import { services as s, appName, authorInfo, version, quality, repo, donations, supportedAudio } from "../config.js"; import { getCommitInfo } from "../sub/currentCommit.js"; import loc from "../../localization/manager.js"; import emoji from "../emoji.js"; import changelogManager from "../changelog/changelogManager.js"; let com = getCommitInfo(); let enabledServices = Object.keys(s).filter((p) => { if (s[p].enabled) return true; }).sort().map((p) => { return s[p].alias ? s[p].alias : p }).join(', ') let donate = `` let donateLinks = `` let audioFormats = supportedAudio.map((p) => { return { "action": p } }) audioFormats.unshift({ "action": "best" }) for (let i in donations["other"]) { donateLinks += `${i}` } let extr = '' for (let i in donations["crypto"]) { donate += `
${i} (REPLACEME)
${donations["crypto"][i]}
` extr = ' top-margin' } export default function(obj) { audioFormats[0]["text"] = loc(obj.lang, 'SettingsAudioFormatBest'); let ua = obj.useragent.toLowerCase(); let isIOS = ua.match("iphone os"); let isMobile = ua.match("android") || ua.match("iphone os"); try { return ` ${appName} ${multiPagePopup({ name: "about", closeAria: loc(obj.lang, 'AccessibilityClosePopup'), tabs: [{ name: "about", title: `${emoji("🐲")} ${loc(obj.lang, 'AboutTab')}`, content: popup({ name: "about", header: { aboveTitle: { text: loc(obj.lang, 'MadeWithLove'), url: authorInfo.link }, closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: loc(obj.lang, 'TitlePopupAbout') }, body: [{ text: loc(obj.lang, 'AboutSummary') }, { text: `${loc(obj.lang, 'AboutSupportedServices')} ${enabledServices}.` }, { text: obj.lang !== "ru" ? loc(obj.lang, 'FollowTwitter') : "" }, { text: backdropLink(repo, loc(obj.lang, 'LinkGitHubIssues')), classes: ["bottom-link"] }] }) }, { name: "changelog", title: `${emoji("🎉")} ${loc(obj.lang, 'ChangelogTab')}`, content: popup({ name: "changelog", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: `${emoji("đŸĒ„", 30)} ${loc(obj.lang, 'TitlePopupChangelog')}` }, body: [{ text: `
${loc(obj.lang, 'ChangelogLastMajor')}
`, raw: true }, { text: changelogManager("banner") ? `
`: '', raw: true }, { text: changelogManager("title"), classes: ["changelog-subtitle"], nopadding: true }, { text: changelogManager("content") }, { text: `
${loc(obj.lang, 'ChangelogLastCommit')}
`, raw: true }, { text: `${com[0]} (${obj.hash})`, classes: ["changelog-subtitle"], nopadding: true }, { text: com[1] }, { text: backdropLink(`${repo}/commits`, loc(obj.lang, 'LinkGitHubChanges')), classes: ["bottom-link"] }, { text: `
${loc(obj.lang, 'ChangelogOlder')}
`, raw: true }, { text: `
`, raw: true }] }) }, { name: "donate", title: `${emoji("💰")} ${loc(obj.lang, 'DonationsTab')}`, content: popup({ name: "donate", header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: emoji("💸", 30) + loc(obj.lang, 'TitlePopupDonate'), subtitle: loc(obj.lang, 'DonateSubtitle') }, body: [{ text: donateLinks, raw: true }, { text: loc(obj.lang, 'DonateLinksDescription'), classes: ["explanation"] }, { text: donate.replace(/REPLACEME/g, loc(obj.lang, 'ClickToCopy')) }, { text: loc(obj.lang, 'DonateDescription'), classes: ["explanation", "no-top-padding"] }, { text: backdropLink(authorInfo.contact, loc(obj.lang, 'LinkDonateContact')), classes: ["bottom-link"] }] }) }], })} ${multiPagePopup({ name: "settings", closeAria: loc(obj.lang, 'AccessibilityClosePopup'), header: { aboveTitle: { text: `v.${version} ~ ${obj.hash}`, url: `${repo}/commit/${obj.hash}` }, title: `${emoji("⚙ī¸", 30)} ${loc(obj.lang, 'TitlePopupSettings')}` }, tabs: [{ name: "video", title: `${emoji("đŸŽŦ")} ${loc(obj.lang, 'SettingsVideoTab')}`, content: settingsCategory({ name: "downloads", title: loc(obj.lang, 'SettingsDownloadsSubtitle'), body: switcher({ name: "vQuality", subtitle: loc(obj.lang, 'SettingsQualitySubtitle'), explanation: loc(obj.lang, 'SettingsQualityDescription'), items: [{ "action": "max", "text": `${loc(obj.lang, 'SettingsQualitySwitchMax')}
(2160p+)` }, { "action": "hig", "text": `${loc(obj.lang, 'SettingsQualitySwitchHigh')}
(${quality.hig}p)` }, { "action": "mid", "text": `${loc(obj.lang, 'SettingsQualitySwitchMedium')}
(${quality.mid}p)` }, { "action": "low", "text": `${loc(obj.lang, 'SettingsQualitySwitchLow')}
(${quality.low}p)` }] }) }) + `${!isIOS ? checkbox("downloadPopup", loc(obj.lang, 'SettingsEnableDownloadPopup'), loc(obj.lang, 'AccessibilityEnableDownloadPopup'), 1) : ''}` + settingsCategory({ name: "youtube", body: switcher({ name: "vFormat", subtitle: loc(obj.lang, 'SettingsFormatSubtitle'), explanation: loc(obj.lang, 'SettingsFormatDescription'), items: [{ "action": "mp4", "text": "mp4 (av1)" }, { "action": "webm", "text": "webm (vp9)" }] }) }) + settingsCategory({ name: "tiktok", title: "tiktok & douyin", body: checkbox("disableTikTokWatermark", loc(obj.lang, 'SettingsRemoveWatermark')) }) }, { name: "audio", title: `${emoji("đŸŽļ")} ${loc(obj.lang, 'SettingsAudioTab')}`, content: settingsCategory({ name: "general", title: loc(obj.lang, 'SettingsAudioTab'), body: switcher({ name: "aFormat", subtitle: loc(obj.lang, 'SettingsFormatSubtitle'), explanation: loc(obj.lang, 'SettingsAudioFormatDescription'), items: audioFormats }) }) + settingsCategory({ name: "tiktok", title: "tiktok & douyin", body: checkbox("fullTikTokAudio", loc(obj.lang, 'SettingsAudioFullTikTok'), loc(obj.lang, 'SettingsAudioFullTikTok'), 3) + `
${loc(obj.lang, 'SettingsAudioFullTikTokDescription')}
` }) }, { name: "other", title: `${emoji("đŸĒ…")} ${loc(obj.lang, 'SettingsOtherTab')}`, content: settingsCategory({ name: "appearance", title: loc(obj.lang, 'SettingsAppearanceSubtitle'), body: switcher({ name: "theme", subtitle: loc(obj.lang, 'SettingsThemeSubtitle'), items: [{ "action": "auto", "text": loc(obj.lang, 'SettingsThemeAuto') }, { "action": "dark", "text": loc(obj.lang, 'SettingsThemeDark') }, { "action": "light", "text": loc(obj.lang, 'SettingsThemeLight') }] }) + checkbox("alwaysVisibleButton", loc(obj.lang, 'SettingsKeepDownloadButton'), loc(obj.lang, 'AccessibilityKeepDownloadButton'), 2) }) + settingsCategory({ name: "miscellaneous", title: loc(obj.lang, 'Miscellaneous'), body: checkbox("disableChangelog", loc(obj.lang, 'SettingsDisableNotifications')) }) }], })} ${popup({ name: "download", standalone: true, header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), subtitle: loc(obj.lang, 'TitlePopupDownload') }, body: switcher({ name: "download", subtitle: loc(obj.lang, 'DownloadPopupWayToSave'), explanation: `${!isIOS ? loc(obj.lang, 'DownloadPopupDescription') : loc(obj.lang, 'DownloadPopupDescriptionIOS')}`, items: `${loc(obj.lang, 'Download')}
${loc(obj.lang, 'CopyURL')}
` }) })} ${popupWithBottomButtons({ name: "picker", closeAria: loc(obj.lang, 'AccessibilityClosePopup'), header: { title: `
`, explanation: `
`, }, buttons: [`${loc(obj.lang, 'ImagePickerDownloadAudio')}`], content: '
' })} ${popup({ name: "error", standalone: true, buttonOnly: true, emoji: emoji("☚ī¸", 48, 1), classes: ["small"], buttonText: loc(obj.lang, 'ErrorPopupCloseButton'), header: { closeAria: loc(obj.lang, 'AccessibilityClosePopup'), title: loc(obj.lang, 'TitlePopupError') }, body: `
` })} `; } catch (err) { return `${loc(obj.lang, 'ErrorPageRenderFail', obj.hash)}`; } }