Skip to content

Instantly share code, notes, and snippets.

@cherenkov
Created October 15, 2010 16:31
Show Gist options
  • Save cherenkov/628504 to your computer and use it in GitHub Desktop.
Save cherenkov/628504 to your computer and use it in GitHub Desktop.
llevalを使ったサンプル。
// ==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