# Juno # # @Requires: 1.2.1 # @Version: 1.07 # updated quota warning to work with MB or GB quota sizes # updated Junk Mail download so From/Subject are recorded # @Version: 1.06 # german texts (with MrPostman 1.2.2+) # @Version: 1.05 # updated quota warning so it works with NetZero again # added "always turn off headers" option # @Version: 1.04 # warning instead of error, if there is no from: in message # @Version: 1.03 # added fallback, if quota message is not found # @Version: 1.02 # removed attachment.text so attachments with long names will be supported # @Version: 1.01 # updated baseurl to default to webmailb.juno.com/webmail, changed quotawarn msg.date to now(), # updated receive(msg) to use msg.link and fixed bug in downloading messages more than 20 messages # @Version: 1.00 # included changes of dpike21 (DWP) for netzero.com # @Version: 0.99 # Updated regular expressions to support changes on UnitedOnline's side # @Version: 0.91 # add support for embedded attachments, quota warning, multiple To: headers # @Version: 0.88 # eliminate duplicate message downloads if there are more than 10 messages # @Version: 0.86 # included version 0.85 of siafu_kali, small enhancements # ... sub getInfo local(info) info.name = "juno" info.authors[0] = "Siafu Kali " info.version = "1.07" info.updateService = "" info.documentationLink = "" info.options["folders"].order = 1 info.options["folders"].value = "Inbox, Junk Mail" info.options["folders"].label = "Folders" info.options["folders"].description = "The webmail folders to check for retrieval" info.options["onlyNew"].order = 2 info.options["onlyNew"].value = true info.options["onlyNew"].label = "Unread Only" info.options["onlyNew"].description = "Only download new messages" info.options["noHeaders"].order = 3 info.options["noHeaders"].value = true info.options["noHeaders"].label = "Always Turn Off Headers" info.options["noHeaders"].description = "Always turn off displaying all headers" info.options["maxNum"].order = 4 info.options["maxNum"].value = 100 info.options["maxNum"].label = "Max Number of Messages" info.options["maxNum"].description = "The maximum number of messages to check for retrieval" info.options["quotaWarn"].order = 5 info.options["quotaWarn"].value = true info.options["quotaWarn"].label = "Turn On Quota Notification" info.options["quotaWarn"].description = "Notify me when the quota has reached a certian limit" info.options["quotaPercent"].order = 6 info.options["quotaPercent"].value = 75 info.options["quotaPercent"].label = "Quota Percentage" info.options["quotaPercent"].description = "The percent of quota reached to trigger notification" #--- german texts info.options["folders"].de.label = "Ordner" info.options["folders"].de.description = "Webmail Ordner, aus denen Nachrichten heruntergeladen werden sollen" info.options["onlyNew"].de.label = "Nur ungelesene Nachrichten" info.options["onlyNew"].de.description = "Nur neue/ungelesene Nachrichten herunterladen" info.options["noHeaders"].de.label = "Kopfzeilen ausschalten" info.options["noHeaders"].de.description = "Anzeige aller Kopfzeilen immer ausschalten" info.options["maxNum"].de.label = "Max. Anzahl Nachrichten" info.options["maxNum"].de.description = "Die maximale Anzahl von Nachrichten, die überprüft bzw. heruntergeladen werden sollen" info.options["quotaWarn"].de.label = "Warnung bei voller Mailbox" info.options["quotaWarn"].de.description = "Benachrichtigung, wenn die Größe der Mailbox ein bestimmtes Limit erreicht hat" info.options["quotaPercent"].de.label = "Kontingent-Prozentsatz" info.options["quotaPercent"].de.description = "Prozentsatz der maximalen Größe der Mailbox, bei dem benachrichtigt werden soll" return info end sub getExtensions #--- all extensions known currently (2004-10-15) return list("@juno.com", "@netzero.com", "@netzero.net") end sub login(username,password) local(loginurl,params,status,page,found,isloggedin,baseurl,domain) found,domain = match(username,"@(.*)$") #--- set some basic settings to allow MrPostman doing some conversions, ... loginurl = "http://webmail." & domain & "/cgi-bin/login.cgi" if(domain=="netzero.com") #--- (DWP) changed on 2005-07-19 #loginurl = "http://webmail.netzero.net/cgi-bin/login.cgi" loginurl = "http://webmail.netzero.net/cgi-bin/nz-login.cgi" end #--- sizes and dates seem to be independent of the language size.locale = "en" size.unit = map("b",1,"k",1024,"m",1024*1024,"M",1024*1024) #--- let's log in: params["domain"] = domain params["LOGIN"] = username params["PASSWORD"] = password #--- find the Mail Home #--- Juno behaves differently depending on whether or not the user logged out properly last time setfollowredirects(false) status,page = post(loginurl,params) #--- If user logged out, we are redirected straight into Mail Home #found,baseurl = match(page,"HREF=\"(.*?)/[\d]+\"") baseurl = "http://webmailb.juno.com/webmail" #--- (DWP) added on 2005-07-19 if(domain=="netzero.com") baseurl = "http://webmaila.netzero.net/webmail" end #--- (jogeedaklown) added on 2005-08-26 if(domain=="netzero.net") baseurl = "http://webmaila.netzero.net/webmail" end status,page = get(baseurl&"/6") found = match(page, "You are signed in as\:") #--- If user did not log out properly, we are redirected to a JavaScript page if(!found) found,baseurl = match(baseurl, "(http://[^/]*)") found,page = match(page,"form action=\"(.*)/[\d]+\"") baseurl = baseurl & page end returnif(!found,false) setbaseurl(baseurl) msglink = "7?folder=" dellink = "7" composelink = "26" logoutlink = "14?type=signOut&GOTO_URL=http://my.juno.com" folders = split(info.options["folders"].value, "\s*,\s*") #--- Check the user's quota status,page=get("6") found,quotaMsg,quota = match(page,"(You are using (\d*)% of your \d*[M|G]B.*?limit.)") if(!found) found,quotaMsg,quota = match(page,"(You are using less than (\d*)% of your \d*[M|G]B.*?limit.)") end if(!found) #--- set to a default value quota = "0" end #--- Check the user's read options to determine what their web preferences are for displaying full headers status,page = get("48?page=5") displayHeaders = match(page,"") #--- Turn headers on for downloading mail if(!displayHeaders) info("Turning headers ON temporarily") status,page = get("48?command=save&headers=1") end return true end sub loginForReceive(username,password) local(ok,status,page,found,msglist,msgpat,numfound,link,block,i,msg) ok = login(username,password) returnif(!ok,false) #--- Get messages from each folder msgs = list() foreach(folders,folder) msgs1 = list() status,page = get(msglink & urlencode(folder)) found,msglist = match(page,"(.*)") #msgpat for only unread messages if(info.options["onlyNew"].value == true) msgpat = ".*?]*>.*?(\d+)([a-zA-Z]*)" end #msgpat for all messages if(info.options["onlyNew"].value == false) msgpat = "'(8\?[^']*folder=([^&]+)&msgNum=(.*?)&[^\']*).*?]*>.*?(\d+)([a-zA-Z]*)" end numfound,msgs1[].link,msgs1[].folder,msgs1[].id,msgs1[].size.value,msgs1[].size.unit = matchall(page,msgpat) #msgs = join(msgs,msgs1) #--- further pages: found,nextpagelink = match(page,"(href=javascript:MoveBlock\('next'\);)") block=2 while (found and size(msgs) <= integer(info.options["maxNum"].value)) msgs2 = list() status,page = get(msglink & urlencode(folder) & "&block="&block) block=block+1 numfound,msgs2[].link,msgs2[].folder,msgs2[].id,msgs2[].size.value,msgs2[].size.unit = matchall(page,msgpat) msgs1 = join(msgs1,msgs2) found,nextpagelink = match(page,"(href=javascript:MoveBlock\('next'\);)") end info("Checking Folder: " & folder & " (" & size(msgs1) & ") messages") msgs = join(msgs,msgs1) end #--- Notify user of quota if(info.options["quotaWarn"].value == true) if(integer(info.options["quotaPercent"].value) <= integer(quota)) info(quotaMsg) msg.link = "about:blank" msg.id = "QuotaWarning" msg.folder = "Inbox" msg.size.value = "1" msg.size.unit = "KB" msg.headers = map("Folder",msg.folder,true) msg.from = "MrPostman" msg.to = username msg.cc = "" msg.bcc = "" msg.date = now() msg.subject = "Quota has reached " & quota & "%" msg.charset = "ISO-8859-1" msg.mimetype = "text/plain" msg.text = quotaMsg msgs = join(msgs,list(msg)) end end return true end sub receive(msg) local(status,page,found,printlink,attachpat,numfound,attachment,attachlinks) local(received, msgtxt, headers, headtxt,folderhead,attachfound,to) if(msg.id != "QuotaWarning") #--- get all headers from the regular view #status,page = get("8?folder=" & urlencode(msg.folder) & "&msgNum=" & msg.id) if(msg.folder == "Junk Mail") msg.link = replace(msg.link,"Junk Mail","Junk%20Mail") end status,page = get(msg.link) #--- adding extra headers to the message (supported in RC2+) found,headtxt = match(page,"\s+
(.*?)
") headtxt = cleanHTML(headtxt) headtxt = replaceAll(headtxt,"\n\n","\n") #--- Juno adds line breaks where they shouldn't be in the received message header #--- we must fix this found,received = matchAll(headtxt,"^(Received:\s+.*?)\\n(?=\\n|[^\s])") headtxt = replaceAll(headtxt,"^(Received:\s+.*?)\\n(?=\\n|[^\s])","") foreach(received, rec) rec = replaceAll(rec,"\n","") rec = replaceAll(rec,"\t","\n\t") headtxt = headtxt & rec & "\n" end #--- Adding extra because the regexpression seems to lose the last header headtxt = headtxt & "Extra:" #--- Map headers to msg.headers numfound,headers[].name,headers[].value = matchall(headtxt,"^(\w[\w\d-]*):\s+(.*?)\\n(?=\\n|[^\s])") msg.headers = map(headers[].name,headers[].value,true) folderhead = map("Folder",msg.folder,true) msg.headers = merge(msg.headers,folderhead) #--- get To,From,Subject,Date,Cc,Bcc from headers found,msg.from = match(headtxt,"^From:\s*(.*?)$") if(!found) #--- some messages are without from, try to continue - changed from error to warning warning("Invalid page structure for message '" & msg.id & "'") end #--- Sometimes Juno puts a return character in the To and Cc fields found,to = match(replaceAll(headtxt," \n"," "),"^To:\s+(.*?)\\n(?:\\n|[^\s])") found,msg.cc = match(replaceAll(headtxt," \n", " "),"^Cc:\s+(.*?)\\n(?:\\n|[^\s])") found,msg.bcc = match(headtxt,"^Bcc:\s+(.*?)\\n(?:\\n|[^\s])") found,msg.date = match(headtxt,"^Date:\s+(.*?)$") found,msg.subject = match(headtxt,"^Subject:\s+(.*?)\\n(?:\\n|[^\s])") found,msg.charset = match(headtxt,"^Content-Type:.*?charset=([^;]*);") #--- check for attachments from original page found = match(page,"'8\?.*?&attachId=[\d+][^']+'.*?