User:Vih~enwiktionary/common.js

$(new_parse_test);

function parser(src) { var startPosEtymP = src.indexOf(' Etymology ', 0) //find the start of p var endPosEtymP = src.indexOf(" ", startPosEtymP) + 4 var etymology=src.substring(startPosEtymP, endPosEtymP)

var startPosNounP = src.indexOf(' Noun ', 0) //find the start of p var endPosNounP = src.indexOf(' <span class="editsection"', startPosNounP) var noun=src.substring(startPosNounP, endPosNounP)

panel.innerHTML=' '+etymology+' '+noun

}

function new_parse_test { if (window.location.href != 'http://en.wiktionary.org/wiki/User:Vih/Game') return

gen_panel

xmlhttp=new XMLHttpRequest; xmlhttp.onreadystatechange=function{ if (xmlhttp.readyState==4 && xmlhttp.status==200) { var txt = xmlhttp.responseText var re = eval ("(" + txt + ")") parser(re.parse.text['*']) } } xmlhttp.open("GET","http://en.wiktionary.org/w/api.php?format=json&action=parse&prop=text&page=appendicitis",true); xmlhttp.send;

}

function gen_panel { panel = document.createElement("div") document.body.appendChild(panel) panel.setAttribute('style', 'position:fixed;right:20px;top:100px;border:1px solid black;width:200px;height:300px;') }