diff --git a/dist/constants.js b/dist/constants.js index 7e97c73..ff8d571 100644 --- a/dist/constants.js +++ b/dist/constants.js @@ -1 +1 @@ -const a0_0x39af8e=a0_0xd17f;(function(_0x5137a1,_0x48bb87){const _0x51f0f7=a0_0xd17f,_0x54e81d=_0x5137a1();while(!![]){try{const _0x2e1524=-parseInt(_0x51f0f7(0x132))/0x1+parseInt(_0x51f0f7(0x151))/0x2+parseInt(_0x51f0f7(0x15d))/0x3+-parseInt(_0x51f0f7(0x146))/0x4+-parseInt(_0x51f0f7(0x140))/0x5+-parseInt(_0x51f0f7(0x144))/0x6+parseInt(_0x51f0f7(0x15c))/0x7;if(_0x2e1524===_0x48bb87)break;else _0x54e81d['push'](_0x54e81d['shift']());}catch(_0x500d30){_0x54e81d['push'](_0x54e81d['shift']());}}}(a0_0x5f13,0x61b6b));function a0_0x5f13(){const _0x5f4ca6=['&p=1&d=all&ctrl=','readMessage():\x20Error\x20read\x20message','floor','deleteInbox():\x20Error\x20delete\x20Inbox\x20page','div.fl\x20>\x20div.md.text.zoom.nw.f24\x20>\x20span.ellipsis.b','../.cache/location','deleteMessage():\x20Error\x20delete\x20message','writeMessage():\x20Error\x20write\x20message','No\x20se\x20encontró\x20la\x20función','timestamp','es-ES,es;q=0.9','div.fl\x20>\x20div.md.text.zoom.nw.f24\x20>\x20span.ellipsis:last-child',':S=ALNI_MZM6T_Gt5i9mVk7fSPYTS_lNnT05A;\x20compte=','mailHTML_content.html','https://yopmail.com/',':S=ALNI_Ma2fiSO_RXMSck7094BDGgSGuA2Uw;\x20__gpi=UID=00000da86f1e915d:T=','yopmail.com','none','archives','&v=','subject','div.fl\x20>\x20div.ellipsis.nw.b.f18','Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/113.0.0.0\x20Safari/537.36','keep-alive','join','https://yopmail.com','Missing\x20parameters','ytime=','getMinutes','482442KCDDxz','Error\x20getting\x20version.\x20Error\x20loading\x20page','/wm','Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/112.0.0.0\x20Safari/537.36','readFileSync','&p=1&d=','/inbox?login=','parameters\x20\x27mail\x27\x20is\x20required','navigate','.yopmail.com','application/x-www-form-urlencoded','text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7','&r_c=&id=','parameters\x20\x27_search\x27\x20keys\x20is\x20invalid,\x20try\x20again\x20with\x20(subject\x20ot\x20content)','2953695JXrlOg','now','\x22Windows\x22','Windows','1999098NTBxOq','#geny','1825064taTlkG',':S=ALNI_MZV3BFxisGotEe_asrUSYKvUv6xVQ;\x20compte=',';\x20compte=','\x20_gat=1;','&id=',':RT=','gzip,\x20deflate,\x20br','getMail():\x20Error\x20getting\x20YOPmail\x20page','&id=m','&yj=','from','409464wEbdBr','getHours',';\x20_ga=GA1.2.336146743.1702309064;\x20_gid=GA1.2.295648288.1702309064;\x20__gads=ID=287f5c78aab0a84d:T=','&r_c=&id=&ad=0','/mail?b=',';\x20ywm=','mailContent.json','existsSync','*/*','getInbox():\x20Error\x20getting\x20Inbox\x20page','resolve','12184753PcNaiE','952362ADZDJf','document','Error\x20getting\x20total\x20number\x20of\x20mails','utf8',':S=ALNI_MYMeBMqh92Qfh-oIx02VDmWeqsdAA;\x20compte=','path',';\x20_ga=GA1.2.503151223.1683393694;\x20_gid=GA1.2.1659462416.1683393694;\x20__gads=ID=1aef015d5c605919-2289ab29f27f0062:T=1683393694:RT=1683393694:S=ALNI_MYhXB3g-Ape8Bl2op45lGwvANkLFg;\x20__gpi=UID=000009f291461986:T=1683393694:RT=','&d=&ctrl=&yp=','tests','same-origin','/email-generator','mailHTML_id.html','\x22Not_A\x20Brand\x22;v=\x228\x22,\x20\x22Chromium\x22;v=\x22120\x22,\x20\x22Google\x20Chrome\x22;v=\x22120\x22','exports','inbox.json','\x22Google\x20Chrome\x22;v=\x22113\x22,\x20\x22Chromium\x22;v=\x22113\x22,\x20\x22Not-A.Brand\x22;v=\x2224\x22','#mail','cors','/webmail.js'];a0_0x5f13=function(){return _0x5f4ca6;};return a0_0x5f13();}const path=require(a0_0x39af8e(0x162)),fs=require('fs');function timeStampInSeconds(){const _0x568962=a0_0x39af8e;return Math[_0x568962(0x117)](Date[_0x568962(0x141)]()/0x3e8);}function a0_0xd17f(_0x5c2d91,_0x3936d7){const _0x5f132f=a0_0x5f13();return a0_0xd17f=function(_0xd17f5a,_0x28acdc){_0xd17f5a=_0xd17f5a-0x117;let _0x288496=_0x5f132f[_0xd17f5a];return _0x288496;},a0_0xd17f(_0x5c2d91,_0x3936d7);}function obtenerYTime(_0xe6d048){const _0x46afc9=a0_0x39af8e,_0x301e82=_0xe6d048*0x3e8,_0x365b0=new Date(_0x301e82),_0x42c6bb=_0x365b0[_0x46afc9(0x152)](),_0x25efe3=_0x365b0[_0x46afc9(0x131)]();return _0x46afc9(0x130)+_0x42c6bb+':'+_0x25efe3+';';}let location='es',pathLocation=path[a0_0x39af8e(0x12d)](__dirname,a0_0x39af8e(0x11a));fs[a0_0x39af8e(0x158)](pathLocation)&&(location=fs[a0_0x39af8e(0x136)](pathLocation,a0_0x39af8e(0x160)));module[a0_0x39af8e(0x16a)]=Object['freeze']({'BASE_URL':a0_0x39af8e(0x123),'GENERATOR_URL':a0_0x39af8e(0x123)+location+a0_0x39af8e(0x167),'READ_MAIL_URL':(_0x54a2ef,_0x55b945)=>'https://yopmail.com/'+location+a0_0x39af8e(0x155)+_0x54a2ef+a0_0x39af8e(0x14e)+_0x55b945,'WRITE_MAIL_URL':_0x3f8690=>'https://yopmail.com/'+location+'/write?b='+_0x3f8690+a0_0x39af8e(0x14a),'DELETE_INBOX_URL':(_0x40ee08,_0x819875,_0x48b932,_0xab4537,_0x1339ff)=>a0_0x39af8e(0x123)+location+a0_0x39af8e(0x138)+_0x40ee08+a0_0x39af8e(0x170)+_0x819875+'&yp='+_0x48b932+a0_0x39af8e(0x14f)+_0xab4537+a0_0x39af8e(0x128)+_0x1339ff+a0_0x39af8e(0x13e),'DELETE_MESSAGE_URL':(_0x598e48,_0x3c44f3,_0x489683,_0x33b8a6,_0x1442f0)=>a0_0x39af8e(0x123)+location+a0_0x39af8e(0x138)+_0x598e48+a0_0x39af8e(0x137)+_0x3c44f3+'&ctrl=&yp='+_0x489683+a0_0x39af8e(0x14f)+_0x33b8a6+a0_0x39af8e(0x128)+_0x1442f0+'&r_c=&id=','SEND_MESSAGE_URL':a0_0x39af8e(0x123)+location+'/writepost','INPUT_YP':'input#yp','REGEX_LOCATION':/lang=\"(.*?)\"/,'REGEX_YJ':/&yj=([^&]+)&v=/,'REGEX_TOTAL_MAILS':/w\.finrmail\((.*?)\)/,'INBOX_URL':(_0x5ad096,_0x5e79e6,_0x504fcc,_0x50d33b,_0x18154e=0x1)=>'https://yopmail.com/'+location+a0_0x39af8e(0x138)+_0x5ad096+'&p='+_0x18154e+a0_0x39af8e(0x164)+_0x5e79e6+a0_0x39af8e(0x14f)+_0x504fcc+a0_0x39af8e(0x128)+_0x50d33b+a0_0x39af8e(0x154),'INBOX_HTTP_CONFIG':(_0x3143ea,_0x43ce57)=>({'headers':{'accept':'text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7','cookie':_0x3143ea+a0_0x39af8e(0x148)+_0x43ce57+a0_0x39af8e(0x156)+_0x43ce57+a0_0x39af8e(0x153)+timeStampInSeconds()+a0_0x39af8e(0x14b)+timeStampInSeconds()+a0_0x39af8e(0x124)+timeStampInSeconds()+a0_0x39af8e(0x14b)+timeStampInSeconds()+a0_0x39af8e(0x147)+_0x43ce57+a0_0x39af8e(0x156)+_0x43ce57+';\x20'+obtenerYTime(timeStampInSeconds()),'accept-encoding':a0_0x39af8e(0x14c),'accept-language':a0_0x39af8e(0x11f),'connection':'keep-alive','host':a0_0x39af8e(0x125),'referer':a0_0x39af8e(0x123)+location+a0_0x39af8e(0x134),'sec-ch-ua':a0_0x39af8e(0x169),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':a0_0x39af8e(0x143),'sec-fetch-dest':'iframe','sec-fetch-mode':a0_0x39af8e(0x13a),'sec-fetch-site':a0_0x39af8e(0x166),'sec-fetch-user':'?1','upgrade-insecure-requests':'1','user-agent':a0_0x39af8e(0x135)}}),'WRITE_MESSAGE_HTTP_CONFIG':(_0x38291b,_0x1f3a2f)=>({'headers':{'accept':a0_0x39af8e(0x159),'accept-encoding':'gzip,\x20deflate,\x20br','accept-language':a0_0x39af8e(0x11f),'connection':'keep-alive','content-type':a0_0x39af8e(0x13c),'cookie':_0x38291b+';\x20compte='+_0x1f3a2f+a0_0x39af8e(0x156)+_0x1f3a2f+';\x20_ga=GA1.2.490358059.1683208319;\x20_gid=GA1.2.1148489241.1683208319;\x20__gads=ID=8e03875306c449c6-22790dab88df0074:T=1683208320:RT=1683208320:S=ALNI_MasidzVb7xQcb0qS7Hrb-gTpCYFkQ;\x20__gpi=UID=0000057b04df1c7f:T=1683208320:RT='+timeStampInSeconds()+a0_0x39af8e(0x161)+_0x1f3a2f+a0_0x39af8e(0x156)+_0x1f3a2f+';\x20'+obtenerYTime(timeStampInSeconds()),'host':a0_0x39af8e(0x125),'origin':a0_0x39af8e(0x12e),'referer':a0_0x39af8e(0x123)+location+a0_0x39af8e(0x134),'sec-ch-ua':a0_0x39af8e(0x16c),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':a0_0x39af8e(0x143),'sec-fetch-dest':'empty','sec-fetch-mode':a0_0x39af8e(0x16e),'sec-fetch-site':a0_0x39af8e(0x166),'user-agent':a0_0x39af8e(0x12b)}}),'RSS_HTTP_CONFIG':(_0x2da3bb,_0x38adfc)=>({'accept':a0_0x39af8e(0x13d),'cookie':_0x2da3bb+a0_0x39af8e(0x163)+timeStampInSeconds()+a0_0x39af8e(0x121)+_0x38adfc+';\x20ywm='+_0x38adfc+';\x20'+obtenerYTime(timeStampInSeconds())+a0_0x39af8e(0x149),'accept-encoding':a0_0x39af8e(0x14c),'accept-language':a0_0x39af8e(0x11f),'connection':a0_0x39af8e(0x12c),'host':a0_0x39af8e(0x125),'referer':'https://yopmail.com/'+location+'/wm','sec-ch-ua':a0_0x39af8e(0x16c),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':a0_0x39af8e(0x142),'sec-fetch-dest':a0_0x39af8e(0x15e),'sec-fetch-mode':a0_0x39af8e(0x13a),'sec-fetch-site':a0_0x39af8e(0x126),'sec-fetch-user':'?1','upgrade-insecure-requests':'1','user-agent':'Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/113.0.0.0\x20Safari/537.36'}),'WEBMAIL_JS_URL':_0x4ad865=>'https://yopmail.com/ver/'+_0x4ad865+a0_0x39af8e(0x16f),'ERROR_MAIL_INVALID':a0_0x39af8e(0x139),'ERROR_SEARCH_INVALID':a0_0x39af8e(0x13f),'ERROR_LOAD_PAGE':a0_0x39af8e(0x14d),'ERROR_GET_INBOX':a0_0x39af8e(0x15a),'ERROR_DELETE_INBOX':a0_0x39af8e(0x118),'ERROR_READ_MESSAGE':a0_0x39af8e(0x171),'ERROR_WRITE_MESSAGE':a0_0x39af8e(0x11c),'ERROR_DELETE_MESSAGE':a0_0x39af8e(0x11b),'ERROR_PARAMETERS_INVALID':a0_0x39af8e(0x11d),'ERROR_GET_COOKIES':'Error\x20getting\x20cookies','ERROR_GET_VERSION':a0_0x39af8e(0x133),'ERROR_MISSING_PARAMETERS':a0_0x39af8e(0x12f),'ERROR_GET_TOTAL_MAILS':a0_0x39af8e(0x15f),'COOKIE':_0x369427=>{const _0xe3b153=a0_0x39af8e;return{'name':'ygen','value':_0x369427,'domain':_0xe3b153(0x13b),'url':'https://yopmail.com/','path':'/','httpOnly':![],'secure':![]};},'TEST_MAIL':'test@yopmail.com','INBOX_FILE':path[a0_0x39af8e(0x15b)](a0_0x39af8e(0x165),'archives',a0_0x39af8e(0x16b)),'MAIL_CONTENT':path['resolve'](a0_0x39af8e(0x165),a0_0x39af8e(0x127),a0_0x39af8e(0x157)),'HTML_ID':path[a0_0x39af8e(0x15b)](a0_0x39af8e(0x165),'archives',a0_0x39af8e(0x168)),'HTML_SUBJECT':path['resolve']('tests','archives','mailHTML_subject.html'),'HTML_CONTENT':path['resolve']('tests',a0_0x39af8e(0x127),a0_0x39af8e(0x122)),'S_INPUT_MAIL_GENERATE':a0_0x39af8e(0x145),'SELECTOR_SUBMIT':a0_0x39af8e(0x12a),'SELECTOR_FROM':a0_0x39af8e(0x119),'SELECTOR_DATE':a0_0x39af8e(0x120),'SELECTOR_FROM_ALT':'div.fl\x20>\x20div.md.text.zoom.nw.f18\x20>\x20span.ellipsis.b','SELECTOR_DATE_ALT':'div.fl\x20>\x20div.md.text.zoom.nw.f18\x20>\x20span.ellipsis:last-child','SELECTOR_MAIL':a0_0x39af8e(0x16d),'possibleKeys':['id',a0_0x39af8e(0x150),a0_0x39af8e(0x129),a0_0x39af8e(0x11e)]}); \ No newline at end of file +'use strict';const a0_0x49eb7c=a0_0x582f;(function(_0x4ba611,_0xce60bc){const _0x4bc141=a0_0x582f,_0x353bfc=_0x4ba611();while(!![]){try{const _0x53c524=parseInt(_0x4bc141(0x1ab))/0x1*(parseInt(_0x4bc141(0x19d))/0x2)+parseInt(_0x4bc141(0x18e))/0x3+parseInt(_0x4bc141(0x185))/0x4+-parseInt(_0x4bc141(0x19c))/0x5*(parseInt(_0x4bc141(0x1b4))/0x6)+-parseInt(_0x4bc141(0x1c5))/0x7+-parseInt(_0x4bc141(0x1d2))/0x8+parseInt(_0x4bc141(0x1ba))/0x9;if(_0x53c524===_0xce60bc)break;else _0x353bfc['push'](_0x353bfc['shift']());}catch(_0x129186){_0x353bfc['push'](_0x353bfc['shift']());}}}(a0_0x1c20,0x419ef));function a0_0x1c20(){const _0x4b8239=['none','/webmail.js','.yopmail.com','tests','es-ES,es;q=0.9','yopmail.com','getInbox():\x20Error\x20getting\x20Inbox\x20page','\x22Google\x20Chrome\x22;v=\x22113\x22,\x20\x22Chromium\x22;v=\x22113\x22,\x20\x22Not-A.Brand\x22;v=\x2224\x22','1207264zRMMzf',':RT=','parameters\x20\x27mail\x27\x20is\x20required','floor',';\x20__gads=ID=9a0b3cce9ff31bac:T=','gzip,\x20deflate,\x20br','now','readFileSync','Error\x20getting\x20total\x20number\x20of\x20mails','1474617WHQnMv',';\x20compte=','cors','&r_c=&id=&ad=0','input#yp','parameters\x20\x27_search\x27\x20keys\x20is\x20invalid,\x20try\x20again\x20with\x20(subject\x20ot\x20content)','navigate','div.fl\x20>\x20div.md.text.zoom.nw.f24\x20>\x20span.ellipsis.b','freeze','No\x20se\x20encontró\x20la\x20función','document','/writepost','iframe','../.cache/location','157690JIDcxV','23032rUvmap','ygen','join','existsSync','&id=m',';\x20_ga=GA1.2.503151223.1683393694;\x20_gid=GA1.2.1659462416.1683393694;\x20__gads=ID=1aef015d5c605919-2289ab29f27f0062:T=1683393694:RT=1683393694:S=ALNI_MYhXB3g-Ape8Bl2op45lGwvANkLFg;\x20__gpi=UID=000009f291461986:T=1683393694:RT=',':S=ALNI_MbohrBpXt1O26O3LDmi-KRsCVPhcw;\x20__eoi=\x22ID=5cd00b43a530b6a4:T=','archives','&ctrl=&yp=','/inbox?login=','same-origin','keep-alive','application/x-www-form-urlencoded','&id=','12mRqgcF','div.fl\x20>\x20div.md.text.zoom.nw.f18\x20>\x20span.ellipsis:last-child',';\x20ywm=','subject','mailHTML_id.html','path',':S=AA-Afjb4QKVvFIwSmOYMSnui2gGd\x22;\x20FCNEC=%5B%5B%22AKsRol_M2LZFqBb7LSYXadLKqvJ5hTBhxAex9zsoE4N4YD_W5EKTjaIdnSjUL1onQWaOaUq-2HI8vZCE9bqnfMfFE9XOzzqfKK3c3UA5WvJQYW6YtylSfhXH3FZ4WTR9pzl8dTHsGaiJSwztPBvgXHwUPGcOlsELSQ%3D%3D%22%5D%5D;compte=','&p=1&d=','exports','96PTfilh','Error\x20getting\x20cookies','timestamp','utf8','\x22Windows\x22',':S=ALNI_MZM6T_Gt5i9mVk7fSPYTS_lNnT05A;\x20compte=','3146850rNJYDy','ytime=','Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/113.0.0.0\x20Safari/537.36','deleteMessage():\x20Error\x20delete\x20message','getMail():\x20Error\x20getting\x20YOPmail\x20page','Error\x20getting\x20version.\x20Error\x20loading\x20page','mailHTML_subject.html','/mail?b=','resolve','\x22Not_A\x20Brand\x22;v=\x2299\x22,\x20\x22Chromium\x22;v=\x22121\x22,\x20\x22Google\x20Chrome\x22;v=\x22121\x22','&r_c=&id=','2663549AJyGLM','#geny','*/*','Mozilla/5.0\x20(Windows\x20NT\x2010.0;\x20Win64;\x20x64)\x20AppleWebKit/537.36\x20(KHTML,\x20like\x20Gecko)\x20Chrome/112.0.0.0\x20Safari/537.36','Windows','https://yopmail.com/ver/','/wm','mailContent.json','getHours','getMinutes','div.fl\x20>\x20div.md.text.zoom.nw.f18\x20>\x20span.ellipsis.b','deleteInbox():\x20Error\x20delete\x20Inbox\x20page','&v=','1018392IWOysx','text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7','from','https://yopmail.com/'];a0_0x1c20=function(){return _0x4b8239;};return a0_0x1c20();}function a0_0x582f(_0x324fef,_0x5c8774){const _0x1c2020=a0_0x1c20();return a0_0x582f=function(_0x582fa9,_0x7e52a1){_0x582fa9=_0x582fa9-0x17c;let _0x1565d2=_0x1c2020[_0x582fa9];return _0x1565d2;},a0_0x582f(_0x324fef,_0x5c8774);}const path=require(a0_0x49eb7c(0x1b0)),fs=require('fs');function timeStampInSeconds(){const _0x26da5b=a0_0x49eb7c;return Math[_0x26da5b(0x188)](Date[_0x26da5b(0x18b)]()/0x3e8);}function obtenerYTime(_0x3166aa){const _0x3faccf=a0_0x49eb7c,_0x426988=_0x3166aa*0x3e8,_0x2359d8=new Date(_0x426988),_0x30c298=_0x2359d8[_0x3faccf(0x1cd)](),_0x302d49=_0x2359d8[_0x3faccf(0x1ce)]();return _0x3faccf(0x1bb)+_0x30c298+':'+_0x302d49+';';}let location='es',pathLocation=path[a0_0x49eb7c(0x19f)](__dirname,a0_0x49eb7c(0x19b));fs[a0_0x49eb7c(0x1a0)](pathLocation)&&(location=fs[a0_0x49eb7c(0x18c)](pathLocation,a0_0x49eb7c(0x1b7)));module[a0_0x49eb7c(0x1b3)]=Object[a0_0x49eb7c(0x196)]({'BASE_URL':a0_0x49eb7c(0x17c),'GENERATOR_URL':a0_0x49eb7c(0x17c)+location+'/email-generator','READ_MAIL_URL':(_0x1022c4,_0x41fd07)=>'https://yopmail.com/'+location+a0_0x49eb7c(0x1c1)+_0x1022c4+a0_0x49eb7c(0x1a1)+_0x41fd07,'WRITE_MAIL_URL':_0x5f111a=>a0_0x49eb7c(0x17c)+location+'/write?b='+_0x5f111a+a0_0x49eb7c(0x1aa),'DELETE_INBOX_URL':(_0x4b95c3,_0x231545,_0x28d9f9,_0x9ec7b6,_0x3dc71e)=>a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1a6)+_0x4b95c3+'&p=1&d=all&ctrl='+_0x231545+'&yp='+_0x28d9f9+'&yj='+_0x9ec7b6+a0_0x49eb7c(0x1d1)+_0x3dc71e+a0_0x49eb7c(0x1c4),'DELETE_MESSAGE_URL':(_0x1242a1,_0x58d6ae,_0x39eb11,_0x2ab129,_0x4ad2eb)=>a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1a6)+_0x1242a1+a0_0x49eb7c(0x1b2)+_0x58d6ae+a0_0x49eb7c(0x1a5)+_0x39eb11+'&yj='+_0x2ab129+a0_0x49eb7c(0x1d1)+_0x4ad2eb+a0_0x49eb7c(0x1c4),'SEND_MESSAGE_URL':a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x199),'INPUT_YP':a0_0x49eb7c(0x192),'REGEX_LOCATION':/lang=\"(.*?)\"/,'REGEX_YJ':/&yj=([^&]+)&v=/,'REGEX_TOTAL_MAILS':/w\.finrmail\((.*?)\)/,'INBOX_URL':(_0x10de78,_0x53e420,_0x344cf2,_0x1c5cf0,_0x5b3462=0x1)=>a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1a6)+_0x10de78+'&p='+_0x5b3462+'&d=&ctrl=&yp='+_0x53e420+'&yj='+_0x344cf2+a0_0x49eb7c(0x1d1)+_0x1c5cf0+a0_0x49eb7c(0x191),'INBOX_HTTP_CONFIG':(_0x1df622,_0x544deb)=>({'headers':{'accept':a0_0x49eb7c(0x1d3),'cookie':_0x1df622+';\x20compte='+_0x544deb+a0_0x49eb7c(0x1ad)+_0x544deb+a0_0x49eb7c(0x189)+timeStampInSeconds()+a0_0x49eb7c(0x186)+timeStampInSeconds()+':S=ALNI_MZ3k3gFQXDYCyC-n7CnlRltSEFoVQ;\x20__gpi=UID=00000a0a4f90dd17:T='+timeStampInSeconds()+a0_0x49eb7c(0x186)+timeStampInSeconds()+a0_0x49eb7c(0x1a3)+timeStampInSeconds()+':RT='+timeStampInSeconds()+a0_0x49eb7c(0x1b1)+_0x544deb+';\x20ywm='+_0x544deb+';\x20'+obtenerYTime(timeStampInSeconds()),'accept-encoding':a0_0x49eb7c(0x18a),'accept-language':a0_0x49eb7c(0x181),'connection':a0_0x49eb7c(0x1a8),'host':a0_0x49eb7c(0x182),'referer':a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1cb),'sec-ch-ua':a0_0x49eb7c(0x1c3),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':'Windows','sec-fetch-dest':a0_0x49eb7c(0x19a),'sec-fetch-mode':a0_0x49eb7c(0x194),'sec-fetch-site':a0_0x49eb7c(0x1a7),'sec-fetch-user':'?1','upgrade-insecure-requests':'1','user-agent':a0_0x49eb7c(0x1c8)}}),'WRITE_MESSAGE_HTTP_CONFIG':(_0x11415a,_0x3188e6)=>({'headers':{'accept':a0_0x49eb7c(0x1c7),'accept-encoding':a0_0x49eb7c(0x18a),'accept-language':a0_0x49eb7c(0x181),'connection':a0_0x49eb7c(0x1a8),'content-type':a0_0x49eb7c(0x1a9),'cookie':_0x11415a+a0_0x49eb7c(0x18f)+_0x3188e6+a0_0x49eb7c(0x1ad)+_0x3188e6+';\x20_ga=GA1.2.490358059.1683208319;\x20_gid=GA1.2.1148489241.1683208319;\x20__gads=ID=8e03875306c449c6-22790dab88df0074:T=1683208320:RT=1683208320:S=ALNI_MasidzVb7xQcb0qS7Hrb-gTpCYFkQ;\x20__gpi=UID=0000057b04df1c7f:T=1683208320:RT='+timeStampInSeconds()+':S=ALNI_MYMeBMqh92Qfh-oIx02VDmWeqsdAA;\x20compte='+_0x3188e6+a0_0x49eb7c(0x1ad)+_0x3188e6+';\x20'+obtenerYTime(timeStampInSeconds()),'host':a0_0x49eb7c(0x182),'origin':'https://yopmail.com','referer':a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1cb),'sec-ch-ua':a0_0x49eb7c(0x184),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':a0_0x49eb7c(0x1c9),'sec-fetch-dest':'empty','sec-fetch-mode':a0_0x49eb7c(0x190),'sec-fetch-site':a0_0x49eb7c(0x1a7),'user-agent':a0_0x49eb7c(0x1bc)}}),'RSS_HTTP_CONFIG':(_0x20a4b6,_0x5383e7)=>({'accept':a0_0x49eb7c(0x1d3),'cookie':_0x20a4b6+a0_0x49eb7c(0x1a2)+timeStampInSeconds()+a0_0x49eb7c(0x1b9)+_0x5383e7+a0_0x49eb7c(0x1ad)+_0x5383e7+';\x20'+obtenerYTime(timeStampInSeconds())+'\x20_gat=1;','accept-encoding':'gzip,\x20deflate,\x20br','accept-language':a0_0x49eb7c(0x181),'connection':a0_0x49eb7c(0x1a8),'host':'yopmail.com','referer':a0_0x49eb7c(0x17c)+location+a0_0x49eb7c(0x1cb),'sec-ch-ua':a0_0x49eb7c(0x184),'sec-ch-ua-mobile':'?0','sec-ch-ua-platform':a0_0x49eb7c(0x1b8),'sec-fetch-dest':a0_0x49eb7c(0x198),'sec-fetch-mode':a0_0x49eb7c(0x194),'sec-fetch-site':a0_0x49eb7c(0x17d),'sec-fetch-user':'?1','upgrade-insecure-requests':'1','user-agent':a0_0x49eb7c(0x1bc)}),'WEBMAIL_JS_URL':_0x2dc3cf=>a0_0x49eb7c(0x1ca)+_0x2dc3cf+a0_0x49eb7c(0x17e),'ERROR_MAIL_INVALID':a0_0x49eb7c(0x187),'ERROR_SEARCH_INVALID':a0_0x49eb7c(0x193),'ERROR_LOAD_PAGE':a0_0x49eb7c(0x1be),'ERROR_GET_INBOX':a0_0x49eb7c(0x183),'ERROR_DELETE_INBOX':a0_0x49eb7c(0x1d0),'ERROR_READ_MESSAGE':'readMessage():\x20Error\x20read\x20message','ERROR_WRITE_MESSAGE':'writeMessage():\x20Error\x20write\x20message','ERROR_DELETE_MESSAGE':a0_0x49eb7c(0x1bd),'ERROR_PARAMETERS_INVALID':a0_0x49eb7c(0x197),'ERROR_GET_COOKIES':a0_0x49eb7c(0x1b5),'ERROR_GET_VERSION':a0_0x49eb7c(0x1bf),'ERROR_MISSING_PARAMETERS':'Missing\x20parameters','ERROR_GET_TOTAL_MAILS':a0_0x49eb7c(0x18d),'COOKIE':_0x2b5988=>{const _0x421660=a0_0x49eb7c;return{'name':_0x421660(0x19e),'value':_0x2b5988,'domain':_0x421660(0x17f),'url':_0x421660(0x17c),'path':'/','httpOnly':![],'secure':![]};},'TEST_MAIL':'test@yopmail.com','INBOX_FILE':path['resolve'](a0_0x49eb7c(0x180),a0_0x49eb7c(0x1a4),'inbox.json'),'MAIL_CONTENT':path[a0_0x49eb7c(0x1c2)](a0_0x49eb7c(0x180),'archives',a0_0x49eb7c(0x1cc)),'HTML_ID':path[a0_0x49eb7c(0x1c2)]('tests','archives',a0_0x49eb7c(0x1af)),'HTML_SUBJECT':path[a0_0x49eb7c(0x1c2)]('tests','archives',a0_0x49eb7c(0x1c0)),'HTML_CONTENT':path[a0_0x49eb7c(0x1c2)](a0_0x49eb7c(0x180),a0_0x49eb7c(0x1a4),'mailHTML_content.html'),'S_INPUT_MAIL_GENERATE':a0_0x49eb7c(0x1c6),'SELECTOR_SUBMIT':'div.fl\x20>\x20div.ellipsis.nw.b.f18','SELECTOR_FROM':a0_0x49eb7c(0x195),'SELECTOR_DATE':'div.fl\x20>\x20div.md.text.zoom.nw.f24\x20>\x20span.ellipsis:last-child','SELECTOR_FROM_ALT':a0_0x49eb7c(0x1cf),'SELECTOR_DATE_ALT':a0_0x49eb7c(0x1ac),'SELECTOR_MAIL':'#mail','possibleKeys':['id',a0_0x49eb7c(0x1d4),a0_0x49eb7c(0x1ae),a0_0x49eb7c(0x1b6)]}); \ No newline at end of file diff --git a/dist/index.js b/dist/index.js index d479195..c52aa3f 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1 +1 @@ -const axios=require("axios");const cheerio=require("cheerio");const constants=require("./constants.js");const utils=require("./utils.js");async function getMail(){try{const response=await axios.get(constants.GENERATOR_URL);if(response.status!==200){console.error(constants.ERROR_LOAD_PAGE);return null}const $=cheerio.load(response.data);const genEmail=$(constants.S_INPUT_MAIL_GENERATE).text();return genEmail.split(";")[1]||genEmail}catch(error){console.error(constants.ERROR_LOAD_PAGE);console.error(error.message);throw new Error(error)}}async function getInbox(mailAddress,search={},settings={}){try{settings=settings||{};const mail=(mailAddress.split("@")[0]||"").toLowerCase()||mailAddress;const{cookie:cookie,yp:yp,ver:ver}=await utils.getCookiesAndYP();const yj=await utils.getYJ(cookie);return await utils.detailInbox(mail,yp,yj,ver,cookie,search,settings)}catch(error){console.error(constants.ERROR_GET_INBOX);console.error(error.message);throw new Error(error)}}async function deleteInbox(mail){try{const{cookie:cookie,yp:yp}=await utils.getCookiesAndYP();const yj=await utils.getYJ(cookie);const ver=await utils.getVersion();const{inbox:inbox}=await getInbox(mail);if(inbox.length>0){const id=inbox[0].id;const url=constants.DELETE_INBOX_URL(mail,id,yp,yj,ver);const response=await axios.get(url,constants.INBOX_HTTP_CONFIG(cookie,mail));return Boolean(200===response.status)}else{return false}}catch(error){console.error(constants.ERROR_DELETE_INBOX);console.error(error.message);throw new Error(error)}}async function readMessage(mail,id,format,selector=""){try{const{cookie:cookie}=await utils.getCookiesAndYP();const response=await axios.get(constants.READ_MAIL_URL(mail,id),constants.INBOX_HTTP_CONFIG(cookie,mail));const $=cheerio.load(response.data);const submit=$(constants.SELECTOR_SUBMIT).text();const fromSelector=$(constants.SELECTOR_FROM);const dateSelector=$(constants.SELECTOR_DATE);const from=fromSelector.length?fromSelector.text():$(constants.SELECTOR_FROM_ALT).text();const date=dateSelector.length?dateSelector.text().replace(from,""):$(constants.SELECTOR_DATE_ALT).text();let message;if(selector){selector=`${constants.SELECTOR_MAIL} ${selector}`;message=format.toLowerCase()==="html"?$(selector).html():$(selector).text().trim()}else{selector="#mail";message=format.toLowerCase()==="html"?$(selector).html():$(selector).text().trim()}return{id:id,submit:submit,from:from,date:date,selector:selector,format:format,data:message}}catch(error){console.error(constants.ERROR_READ_MESSAGE);console.error(error.message);throw new Error(error)}}async function writeMessage(mail,to,subject,body){try{if(!mail||!to||!subject||!body){console.error(constants.ERROR_MISSING_PARAMETERS)}const{cookie:cookie}=await utils.getCookiesAndYP();const response=await axios.get(constants.WRITE_MAIL_URL(mail),constants.INBOX_HTTP_CONFIG(cookie,mail));if(response.status===200){const data={msgfrom:`${mail}@yopmail.com`,msgto:to,msgsubject:subject,msgbody:body};const sendMessage=await axios.post(constants.SEND_MESSAGE_URL,data,constants.WRITE_MESSAGE_HTTP_CONFIG(cookie,mail));return sendMessage.data}return response.data}catch(error){console.error(constants.ERROR_WRITE_MESSAGE);console.error(error.message);throw new Error(error)}}async function deleteMessage(mail,id){try{const{cookie:cookie,yp:yp}=await utils.getCookiesAndYP();const yj=await utils.getYJ(cookie);const ver=await utils.getVersion();const{inbox:inbox}=await getInbox(mail,{id:id});if(inbox.length>0){const url=constants.DELETE_MESSAGE_URL(mail,id,yp,yj,ver);const response=await axios.get(url,constants.INBOX_HTTP_CONFIG(cookie,mail));return Boolean(200===response.status)}else{return false}}catch(error){console.error(constants.ERROR_DELETE_MESSAGE);console.error(error.message);throw new Error(error)}}module.exports={getMail:getMail,getInbox:getInbox,deleteInbox:deleteInbox,readMessage:readMessage,writeMessage:writeMessage,deleteMessage:deleteMessage}; \ No newline at end of file +"use strict";const axios=require("axios");const cheerio=require("cheerio");const constants=require("./constants.js");const utils=require("./utils.js");async function getMail(){try{const a=await axios.get(constants.GENERATOR_URL);if(a.status!==200){console.error(constants.ERROR_LOAD_PAGE);return null}const b=cheerio.load(a.data);const c=b(constants.S_INPUT_MAIL_GENERATE).text();return c.split(";")[1]||c}catch(a){console.error(constants.ERROR_LOAD_PAGE);console.error(a.message);throw new Error(a)}}async function getInbox(a,b={},c={}){try{c=c||{};const d=(a.split("@")[0]||"").toLowerCase()||a;const{cookie:e,yp:f,ver:g}=await utils.getCookiesAndYP();const h=await utils.getYJ(e,g);return await utils.detailInbox(d,f,h,g,e,b,c)}catch(a){console.error(constants.ERROR_GET_INBOX);console.error(a.message);throw new Error(a)}}async function deleteInbox(a){try{const{cookie:b,yp:c}=await utils.getCookiesAndYP();const d=await utils.getYJ(b);const e=await utils.getVersion();const{inbox:f}=await getInbox(a);if(f.length>0){const g=f[0].id;const h=constants.DELETE_INBOX_URL(a,g,c,d,e);const i=await axios.get(h,constants.INBOX_HTTP_CONFIG(b,a));return Boolean(200===i.status)}else{return false}}catch(a){console.error(constants.ERROR_DELETE_INBOX);console.error(a.message);throw new Error(a)}}async function readMessage(a,b,c,d=""){try{const{cookie:e}=await utils.getCookiesAndYP();const f=await axios.get(constants.READ_MAIL_URL(a,b),constants.INBOX_HTTP_CONFIG(e,a));const g=cheerio.load(f.data);const h=g(constants.SELECTOR_SUBMIT).text();const i=g(constants.SELECTOR_FROM);const j=g(constants.SELECTOR_DATE);const k=i.length?i.text():g(constants.SELECTOR_FROM_ALT).text();const l=j.length?j.text().replace(k,""):g(constants.SELECTOR_DATE_ALT).text();let m;if(d){d=`${constants.SELECTOR_MAIL} ${d}`;m=c.toLowerCase()==="html"?g(d).html():g(d).text().trim()}else{d="#mail";m=c.toLowerCase()==="html"?g(d).html():g(d).text().trim()}return{id:b,submit:h,from:k,date:l,selector:d,format:c,data:m}}catch(a){console.error(constants.ERROR_READ_MESSAGE);console.error(a.message);throw new Error(a)}}async function writeMessage(a,b,c,d){try{if(!a||!b||!c||!d){console.error(constants.ERROR_MISSING_PARAMETERS)}const{cookie:e}=await utils.getCookiesAndYP();const f=await axios.get(constants.WRITE_MAIL_URL(a),constants.INBOX_HTTP_CONFIG(e,a));if(f.status===200){const f={msgfrom:`${a}@yopmail.com`,msgto:b,msgsubject:c,msgbody:d};const g=await axios.post(constants.SEND_MESSAGE_URL,f,constants.WRITE_MESSAGE_HTTP_CONFIG(e,a));return g.data}return f.data}catch(a){console.error(constants.ERROR_WRITE_MESSAGE);console.error(a.message);throw new Error(a)}}async function deleteMessage(a,b){try{const{cookie:c,yp:d}=await utils.getCookiesAndYP();const e=await utils.getYJ(c);const f=await utils.getVersion();const{inbox:g}=await getInbox(a,{id:b});if(g.length>0){const g=constants.DELETE_MESSAGE_URL(a,b,d,e,f);const h=await axios.get(g,constants.INBOX_HTTP_CONFIG(c,a));return Boolean(200===h.status)}else{return false}}catch(a){console.error(constants.ERROR_DELETE_MESSAGE);console.error(a.message);throw new Error(a)}}module.exports={getMail:getMail,getInbox:getInbox,deleteInbox:deleteInbox,readMessage:readMessage,writeMessage:writeMessage,deleteMessage:deleteMessage}; \ No newline at end of file diff --git a/dist/test.spec.js b/dist/test.spec.js index 13c925d..9d9cd31 100644 --- a/dist/test.spec.js +++ b/dist/test.spec.js @@ -1,81 +1,83 @@ +"use strict"; + const constants = require('./constants.js'); -const easyYopmail = ({ getInbox, getMailDetail, deleteMail, deleteInbox } = require('./index.js')); +const easyYopmail = ({ + getInbox, + getMailDetail, + deleteMail, + deleteInbox +} = require('./index.js')); const assert = require('assert'); - let mails = []; let inbox = undefined; let mailDetail = undefined; let firstMail = undefined; let secondMail = undefined; - describe('🧪 TESTING GENERATE E-MAILS', () => { - it('should, generate email dynamically', async () => { - mails.push((await easyYopmail.getMail())); - console.log(mails[0]); - assert.match(mails[0], /yopmail/g); - assert.ok(mails[0]); - }); - it('should, generate new email and be differents', async () => { - mails.push((await easyYopmail.getMail())); - console.log(mails[1]); - assert.match(mails[1], /yopmail/g); - assert.notStrictEqual(mails[0], mails[1]); - }); - it('should, generate new email and be diferent to before', async () => { - mails.push((await easyYopmail.getMail())); - console.log(mails[2]); - assert.match(mails[2], /yopmail/g); - assert.notStrictEqual(mails[1], mails[2]); - }); + it('should, generate email dynamically', async () => { + mails.push(await easyYopmail.getMail()); + console.log(mails[0]); + assert.match(mails[0], /yopmail/g); + assert.ok(mails[0]); + }); + it('should, generate new email and be differents', async () => { + mails.push(await easyYopmail.getMail()); + console.log(mails[1]); + assert.match(mails[1], /yopmail/g); + assert.notStrictEqual(mails[0], mails[1]); + }); + it('should, generate new email and be diferent to before', async () => { + mails.push(await easyYopmail.getMail()); + console.log(mails[2]); + assert.match(mails[2], /yopmail/g); + assert.notStrictEqual(mails[1], mails[2]); + }); }); - describe('🧪 TESTING INBOX', () => { + before(async () => { + inbox = await easyYopmail.getInbox(constants.TEST_MAIL); + }); + it('should, inbox has properties', () => { + console.log(inbox); + assert.ok(inbox.hasOwnProperty('settings')); + assert.ok(inbox.hasOwnProperty('search')); + assert.ok(inbox.hasOwnProperty('totalInbox')); + assert.ok(inbox.hasOwnProperty('totalPages')); + assert.ok(inbox.hasOwnProperty('mailFromPage')); + assert.ok(inbox.hasOwnProperty('totalGetMails')); + assert.ok(inbox.hasOwnProperty('inbox')); + }); - before(async () => { - inbox = await easyYopmail.getInbox(constants.TEST_MAIL); - }); - - it('should, inbox has properties', () => { - console.log(inbox); - assert.ok(inbox.hasOwnProperty('settings')); - assert.ok(inbox.hasOwnProperty('search')); - assert.ok(inbox.hasOwnProperty('totalInbox')); - assert.ok(inbox.hasOwnProperty('totalPages')); - assert.ok(inbox.hasOwnProperty('mailFromPage')); - assert.ok(inbox.hasOwnProperty('totalGetMails')); - assert.ok(inbox.hasOwnProperty('inbox')); - }); - - // it('should, inbox has property maxPage', () => { - // - // }); - // - // it('should, default number page getting is 1', () => { - // assert.strictEqual(inbox.maxPage, 1); - // }); - // - // it('should, inbox has property pages ', () => { - // assert.ok(inbox.hasOwnProperty('pages')); - // }); - // - // it('should, property page is array', () => { - // assert.ok(Array.isArray(inbox.pages)); - // }); - // - // it('should, pages to equal 1', () => { - // assert.strictEqual(inbox.pages.length, 1); - // }); + // it('should, inbox has property maxPage', () => { + // + // }); + // + // it('should, default number page getting is 1', () => { + // assert.strictEqual(inbox.maxPage, 1); + // }); + // + // it('should, inbox has property pages ', () => { + // assert.ok(inbox.hasOwnProperty('pages')); + // }); + // + // it('should, property page is array', () => { + // assert.ok(Array.isArray(inbox.pages)); + // }); + // + // it('should, pages to equal 1', () => { + // assert.strictEqual(inbox.pages.length, 1); + // }); }); describe('🧪 TESTING WRITE EMAIL', () => { - it('should, Send email', async () => { - let time = new Date().getTime(); - let mail = 'sender01'; - let to = 'receiver01'; - let subject = 'testing_' + time; - let body = 'This a test that function writeMessage works! DEMO N°: ' + time; - let email = await easyYopmail.writeMessage(mail, to, subject, body); - console.log(email); - assert.strictEqual(email, 'OK|mobback|Your message has been sent'); - }); + it('should, Send email', async () => { + let a = new Date().getTime(); + let b = 'sender01'; + let c = 'receiver01'; + let d = 'testing_' + a; + let e = 'This a test that function writeMessage works! DEMO N°: ' + a; + let f = await easyYopmail.writeMessage(b, c, d, e); + console.log(f); + assert.strictEqual(f, 'OK|mobback|Your message has been sent'); + }); }); \ No newline at end of file diff --git a/dist/utils.js b/dist/utils.js index d1027d4..1d34d67 100644 --- a/dist/utils.js +++ b/dist/utils.js @@ -1 +1 @@ -const constants=require("./constants");const axios=require("axios");const cheerio=require("cheerio");const fs=require("fs");function setLocation(location){if(!location||typeof location!=="string")return false;fs.mkdirSync("../.cache",{recursive:true});fs.writeFileSync("../.cache/location",location)}async function validateSearch(search){const result=constants.possibleKeys.some((key=>Object.keys(search).includes(key)||null));if(!result){console.error(constants.ERROR_PARAMETERS_INVALID);return{}}return Object.keys(search).reduce(((acc,key)=>{if(constants.possibleKeys.includes(key)){acc[key]=search[key]}return acc}),{})}async function getVersion(){const response=await axios.get(constants.BASE_URL);if(response.status===200){try{return response.data.match(/\/ver\/(\d+\.\d+)\//)[1]}catch(error){console.error(constants.ERROR_GET_VERSION,error.message)}}else{console.error(constants.ERROR_GET_VERSION)}}async function getCookiesAndYP(){const response=await axios.get(constants.BASE_URL);if(response.status===200){try{const $=cheerio.load(response.data);const yp=$(constants.INPUT_YP).val();const cookie=response.headers["set-cookie"].map((x=>x.split(";")[0])).join("; ");const location=response.data.match(constants.REGEX_LOCATION)[1];const ver=response.data.match(/\/ver\/(\d+\.\d+)\//)[1];setLocation(location);return{cookie:cookie,yp:yp,ver:ver}}catch(error){console.error(error.message)}}else{console.error(constants.ERROR_GET_COOKIES);return{cookie:null,yp:null}}}async function getYJ(cookie){const ver=getVersion();const options={headers:{Cookie:cookie}};const response=await axios.get(constants.WEBMAIL_JS_URL(ver),options);const match=response.data.match(constants.REGEX_YJ);return match?match[1]:null}async function getTotalMails(html){const match=html.match(constants.REGEX_TOTAL_MAILS);let totalMails=0;if(match){totalMails=match[1].split(",")[0]}else{console.log(constants.ERROR_GET_TOTAL_MAILS)}return Number(totalMails)}function shouldIncludeEmail(email,filteredSearch){return Object.entries(filteredSearch).every((([key,value])=>{switch(key){case"id":return email.id===value;case"from":return email.from===value;case"subject":return email.subject===value;case"timestamp":return email.timestamp===value;default:return false}}))}function parseEmail(element){const $=cheerio.load(element);const id=$(element).attr("id");const timestamp=$(element).find(".lmh").text();const from=$(element).find(".lmf").text();const subject=$(element).find(".lms").text();return{id:id,from:from,subject:subject,timestamp:timestamp}}function getDetailInboxFromPage(html,filteredSearch){const $=cheerio.load(html);const elements=$(".m");return elements.map(((index,element)=>parseEmail(element))).toArray().filter((email=>shouldIncludeEmail(email,filteredSearch)))}async function fetchInboxPage(mail,yp,yj,ver,pageNumber,cookie){let url=constants.INBOX_URL(mail,yp,yj,ver,pageNumber);let headers=constants.INBOX_HTTP_CONFIG(cookie,mail);return await axios.get(url,headers)}async function detailInbox(mail,yp,yj,ver,cookie,search={},settings={}){const pageNumber=1;const response=await fetchInboxPage(mail,yp,yj,ver,pageNumber,cookie);if(response.status!==200){console.error(constants.ERROR_LOAD_PAGE);return null}const inboxHtml=response.data;const totalMails=await getTotalMails(inboxHtml);let filteredSearch={};if(search&&Object.keys(search).length>0){filteredSearch=await validateSearch(search)}let currentPage=1;let hasNextPage=true;let mailFromPage={};const mailsPerPage=15;const emails=[];while(hasNextPage&&(settings.GET_ALL_MAILS===true||currentPage===1)){const currentPageHtml=currentPage===1?inboxHtml:(await fetchInboxPage(mail,yp,yj,currentPage,cookie)).data;const currentPageEmails=getDetailInboxFromPage(currentPageHtml,filteredSearch);mailFromPage[`page_${currentPage}`]=currentPageEmails.length;emails.push(...currentPageEmails);if(currentPage*mailsPerPage>=totalMails){hasNextPage=false}else{currentPage+=1}}return{settings:settings,search:filteredSearch,totalInbox:totalMails,totalPages:Math.ceil(totalMails/mailsPerPage),mailFromPage:mailFromPage,totalGetMails:emails.length,inbox:emails}}module.exports={getCookiesAndYP:getCookiesAndYP,getYJ:getYJ,detailInbox:detailInbox,getVersion:getVersion}; \ No newline at end of file +"use strict";const constants=require("./constants");const axios=require("axios");const cheerio=require("cheerio");const fs=require("fs");function setLocation(a){if(!a||typeof a!=="string")return false;fs.mkdirSync("../.cache",{recursive:true});fs.writeFileSync("../.cache/location",a)}async function validateSearch(a){const b=constants.possibleKeys.some((b=>Object.keys(a).includes(b)||null));if(!b){console.error(constants.ERROR_PARAMETERS_INVALID);return{}}return Object.keys(a).reduce(((b,c)=>{if(constants.possibleKeys.includes(c)){b[c]=a[c]}return b}),{})}async function getVersion(){const a=await axios.get(constants.BASE_URL);if(a.status===200){try{return a.data.match(/\/ver\/(\d+\.\d+)\//)[1]}catch(a){console.error(constants.ERROR_GET_VERSION,a.message)}}else{console.error(constants.ERROR_GET_VERSION)}}async function getCookiesAndYP(){const a=await axios.get(constants.BASE_URL);if(a.status===200){try{const b=cheerio.load(a.data);const c=b(constants.INPUT_YP).val();const d=a.headers["set-cookie"].map((a=>a.split(";")[0])).join("; ");const e=a.data.match(constants.REGEX_LOCATION)[1];const f=a.data.match(/\/ver\/(\d+\.\d+)\//)[1];setLocation(e);return{cookie:d,yp:c,ver:f}}catch(a){console.error(a.message)}}else{console.error(constants.ERROR_GET_COOKIES);return{cookie:null,yp:null}}}async function getYJ(a,b){const c={headers:{Cookie:a}};const d=await axios.get(constants.WEBMAIL_JS_URL(b),c);const e=d.data.match(constants.REGEX_YJ);return e?e[1]:null}async function getTotalMails(a){const b=a.match(constants.REGEX_TOTAL_MAILS);let c=0;if(b){c=b[1].split(",")[0]}else{console.log(constants.ERROR_GET_TOTAL_MAILS)}return Number(c)}function shouldIncludeEmail(a,b){return Object.entries(b).every((([b,c])=>{switch(b){case"id":return a.id===c;case"from":return a.from===c;case"subject":return a.subject===c;case"timestamp":return a.timestamp===c;default:return false}}))}function parseEmail(a){const b=cheerio.load(a);const c=b(a).attr("id");const d=b(a).find(".lmh").text();const e=b(a).find(".lmf").text();const f=b(a).find(".lms").text();return{id:c,from:e,subject:f,timestamp:d}}function getDetailInboxFromPage(a,b){const c=cheerio.load(a);const d=c(".m");return d.map(((a,b)=>parseEmail(b))).toArray().filter((a=>shouldIncludeEmail(a,b)))}async function fetchInboxPage(a,b,c,d,e,f){let g=constants.INBOX_URL(a,b,c,d,e);let h=constants.INBOX_HTTP_CONFIG(f,a);return await axios.get(g,h)}async function detailInbox(a,b,c,d,e,f={},g={}){const h=1;const i=await fetchInboxPage(a,b,c,d,h,e);if(i.status!==200){console.error(constants.ERROR_LOAD_PAGE);return null}const j=i.data;const k=await getTotalMails(j);let l={};if(f&&Object.keys(f).length>0){l=await validateSearch(f)}let m=1;let n=true;let o={};const p=15;const q=[];while(n&&(g.GET_ALL_MAILS===true||m===1)){const d=m===1?j:(await fetchInboxPage(a,b,c,m,e)).data;const f=getDetailInboxFromPage(d,l);o[`page_${m}`]=f.length;q.push(...f);if(m*p>=k){n=false}else{m+=1}}return{settings:g,search:l,totalInbox:k,totalPages:Math.ceil(k/p),mailFromPage:o,totalGetMails:q.length,inbox:q}}module.exports={getCookiesAndYP:getCookiesAndYP,getYJ:getYJ,detailInbox:detailInbox,getVersion:getVersion}; \ No newline at end of file diff --git a/package.json b/package.json index c5e97bf..181486f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "easy-yopmail", - "version": "4.0.23", + "version": "4.0.24", "description": "Easy-YOPmail (get mail address, inbox and read mail from YOPmail with nodeJS)", "main": "dist/index.js", "scripts": { @@ -38,13 +38,15 @@ "@babel/plugin-proposal-class-properties": "^7.18.6", "@babel/plugin-proposal-object-rest-spread": "^7.20.7", "@babel/plugin-proposal-optional-chaining": "^7.21.0", + "@babel/preset-env": "^7.23.9", + "babel-preset-minify": "^0.5.2", "babel-plugin-minify-mangle-names": "^0.5.1", "mocha": "10.1.0", "standard-version": "^9.5.0", "terser": "^5.17.1" }, "dependencies": { - "axios": "^1.4.0", + "axios": "^1.6.7", "cheerio": "^1.0.0-rc.10" } }