MCPcopy Create free account
hub / github.com/Useful-Scripts-Extension/useful-script / initSettings

Function initSettings

popup/index.js:732–922  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

730}
731
732function initSettings() {
733 settingsBtn.onclick = () => {
734 trackEvent("CLICK_SETTINGS");
735
736 const body = document.createElement("div");
737 body.classList.add("settings-body");
738
739 // select language
740 const langRow = document.createElement("div");
741 const curLang = getLang();
742 langRow.classList.add("row");
743 langRow.innerHTML = `
744 <div class="label">${t({ en: "Language", vi: "Ngôn ngữ" })}</div>
745 <div class="right-container">
746 <img src="${getFlag(curLang)}" />
747 <select class="select">
748 ${LANG_KEY.map(
749 (key) =>
750 `<option value="${key}" ${key === curLang ? "selected" : ""}>
751 ${LANG[key]}
752 </option>`
753 ).join("")}
754 </select>
755 </div>
756 `;
757 const select = langRow.querySelector(".select");
758 select.onchange = (event) => {
759 let newLang = event.target.value;
760 trackEvent("CHANGE-LANGUAGE-" + newLang);
761 setLang(newLang);
762
763 // reset UI
764 createTabs();
765 checkForUpdate();
766
767 // re-open setting modal
768 settingsBtn.click();
769 initTooltip();
770 };
771 body.appendChild(langRow);
772
773 // select themes
774 let curThemeKey = getTheme();
775 let curThem = THEME[curThemeKey];
776 const themeRow = document.createElement("div");
777 themeRow.classList.add("row");
778 const author = curThem?.author
779 ? `<a target="_blank" href="${curThem.author.link}" data-tooltip="${t({
780 vi: "Tác giả: " + curThem.author.name,
781 en: "Author: " + curThem.author.name,
782 })}" data-flow="left">
783 <img src="${curThem.author.avatar}" class="avatar" />
784 </a>`
785 : "";
786 themeRow.innerHTML = `
787 <div class="label">${t({ en: "Theme", vi: "Chủ đề" })}</div>
788 <div class="right-container">
789 ${author}

Callers 1

index.jsFile · 0.85

Calls 15

trackEventFunction · 0.90
getLangFunction · 0.90
tFunction · 0.90
getFlagFunction · 0.90
setLangFunction · 0.90
checkForUpdateFunction · 0.90
getThemeFunction · 0.90
setThemeFunction · 0.90
openModalFunction · 0.90
createTabsFunction · 0.85
initTooltipFunction · 0.85
lazyEnableSmoothScrollFunction · 0.85

Tested by

no test coverage detected