import { backdropLink, celebrationsEmoji, checkbox, collapsibleList, explanation, footerButtons, multiPagePopup, popup, popupWithBottomButtons, sep, settingsCategory, switcher, socialLink } 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('').substring(4)
let donate = ``
let donateLinks = ``
let audioFormats = supportedAudio.map((p) => {
return { "action": p }
})
audioFormats.unshift({ "action": "best" })
for (let i in donations["links"]) {
donateLinks += `REPLACEME ${i}`
}
let extr = ''
for (let i in donations["crypto"]) {
donate += `
${i} (REPLACEME)
${donations["crypto"][i]}
`
extr = ' top-margin'
}
export default function(obj) {
const t = (str, replace) => { return loc(obj.lang, str, replace) };
let ua = obj.useragent.toLowerCase();
let isIOS = ua.match("iphone os");
let isMobile = ua.match("android") || ua.match("iphone os");
audioFormats[0]["text"] = t('SettingsAudioFormatBest');
try {
return `
${appName}
${multiPagePopup({
name: "about",
closeAria: t('AccessibilityClosePopup'),
tabs: [{
name: "about",
title: `${emoji("đ˛")} ${t('AboutTab')}`,
content: popup({
name: "about",
header: {
aboveTitle: {
text: t('MadeWithLove'),
url: authorInfo.link
},
closeAria: t('AccessibilityClosePopup'),
title: `${emoji("đŽ", 30)} ${t('TitlePopupAbout')}`
},
body: [{
text: t('AboutSummary')
}, {
text: collapsibleList([{
"name": "services",
"title": t("CollapseServices"),
"body": `${enabledServices}
${t("ServicesNote")}`
}, {
"name": "support",
"title": t("CollapseSupport"),
"body": `${t("FollowSupport")}
${socialLink(emoji("đ"), "mastodon", authorInfo.support.mastodon.handle, authorInfo.support.mastodon.url)}
${socialLink(emoji("đĻ"), "twitter", authorInfo.support.twitter.handle, authorInfo.support.twitter.url)}
${t("SourceCode")}
${socialLink(emoji("đ"), "github", repo.replace("https://github.com/", ''), repo)}
${t("SupportNote")}`
}, {
"name": "privacy",
"title": t("CollapsePrivacy"),
"body": t("PrivacyPolicy")
}])
}]
})
}, {
name: "changelog",
title: `${emoji("đ")} ${t('ChangelogTab')}`,
content: popup({
name: "changelog",
header: {
closeAria: t('AccessibilityClosePopup'),
title: `${emoji("đĒ", 30)} ${t('TitlePopupChangelog')}`
},
body: [{
text: `${t('ChangelogLastMajor')}
`,
raw: true
}, {
text: changelogManager("banner") ? ``: '',
raw: true
}, {
text: changelogManager("title"),
classes: ["changelog-subtitle"],
nopadding: true
}, {
text: changelogManager("content")
}, {
text: `${sep()}${obj.hash}: ${com[0]}`,
classes: ["changelog-subtitle"],
nopadding: true
}, {
text: com[1]
}, {
text: backdropLink(`${repo}/commits`, t('LinkGitHubChanges')),
classes: ["bottom-link"]
}, {
text: `${t('ChangelogOlder')}
`,
raw: true
}, {
text: ``,
raw: true
}]
})
}, {
name: "donate",
title: `${emoji("đ°")} ${t('DonationsTab')}`,
content: popup({
name: "donate",
header: {
closeAria: t('AccessibilityClosePopup'),
title: emoji("đ¸", 30) + t('TitlePopupDonate')
},
body: [{
text: `${t('DonateSub')}
`,
raw: true
}, {
text: ``,
raw: true
}, {
text: t('DonateExplanation')
}, {
text: donateLinks.replace(/REPLACEME/g, t('DonateVia')),
raw: true
}, {
text: t('DonateLinksDescription'),
classes: ["explanation"]
}, {
text: sep(),
raw: true
}, {
text: donate.replace(/REPLACEME/g, t('ClickToCopy')),
classes: ["desc-padding"]
}, {
text: sep(),
raw: true
}, {
text: t('DonateHireMe', authorInfo.link),
classes: ["desc-padding"]
}]
})
}],
})}
${multiPagePopup({
name: "settings",
closeAria: t('AccessibilityClosePopup'),
header: {
aboveTitle: {
text: `v.${version}-${obj.hash}`,
url: `${repo}/commit/${obj.hash}`
},
title: `${emoji("âī¸", 30)} ${t('TitlePopupSettings')}`
},
tabs: [{
name: "video",
title: `${emoji("đŦ")} ${t('SettingsVideoTab')}`,
content: settingsCategory({
name: "downloads",
title: t('SettingsVideoGeneral'),
body: switcher({
name: "vQuality",
subtitle: t('SettingsQualitySubtitle'),
explanation: t('SettingsQualityDescription'),
items: [{
"action": "max",
"text": `${t('SettingsQualitySwitchMax')}
(2160p+)`
}, {
"action": "hig",
"text": `${t('SettingsQualitySwitchHigh')}
(${quality.hig}p)`
}, {
"action": "mid",
"text": `${t('SettingsQualitySwitchMedium')}
(${quality.mid}p)`
}, {
"action": "low",
"text": `${t('SettingsQualitySwitchLow')}
(${quality.low}p)`
}]
})
})
+ settingsCategory({
name: "tiktok",
title: "tiktok & douyin",
body: checkbox("disableTikTokWatermark", t('SettingsRemoveWatermark'), 3)
})
+ settingsCategory({
name: "youtube",
body: switcher({
name: "vFormat",
subtitle: t('SettingsFormatSubtitle'),
explanation: t('SettingsFormatDescription'),
items: [{
"action": "mp4",
"text": "mp4 (av1)"
}, {
"action": "webm",
"text": "webm (vp9)"
}]
})
})
}, {
name: "audio",
title: `${emoji("đļ")} ${t('SettingsAudioTab')}`,
content: settingsCategory({
name: "general",
title: t('SettingsAudioTab'),
body: switcher({
name: "aFormat",
subtitle: t('SettingsFormatSubtitle'),
explanation: t('SettingsAudioFormatDescription'),
items: audioFormats
}) + sep(0) + checkbox("muteAudio", t('SettingsVideoMute'), 3) + explanation(t('SettingsVideoMuteExplanation'))
}) + settingsCategory({
name: "tiktok",
title: "tiktok & douyin",
body: checkbox("fullTikTokAudio", t('SettingsAudioFullTikTok'), 3) + `${t('SettingsAudioFullTikTokDescription')}
`
})
}, {
name: "other",
title: `${emoji("đĒ
")} ${t('SettingsOtherTab')}`,
content: settingsCategory({
name: "appearance",
title: t('SettingsAppearanceSubtitle'),
body: switcher({
name: "theme",
subtitle: t('SettingsThemeSubtitle'),
items: [{
"action": "auto",
"text": t('SettingsThemeAuto')
}, {
"action": "dark",
"text": t('SettingsThemeDark')
}, {
"action": "light",
"text": t('SettingsThemeLight')
}]
}) + checkbox("alwaysVisibleButton", t('SettingsKeepDownloadButton'), 4, t('AccessibilityKeepDownloadButton'))
}) + settingsCategory({
name: "miscellaneous",
title: t('Miscellaneous'),
body: checkbox("disableChangelog", t('SettingsDisableNotifications')) + `${!isIOS ? checkbox("downloadPopup", t('SettingsEnableDownloadPopup'), 1, t('AccessibilityEnableDownloadPopup')) : ''}`
})
}],
})}
${popup({
name: "download",
standalone: true,
header: {
closeAria: t('AccessibilityClosePopup'),
subtitle: t('TitlePopupDownload')
},
body: switcher({
name: "download",
subtitle: t('DownloadPopupWayToSave'),
explanation: `${!isIOS ? t('DownloadPopupDescription') : t('DownloadPopupDescriptionIOS')}`,
items: `${t('Download')}
${t('CopyURL')}
`
})
})}
${popupWithBottomButtons({
name: "picker",
closeAria: t('AccessibilityClosePopup'),
header: {
title: ``,
explanation: ``,
},
buttons: [`${t('ImagePickerDownloadAudio')}`],
content: ''
})}
${popup({
name: "error",
standalone: true,
buttonOnly: true,
classes: ["small"],
buttonText: t('ErrorPopupCloseButton'),
header: {
closeAria: t('AccessibilityClosePopup'),
title: t('TitlePopupError'),
emoji: emoji("âšī¸", 64, 1),
},
body: ``
})}
`;
} catch (err) {
return `${t('ErrorPageRenderFail', obj.hash)}`;
}
}