Created
August 11, 2012 12:33
-
-
Save hkrn/3324191 to your computer and use it in GitHub Desktop.
お絵カキコの UI を英語に翻訳するためのヘルパー...だったはずのもの
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 translate_english_oekakiko.js | |
// @namespace https://github.com/hkrn/ | |
// @description The helper of translating Oekakiko to english | |
// @include http://dic.nicovideo.jp/p/oekaki/* | |
// ==/UserScript== | |
// code from http://stackoverflow.com/questions/2246901/how-can-i-use-jquery-in-greasemonkey-scripts-in-google-chrome | |
function addjQuery(callback) { | |
var script = document.createElement("script"); | |
script.setAttribute("src", "http://ajax.googleapis.com/ajax/libs/jquery/1.8.0/jquery.min.js"); | |
script.addEventListener("load", function() { | |
var script = document.createElement("script"); | |
script.textContent = "(" + callback.toString() + ")();"; | |
document.body.appendChild(script); | |
}, false); | |
document.body.appendChild(script); | |
} | |
function main() { | |
var val = $("param[name=flashvars]", $("#res_oekaki")).val(); | |
var pairs = val.split('&'); | |
var flashvars = {}, npairs = pairs.length; | |
for (var i = 0; i < npairs; i++) { | |
var pair = pairs[i].split('='); | |
flashvars[pair[0]] = pair[1]; | |
} | |
flashvars["language"] = "ja_jp"; | |
$flash = $("object"); | |
$flash.val({ | |
"width": "100%", | |
"height": "100%", | |
"type": "application/x-shockwave-flash", | |
"data": "/fla/2011090701/gunyarapaint.swf", | |
}); | |
$flash.append($("param[name=wmode]").val("window")); | |
$flash.append($("param[name=flashvars]").val($.param(flashvars))); | |
$flash.append($("param[name=allowScriptAccess]").val("sameDomain")); | |
$("#res_oekaki").empty().append($flash); | |
} | |
addjQuery(main); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment