// ==UserScript== // @name 别样红辅助(大道店) // @namespace https://bbs.tampermonkey.net.cn/ // @version 0.4.0 // @description 别样红辅助 // @author EmpyrealTear // @icon https://c1.beyondh.com/maxpms/5.2.1.2/favicon.ico // @match .*://mn.beyondh.com:8101/* // @require https://cdn.bootcdn.net/ajax/libs/jquery/3.7.1/jquery.min.js // @require https://scriptcat.org/lib/513/2.0.0/ElementGetter.js // @grant unsafeWindow // @grant GM_setValue // @grant GM_getValue // @grant GM_registerMenuCommand // @grant GM_unregisterMenuCommand // ==/UserScript== (function () { 'use strict'; unsafeWindow.jQuery = $ const options = { menus: { isShowCleaner: { toStr: (x) => '显示保洁:' + (x ? '✓' : '✕'), _new: null, _old: null }, isShowDetailContractName: { toStr: (x) => '显示中介明细:' + (x ? '✓' : '✕'), _new: null, _old: null }, isHighlightBalanceltPrice: { toStr: (x) => '显示高亮余额低于房价:' + (x ? '✓' : '✕'), _new: null, _old: null }, }, register: (name) => { let val = GM_getValue(name) options.menus[name][!val ? '_new' : '_old'] = GM_registerMenuCommand(options.menus[name].toStr(val), () => { GM_setValue(name, !val) options.register(name) }) GM_unregisterMenuCommand(options.menus[name][val ? '_new' : '_old']) }, loads: () => { Object.keys(options.menus).forEach(v => options.register(v)) // options.register('isShowCleaner') // options.register('isShowDetailContractName') } } options.loads() const sum = (arr) => { if (arr == undefined) return undefined let res = 0 for (let i of arr) res += i return res } const getCleaner = (id) => { if ((id >= 301 && id <= 311) || (id >= 601 && id <= 611)) return '谢' else if ((id >= 401 && id <= 411) || id == 706 || (id >= 708 && id <= 711) || (id >= 807 && id <= 812)) return '易' else return '段' } const apis = { GetMixAllRoomDetails: () => { let res = null $.ajax({ url: 'https://mn.beyondh.com:8111/api/Room/GetMixAllRoomDetails', type: 'GET', xhrFields: { withCredentials: true }, dataType: 'json', async: false, success: (data) => { res = data } }) if (res == null) return res for (let i = 0; i < res.Content.length; i++) { let id = parseInt(res.Content[i].RoomNumber) res.Content[i].Cleaner = getCleaner(id) } return res }, GetMixSingleRoomOccupationInfo: (id) => { let res = null $.ajax({ url: `https://mn.beyondh.com:8111/api/Room/GetMixSingleRoomOccupationInfo?roomNumber=${id}`, type: 'GET', xhrFields: { withCredentials: true }, dataType: 'json', async: false, success: (data) => { res = data } }) return res }, SearchGuestFolio: () => { let res = null $.ajax({ url: `https://mn.beyondh.com:8111/API/GuestFolio/SearchGuestFolio?PageSize=100&PageIndex=1&IsDesc=false&Status%5B%5D=I&IsMeiTuanOrder=false&DateRangeType=RecentWithOneYear`, type: 'GET', xhrFields: { withCredentials: true }, dataType: 'json', async: false, success: (data) => { res = data } }) return res }, } elmGetter.selector('jquery') const xhrOpen = XMLHttpRequest.prototype.open; XMLHttpRequest.prototype.open = function () { const xhr = this if (/api\/Room\/GetMixAllRoomDetails/.test(arguments[1])) { const getter = Object.getOwnPropertyDescriptor(XMLHttpRequest.prototype, "responseText").get Object.defineProperty(xhr, "responseText", { get: () => { let result = getter.call(xhr) let roomInfo = JSON.parse(result) let roomSet = {} let roomDetails = apis.SearchGuestFolio().Content.Content for (let i = 0; i < roomInfo.Content.length; i++) { let id = parseInt(roomInfo.Content[i].RoomNumber) roomInfo.Content[i].Cleaner = getCleaner(id) let guests = roomDetails .filter(v => v.GuestFolioDetailModels[0].RoomNumber.some(num => num == roomInfo.Content[i].RoomNumber)) roomInfo.Content[i].Remark = guests.map(v => v.CheckinMemo).join(';') if (guests.length > 0) { roomInfo.Content[i].Balance = sum(guests.map(v => v.Balance)) roomInfo.Content[i].TodayPrice = guests[0].GuestFolioDetailModels[0].FirstDayPrice.ActualPrice roomInfo.Content[i].DailyPrices = guests[0].GuestFolioDetailModels[0].DailyPrices } roomSet[roomInfo.Content[i].RoomNumber] = roomInfo.Content[i] } // console.log(roomSet) let cleans = {} let rooms = roomInfo.Content for (let i = 0; i < rooms.length; i++) { let k = rooms[i].Cleaner if (!(k in cleans)) cleans[k] = 0 // VD=空脏; VC=空净; V_C=空夜; OOO=维修; OK=已检; OD=住脏; OC=住净; ED=预退; if (rooms[i].CustomerStatus == 'IsEstArrival' || /VD|OD|OC/.test(rooms[i].RoomStatus)) // if (rooms[i].CustomerStatus == 'IsEstArrival' || /OD|OC/.test(rooms[i].RoomStatus)) cleans[k] += 1 } // 统计需保洁数量 jQuery('#cleaner').remove() jQuery('div>div.small:contains("出租率")').parent().prepend(`