Created
June 30, 2013 19:00
-
-
Save khanfx/5896405 to your computer and use it in GitHub Desktop.
Forward all email to a destination using nothing but the Outlook Web Access client. Useful when an account is shutting down (say you're graduating), and the IT admins won't export your mail for you. Implemented as a User Script for Tampermonkey and run in Chrome. Several values are hardcoded.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Forward All OWA Webmail | |
// @namespace https://webmail.uth.tmc.edu/ | |
// @version 0.1 | |
// @description enter something useful | |
// @match https://webmail.uth.tmc.edu/* | |
// @copyright 2012+, You | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @require http://ajax.googleapis.com/ajax/libs/jquery/1.6/jquery.min.js | |
// ==/UserScript== | |
var forwardDest = 'sana_a_hasan@yahoo.com'; | |
//console.log(window.location.href); | |
//GM_setValue('forward-item', 0); | |
console.log("Processing item " + GM_getValue('forward-item')); | |
$("#tblSch").after("<span id='forward-ui' />"); | |
//$("#forward-ui").append($("<span>email: <input id='forward-dest' /></span>")); | |
//$("#forward-ui").append($("<span>page: <input id='forward-page' /></span>")); | |
$("#forward-ui").append($("<span>item: <input id='forward-item' style='width:3ex' /></span>")); | |
$("#forward-ui").append($("<span>status: <input id='forward-status' style='width:2ex' /></span>")); | |
$("#forward-ui").append($("<button id='forward-start'>forward start</button>")); | |
$("#forward-ui").append($("<button id='forward-stop'>forward stop</button>")); | |
$("#forward-status").val(GM_getValue("forward-inprogress")); | |
$("#forward-start").click(function() { | |
GM_setValue("forward-inprogress", 1); | |
GM_setValue("forward-item", 0); | |
$("#forward-status").val(GM_getValue("forward-inprogress")); | |
return false; | |
}); | |
$("#forward-stop").click(function() { | |
GM_setValue("forward-inprogress", 0); | |
$("#forward-status").val(GM_getValue("forward-inprogress")); | |
return false; | |
}); | |
var inprogress = GM_getValue("forward-inprogress"); | |
if (!inprogress) { | |
return; | |
} | |
console.log('we are in progress!'); | |
// page is CURRENT page | |
// item is CURRENT item | |
/*var page = GM_getValue('forward-page'); | |
if (page === undefined) { | |
page = 1; | |
}*/ | |
var item = GM_getValue('forward-item'); | |
$("#forward-item").val(item); | |
if (item === undefined) { | |
item = 0; | |
} | |
// On forward page, for now close it | |
if (window.location.href.indexOf('ae=PreFormAction') !== -1 && | |
window.location.href.indexOf('a=Forward') !== -1 ) { | |
// For testing | |
//$("#lnkHdrclose").click(); | |
$("#txtto").val(forwardDest); | |
$("#txtsbj").val('[UT RESIDENCY] ' + $("#txtsbj").val()); | |
$("#lnkHdrsend").click(); | |
} | |
var urlchk = function(snippet) { | |
return window.location.href.indexOf(snippet) !== -1; | |
} | |
// On email list page, iterate over the emails and click each | |
if ( | |
urlchk('ae=StartPage') || | |
urlchk('ae=PreFormAction') && urlchk('a=Close') || | |
urlchk('ae=PreFormAction') && urlchk('a=Send') || | |
urlchk('ae=Folder')) { | |
var mailLinks = $(".cntnt").find("a[onclick^='onClkRdMsg']"); | |
console.log(mailLinks.length + " mail links found"); | |
if (mailLinks.length === item) { | |
// quit for now, do just a page at a time | |
//GM_setValue("forward-inprogress", 0); | |
// Go to next page | |
GM_setValue('forward-item', 0); | |
$('#lnkNxtPg').click(); | |
return; | |
} | |
else { | |
// Go into the next email | |
GM_setValue('forward-item', item+1); | |
mailLinks[item].click(); | |
} | |
} | |
if (window.location.href.indexOf('ae=Item') !== -1) { | |
$("#lnkHdrforward").click(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment