Created
June 17, 2012 02:55
-
-
Save ww24/2943252 to your computer and use it in GitHub Desktop.
Gmailの一番上にあるメールの件名を任意のサーバーへ送る
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
javascript:(function(){var e=document.getElementById("canvas_frame").contentWindow.document.getElementsByClassName("BltHke nH oy8Mbf"),t;for(var i=0,l=e.length;i<l;i++){t=e[i];if(t.style.display!=="none")break}var s=t.getElementsByTagName("table")[1].getElementsByTagName("tr")[0].getElementsByTagName("td")[5].getElementsByTagName("span")[0].innerText;var x=/*@cc_on!@*/true?new XMLHttpRequest():new XDomainRequest();x.timeout=3000;x.ontimeout=function(){alert("timeout")};x.onerror=function(){alert("error")};x.onload=function(){alert(decodeURIComponent(x.responseText))};x.open("POST",prompt("Subject:"+s+"を送信するサーバを指定してください","http://echo.ww24.jp"),false);x.setRequestHeader("Content-Type","application\/x-www-form-urlencoded;charset=UTF-8");x.send("subject="+encodeURIComponent(s))})() |
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
var http = require("http"); | |
http.createServer(function (req, res) { | |
res.writeHead("200", { | |
"Access-Control-Allow-Origin": "*" | |
}); | |
req.on("data", function (chunk) { | |
res.write(chunk); | |
}); | |
req.once("end", function () { | |
res.end(); | |
}); | |
}).listen(80); |
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
// get subject | |
var d = document.getElementById("canvas_frame").contentWindow.document, | |
elem = d.getElementsByClassName("BltHke nH oy8Mbf"), | |
target; | |
for (var i = 0, l = elem.length; i < l; i++) { | |
target = elem[i]; | |
if (target.style.display !== "none") | |
break; | |
} | |
var subject = target.getElementsByTagName("table")[1].getElementsByTagName("tr")[0].getElementsByTagName("td")[5].getElementsByTagName("span")[0].innerText; | |
// XHR | |
var ajax = function (method, url, data, callback) { | |
var xhr = /*@cc_on!@*/true ? new XMLHttpRequest() : new XDomainRequest(); | |
xhr.timeout = 3000; | |
xhr.ontimeout = function () { | |
alert("timeout"); | |
}; | |
xhr.onerror = function () { | |
alert("error"); | |
}; | |
xhr.onload = function () { | |
callback(xhr.responseText); | |
}; | |
xhr.open(method, url, false); | |
if (method === "POST") | |
xhr.setRequestHeader("Content-Type", "application\/x-www-form-urlencoded; charset=UTF-8"); | |
xhr.send(data); | |
}; | |
// request | |
url = prompt("Subject:" + subject + "を送信するサーバを指定してください", "http://echo.ww24.jp"); | |
ajax("POST", url, "subject=" + encodeURIComponent(subject), function (data) { | |
alert(decodeURIComponent(data)); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
SOPを学ぶためのテストコード①