// ==UserScript==
// @name MissAVAutomatic login
// @description DetectionMisssAVstate,and automatically log in when not logged in
// @name:ar MissAVتسجيل الدخول التلقائي
// @description:ar كشفMisssAVولاية,وتسجيل الدخول تلقائيًا في حالة عدم تسجيل الدخول
// @name:bg MissAVАвтоматично влизане
// @description:bg ОткриванеMisssAVсъстояние,и автоматично влизане, когато не сте влезли
// @name:cs MissAVAutomatické přihlášení
// @description:cs DetekceMisssAVstát,a automaticky se přihlásit, když nejste přihlášeni
// @name:da MissAVAutomatisk login
// @description:da OpdagelseMisssAVtilstand,og logger automatisk på, når du ikke er logget ind
// @name:de MissAVAutomatische Anmeldung
// @description:de ErkennungMisssAVZustand,und melden Sie sich automatisch an, wenn Sie nicht angemeldet sind
// @name:el MissAVΑυτόματη σύνδεση
// @description:el ΑνίχνευσηMisssAVκατάσταση,και αυτόματα συνδέεστε όταν δεν είστε συνδεδεμένοι
// @name:en MissAVAutomatic login
// @description:en DetectionMisssAVstate,and automatically log in when not logged in
// @name:eo MissAVAŭtomata ensaluto
// @description:eo DetektoMisssAVstato,kaj aŭtomate ensalutu kiam ne ensalutinta
// @name:es MissAVInicio de sesión automático
// @description:es DetecciónMisssAVestado,e iniciar sesión automáticamente cuando no haya iniciado sesión
// @name:fi MissAVAutomaattinen sisäänkirjautuminen
// @description:fi HavaitseminenMisssAVosavaltio,ja kirjaudu sisään automaattisesti, kun et ole kirjautunut sisään
// @name:fr MissAVConnexion automatique
// @description:fr DétectionMisssAVÉtat,et connectez-vous automatiquement lorsque vous n’êtes pas connecté
// @name:he MissAVכניסה אוטומטית
// @description:he איתורMisssAVמְדִינָה,והתחבר אוטומטית כאשר לא מחובר
// @name:hr MissAVAutomatska prijava
// @description:hr OtkrivanjeMisssAVstanje,i automatski se prijavite kada niste prijavljeni
// @name:hu MissAVAutomatikus bejelentkezés
// @description:hu ÉrzékelésMisssAVállami,és automatikusan bejelentkezik, ha nincs bejelentkezve
// @name:id MissAVMasuk otomatis
// @description:id DeteksiMisssAVnegara,dan secara otomatis login ketika tidak login
// @name:it MissAVAccesso automatico
// @description:it RilevamentoMisssAVstato,e accedi automaticamente quando non sei loggato
// @name:ja MissAV自動ログイン
// @description:ja 検出MisssAV州,ログインしていない場合は自動的にログインします
// @name:ka MissAVავტომატური შესვლა
// @description:ka გამოვლენაMisssAVსახელმწიფო,და ავტომატურად შედით სისტემაში, როდესაც არ ხართ შესული
// @name:ko MissAV자동 로그인
// @description:ko 발각MisssAV상태,로그인하지 않으면 자동으로 로그인됩니다.
// @name:nl MissAVAutomatisch inloggen
// @description:nl DetectieMisssAVstaat,en automatisch inloggen als je niet ingelogd bent
// @name:nb MissAVAutomatisk pålogging
// @description:nb OppdagelseMisssAVtilstand,og logger automatisk på når du ikke er pålogget
// @name:pl MissAVAutomatyczne logowanie
// @description:pl WykrywanieMisssAVpaństwo,i automatycznie loguj się, gdy nie jesteś zalogowany
// @name:pt-BR MissAVLogin automático
// @description:pt-BR DetecçãoMisssAVestado,e faça login automaticamente quando não estiver conectado
// @name:ro MissAVConectare automată
// @description:ro DetectareMisssAVstat,și conectați-vă automat când nu sunteți autentificat
// @name:ru MissAVАвтоматический вход
// @description:ru ОбнаружениеMisssAVсостояние,и автоматически входить в систему, когда вы не вошли в систему
// @name:sk MissAVAutomatické prihlásenie
// @description:sk DetekciaMisssAVštátu,a automaticky sa prihlásiť, keď nie ste prihlásení
// @name:sr MissAVАутоматско пријављивање
// @description:sr ДетецтионMisssAVдржава,и аутоматски се пријављује када нисте пријављени
// @name:sv MissAVAutomatisk inloggning
// @description:sv UpptäcktMisssAVange,och logga in automatiskt när du inte är inloggad
// @name:th MissAVเข้าสู่ระบบอัตโนมัติ
// @description:th การตรวจจับMisssAVสถานะ,และเข้าสู่ระบบอัตโนมัติเมื่อไม่ได้เข้าสู่ระบบ
// @name:tr MissAVOtomatik giriş
// @description:tr AlgılamaMisssAVdurum,ve oturum açmadığınızda otomatik olarak oturum açın
// @name:ug MissAVئاپتوماتىك كىرىش
// @description:ug بايقاشMisssAVئىشتات,ھەمدە كىرمىگەندە ئاپتوماتىك كىرىدۇ
// @name:uk MissAVАвтоматичний вхід
// @description:uk виявленняMisssAVстан,і автоматично ввійти, якщо ви не ввійшли
// @name:vi MissAVĐăng nhập tự động
// @description:vi Phát hiệnMisssAVtình trạng,và tự động đăng nhập khi chưa đăng nhập
// @name:zh-CN MissAV自动登录
// @description:zh-CN 检测MisssAV状态,并且在未登录时自动登录
// @name:zh-TW MissAV自動登入
// @description:zh-TW 偵測MisssAV狀態,並且在未登入時自動登入
// @name:ja MissAV自動ログイン
// @description:ja MissAVの状態を検出し、未ログインの場合に自動でログインします
// @namespace https://github.com/ChinaGodMan/UserScripts
// @author 人民的勤务员 <[email protected]>
// @match https://missav.com/*
// @grant GM_registerMenuCommand
// @grant GM_setValue
// @grant GM_getValue
// @version 1.0.0.1
// @require https://update.greasyfork.org/scripts/498897/1404834/Toastnew.js
// @icon https://pic.616pic.com/ys_bnew_img/00/35/79/Gv93yQh7v6.jpg
// @supportURL https://github.com/ChinaGodMan/UserScripts/issues
// @homepageURL https://github.com/ChinaGodMan/UserScripts
// ==/UserScript==
const translate = (function () {
const userLang = (navigator.languages && navigator.languages[0]) || navigator.language || 'en'
const strings = {
'en': {
Accountnull: 'Error: UserEmail or UserPassword is empty.',
loginSuccess: 'Login successful, refreshing the page.',
Networkfailed: 'Status code error.',
Loginfailed: 'Login failed, incorrect email or password. Check console for error details.',
},
'zh-CN': {
Accountnull: '邮箱或密码为空',
loginSuccess: '登录成功,即将刷新页面。',
Networkfailed: '状态码错误',
Loginfailed: '登录失败,邮箱或密码错误,可以在控制台查看错误信息。',
},
'zh-TW': {
Accountnull: '郵箱或密碼為空',
loginSuccess: '登錄成功,即將刷新頁面。',
Networkfailed: '狀態碼錯誤',
Loginfailed: '登錄失敗,郵箱或密碼錯誤,可以在控制台查看錯誤信息。',
},
'ja': {
Accountnull: 'エラー:メールアドレスまたはパスワードが空です。',
loginSuccess: 'ログイン成功、ページを更新します。',
Networkfailed: 'ステータスコードエラー',
Loginfailed: 'ログインに失敗しました。メールアドレスまたはパスワードが間違っています。エラーの詳細はコンソールで確認できます。',
},
'vi': {
Accountnull: 'Lỗi: Email hoặc mật khẩu trống.',
loginSuccess: 'Đăng nhập thành công, đang làm mới trang.',
Networkfailed: 'Lỗi mã trạng thái.',
Loginfailed: 'Đăng nhập không thành công, email hoặc mật khẩu không chính xác. Xem chi tiết lỗi trên bảng điều khiển.',
}
}
return (id, lang = '') => {
const selectedLang = lang || userLang
return (strings[selectedLang] || strings.en)[id] || strings.en[id]
}
}());
(function () {
'use strict'
let UserEmail = GM_getValue("UserEmail", "")
let UserPassword = GM_getValue("UserPassword", "")
var style = document.createElement('style')
GM_registerMenuCommand("Set Account", showuserInfoModal)
function showuserInfoModal() {
let modalHtml = `
<div id="userInfoModal" style="position: fixed; z-index: 10000; background: white; padding: 20px; border-radius: 8px; box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.5); top: 20%; left: 50%; transform: translate(-50%, -20%); max-width: 300px;">
<h2 style="margin-top: 0;">Set Account </h2>
<div style="margin-bottom: 10px;">
<label for="UserEmail" style="display: block; margin-bottom: 5px;">UserEmail:</label>
<input id="UserEmail" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px;" value="${UserEmail}" />
</div>
<div style="margin-bottom: 20px;">
<label for="UserPassword" style="display: block; margin-bottom: 5px;">UserPassword:</label>
<input id="UserPassword" style="width: 100%; padding: 8px; border: 1px solid #ccc; border-radius: 4px;" value="${UserPassword}" />
</div>
<div style="text-align: right;">
<button id="saveUserInfo" style="background-color: #4CAF50; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer;">Save</button>
<button id="closeUserModal" style="background-color: #f44336; color: white; padding: 10px 20px; border: none; border-radius: 4px; cursor: pointer; margin-left: 10px;">Close</button>
</div>
</div>`
let modalDiv = document.createElement('div')
modalDiv.innerHTML = modalHtml
document.body.appendChild(modalDiv)
document.getElementById("saveUserInfo").addEventListener("click", function () {
UserEmail = document.getElementById("UserEmail").value
UserPassword = document.getElementById("UserPassword").value
GM_setValue("UserEmail", UserEmail)
GM_setValue("UserPassword", UserPassword)
closeUserModal()
})
document.getElementById("closeUserModal").addEventListener("click", closeUserModal)
}
function closeUserModal() {
let modal = document.getElementById("userInfoModal")
if (modal) {
modal.remove()
}
}
function login(email, password) {
if (!email || !password) {
Toast(translate('Accountnull'), 2000, '#FF0000', '#ffffff', 'top')
return
}
fetch('https://missav.com/cn/api/login', {
method: 'POST',
headers: {
'Content-Type': 'application/json',
},
body: JSON.stringify({
email: email,
password: password,
remember: true,
}),
})
.then(response => {
if (!response.ok) {
return response.text().then(text => {
console.error('Login error:', {
status: response.status,
statusText: response.statusText,
responseText: text,
})
Toast('Login failed: ' + text, 2000, '#FF0000', '#ffffff', 'top')
throw new Error(translate('Networkfailed'))
})
}
if (response.headers.get('Content-Type')?.includes('application/json')) {
return response.json()
} else {
return response.text().then(text => {
console.error(translate('Loginfailed'), {
status: response.status,
statusText: response.statusText,
responseText: text,
})
Toast(translate('Loginfailed'), 2000, '#FF0000', '#ffffff', 'top')
throw new Error(translate('Loginfailed'))
})
}
})
.then(data => {
console.log('Success:', data)
Toast(translate('loginSuccess'), 2000, 'rgb(18, 187, 2)', '#ffffff', 'top')
location.reload()
})
.catch(error => {
Toast('An error occurred: ' + error.message, 2000, '#FF0000', '#ffffff', 'top')
})
}
function check() {
const url = 'https://missav.com/api/actresses/1016525/view'
fetch(url, {
method: 'GET'
})
.then(response => {
if (response.ok) {
return response.json()
} else {
throw new Error('Network response was not ok.')
}
})
.then(data => {
if (data) {
if (data.user === null) {
login(UserEmail, UserPassword)
} else {
// 已经登录
}
}
})
.catch(error => console.error('Error:', error))
}
check()
})()