async function anonymous(__self,scope ) { with (scope) { __self.result = { showDropdown: null, showCollapse: null, showLocaleSwitcher: false, showSearch: window.location.pathname.startsWith('/search/'), searchHistory: [], showPreview: null, holdPreviews: [], showModal: { login: false, }, currentPage: 'login', locale: 'en', isMain: true, isChinese: false, isEnglish: true, fallbackLocale: 'zh', user: null, loadedRecaptcha: false, loginCallback: null, blockedKeywords: {"abuse":"play","asphyxia":"play","behead":"play","bleed":"play","blood":"play","child":"play","choke":"play","choking":"play","decapitation":"play","drugged":"played","forced":"played","kid":"play","kill":"play","loli":"play","murder":"play","rape":"play","raped":"played","raping":"playing","shota":"play","snuff":"play","strangle":"play","torture":"play","abduct":"play","incest":"play","underaged":"play"}, dmcaDummy: 'dm17', currentSearchPlaceholderIndex: 0, searchPlaceholderTexts: [ 'Example: Big Tit Blonde Schoolgirl', 'Use "+" to combine multiple keywords', ], currentSearchPlaceholderText() { return this.searchPlaceholderTexts[this.currentSearchPlaceholderIndex] }, slot() { return parseInt(window.localStorage.getItem('slot')) }, isDesktop() { return document.documentElement.clientWidth >= 1024 }, isThreeColumns() { return document.documentElement.clientWidth >= 768 && document.documentElement.clientWidth < 1280 }, cdnUrl(path) { return `https://fourhoi.com${path}` }, itemUrl(item) { let dmPrefix = item.dm ? `/dm${item.dm}` : ''; let url = this.locale === 'zh' ? `${dmPrefix}/${item.dvd_id}` : `${dmPrefix}/${this.locale}/${item.dvd_id}` if (item.recommend_id) { url += `#${item.recommend_id}` if (item.scenario) { url += `_${item.scenario}` } } else if (this.isMain && item.scenario) { url += `#${item.scenario}` } return url }, generateFullItemTitle(item) { const titleField = this.translatedField('title', this.locale) item['full_title'] = item['dvd_id'] ? `${item['dvd_id'].toUpperCase().replace('-UNCENSORED-LEAK', '').replace('-CHINESE-SUBTITLE', '').replace('-ENGLISH-SUBTITLE', '')} ${item[titleField]}` : ' ' return item }, translatedField(field, locale) { return locale === 'ja' ? field : `${field}_${locale}` }, translatedValue(object, field, locale) { return this.purify(object[this.translatedField(field, locale)]) }, toggleSearch() { let type this.showSearch = ! this.showSearch if (this.showSearch) { this.showDropdown = null this.$nextTick(() => { this.$refs.search.select() }) } }, search(keyword) { keyword = keyword.trim() if (! keyword) { return } keyword = encodeURIComponent(keyword.replace('\\', '')) if (window.location.href.includes('/legacy')) { window.location.href = this.locale === this.fallbackLocale ? `/legacy?keyword=${keyword}` : `/${this.locale}/legacy?keyword=${keyword}` return } let searchHistory = this.getSearchHistory() if (searchHistory.includes(keyword)) { searchHistory.splice(searchHistory.indexOf(keyword), 1) } searchHistory.unshift(keyword); window.Cookies.set('search_history', JSON.stringify(searchHistory), { expires: 365 }) window.location.href = this.locale === this.fallbackLocale ? `/search/${keyword}` : `/${this.locale}/search/${keyword}` }, getSearchHistory() { const searchHistoryText = window.Cookies.get('search_history') if (! searchHistoryText) { return [] } return JSON.parse(searchHistoryText).slice(0, 5) }, clearSearchHistory() { window.Cookies.remove('search_history') this.searchHistory = [] }, clearWatchHistory() { this.showDropdown = null if (! confirm(`Are you sure to clear all watch history?`)) { return } window.axios.delete('https://missav.ws/api/history').then(response => { alert(`Watch history has been cleared.`) window.location.href = 'https://missav.ws/en/history' }) }, localizedUrl(locale) { let path = window.location.pathname if (! path.endsWith('/')) { path = `${path}/` } path = path + window.location.search if (locale === this.fallbackLocale) { return this.removeTrailingSlash(path .replace('/cn/', '/').replace('/en/', '/').replace('/ja/', '/').replace('/ko/', '/').replace('/ms/', '/').replace('/th/', '/').replace('/de/', '/').replace('/fr/', '/').replace('/vi/', '/').replace('/id/', '/').replace('/fil/', '/').replace('/pt/', '/') ) } if (path.includes('/cn/') || path.includes('/en/') || path.includes('/ja/') || path.includes('/ko/') || path.includes('/ms/') || path.includes('/th/') || path.includes('/de/') || path.includes('/fr/') || path.includes('/vi/') || path.includes('/id/') || path.includes('/fil/') || path.includes('/pt/')) { return this.removeTrailingSlash(path .replace('/cn/', `/${locale}/`).replace('/en/', `/${locale}/`).replace('/ja/', `/${locale}/`).replace('/ko/', `/${locale}/`).replace('/ms/', `/${locale}/`).replace('/th/', `/${locale}/`).replace('/de/', `/${locale}/`).replace('/fr/', `/${locale}/`).replace('/vi/', `/${locale}/`).replace('/id/', `/${locale}/`).replace('/fil/', `/${locale}/`).replace('/pt/', `/${locale}/`) ) } return this.removeTrailingSlash( this.dmcaDummy ? path.replace(this.dmcaDummy, `${this.dmcaDummy}/${locale}`) : `/${locale}${path}` ) }, removeTrailingSlash(url) { if (url.substr(url.length - 1) === '/') { return url.slice(0, -1) } return url.replace('/?', '?') }, redirectToBaseLocalizedUrl() { window.Cookies.set('localized', 1, { expires: 30 }) setTimeout(() => { window.location.href = '/?localized=1' }, 100) }, loadRecaptcha() { if (! this.loadedRecaptcha) { this.loadedRecaptcha = true let script = document.createElement('script') script.type = 'text/javascript'; script.src = 'https://www.google.com/recaptcha/api.js?render=6Leez8oZAAAAABJqF0uuw35s7N50I1pZkIJBO1QT' document.getElementsByTagName('head')[0].appendChild(script) } }, requireRecaptcha(callback) { grecaptcha.ready(() => { grecaptcha.execute('6Leez8oZAAAAABJqF0uuw35s7N50I1pZkIJBO1QT', { action: 'submit' }).then(recaptchaToken => { callback(recaptchaToken) }) }) }, showLoginModal(page) { this.loadRecaptcha() this.showModal.login = true if (page) { this.currentPage = page } }, requireLogin(callback) { if (! this.user) { this.loginCallback = callback this.showLoginModal() return } callback() }, handleErrorResponse(page, error) { this.errors[page] = error.response.data.errors }, setPreview(id) { if (window.innerWidth < 1024) { return } if (this.showPreview) { const previousPreview = document.getElementById(`preview-${this.showPreview}`) if (previousPreview) { previousPreview.pause() } } if (! id) { this.showPreview = id return } this.playPreview(id) }, clickPreview(id) { if (this.isDesktop()) { return } if (! this.holdPreviews.includes(id)) { event.preventDefault() this.holdPreviews.push(id) this.playPreview(id) } }, playPreview(id) { const preview = document.getElementById(`preview-${id}`) if (! preview.getAttribute('src')) { preview.addEventListener('loadedmetadata', event => { event.target.play() this.showPreview = id }) preview.setAttribute('src', preview.getAttribute('data-src')) } else { preview.play() this.showPreview = id } }, initLozad() { window.lozad('.lozad', { loaded: function(element) { element.classList.remove('lozad') }, }).observe() }, purify(text) { for (key in this.blockedKeywords) { text = text.replaceAll(new RegExp(key, 'gi'), this.blockedKeywords[key]) } return text }, } }; __self.finished = true; return __self.result; }