Created
October 15, 2010 16:31
-
-
Save cherenkov/628504 to your computer and use it in GitHub Desktop.
llevalを使ったサンプル。
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 lleval-test | |
// @namespace http://d.hatena.ne.jp/Cherenkov/ | |
// @include * | |
// ==/UserScript== | |
// サンプルで使うJSONP供給源 | |
// lleval - run codes from your browser http://colabv6.dan.co.jp/lleval.html | |
/* unsafeWindowを使った方法*/ | |
unsafeWindow.JSONP = {}; | |
unsafeWindow.JSONP.callback = function(r) { | |
alert(r.stdout) | |
} | |
// appendChildな方法 | |
/* | |
var s = document.createElement('script'); | |
var t = document.createTextNode("var JSONP = { callback: function(r) { alert(r.stdout); } }"); | |
s.appendChild(t); | |
document.body.appendChild(s); | |
*/ | |
var src = "print(1+2)"; | |
var ll = "js"; | |
var s = document.createElement('script'); | |
s.src = 'http://api.dan.co.jp/lleval.cgi?c=JSONP.callback' + '&s=' + encodeURIComponent(src) + '&l=' + encodeURIComponent(ll); | |
document.body.appendChild(s); | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment