Last active
August 29, 2015 14:24
-
-
Save 45deg/5551106ee5aa24f39e1d to your computer and use it in GitHub Desktop.
Project Euler: Translate Into Japanese (Tampermonkey, Greasemonkey?)
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 Project Euler: Translate Into Japanese | |
// @namespace https://gist.github.com/45deg/5551106ee5aa24f39e1d | |
// @version 0.1 | |
// @description odz.sakura.ne.jp/projecteuler/ から日本語訳を取ってきて追加するスクリプト | |
// @author zakuro | |
// @run-at document-end | |
// @match https://projecteuler.net/problem=* | |
// @grant GM_xmlhttpRequest | |
// ==/UserScript== | |
GM_xmlhttpRequest({ | |
method: "GET", | |
url: "http://odz.sakura.ne.jp/projecteuler/index.php?cmd=read&page=Problem%20" + location.href.match(/\d+$/)[0], | |
onload: function(response) { | |
var responseXML = new DOMParser().parseFromString(response.responseText, "text/html"); | |
var paragraphs = responseXML.querySelectorAll('#body > *'); | |
var problemContent = document.getElementsByClassName('problem_content')[0]; | |
// add horizonal line | |
problemContent.appendChild(document.createElement('hr')); | |
// add japanese problem content | |
for (var i = 1; i < paragraphs.length; i++) { | |
problemContent.appendChild(paragraphs[i]); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment