public
Last active

Temporary email address from Jetable

  • Download Gist
jetable.js
JavaScript
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
var noun_type_lifespan = new CmdUtils.NounType("Lifespan",
["hour", "day", "week", "month"]);
 
CmdUtils.CreateCommand(
{
name: "jetable",
description: "Creates a temporary email address from Jetable.org.",
icon: "http://www.jetable.org/favicon.ico",
homepage: "http://www.makadia.com",
author: { name: "Svapan Makadia", email: "codewzrd@hotmail.com"},
help: "Enter email address and a span {hour, day, week, month}.",
 
takes: {"email": noun_arb_text},
modifiers: {span: noun_type_lifespan},
preview: function(pBlock)
{
var html = "Inserts a temporary Jetable email address in the current editable text area.";
html += "<br/><span style=\"color: yellow;\">Warning, it takes a few seconds to retrieve the email.</span>";
pBlock.innerHTML = html;
},
 
execute: function(directObj, lifespan)
{
switch(lifespan.span.text)
{
case "hour":
span = 3600;
break;
case "day":
span = 86400;
break;
case "week":
span = 604800;
break;
case "month":
span = 2592000;
break;
default:
span = 3600;
}
 
var params = {email:directObj.text,
time:span};
 
jQuery.ajax(
{
type: "POST",
url: "http://www.jetable.org/en/confirm",
data: params,
error: function()
{
displayMessage("Could not get temporary email address.");
},
success: function(msg)
{
var tempElement = CmdUtils.getHiddenWindow().document.createElementNS("http://www.w3.org/1999/xhtml", "div");
tempElement.innerHTML = msg;
//CmdUtils.log(jQuery(tempElement).find("#aliasgenerated").text());
var tempEmail = jQuery(tempElement).find("#aliasgenerated").text();
CmdUtils.setSelection(tempEmail);
displayMessage("Temporary Jetable email address is: " + tempEmail);
}
})
}
});

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.