Posted 07 July 2012 - 08:10 PM
function stripHTML(str){
// remove all string within tags
var tmp = str.replace(/(<.*['"])([^'"]*)(['"]>)/g,
function(x, p1, p2, p3) { return p1 + p3;}
);
// now remove the tags
return tmp.replace(/<\/?[^>]+>/gi, '');
}
var stringarray = document.getElementsByClassName("prettyprint");
var tochange = [];
for (var i = 0; i < stringarray.length; i++) {
var test = [];
test = stringarray[i].innerHTML.split("<br>");
var output = [];
for (var i2 = 0; i2 < test.length; i2++){
output.push((i2+1) +": " + stripHTML(test[i2]));
}
var realout = "";
for (var i3 = 0; i3 <output.length;i3++) {
realout = realout + output[i3] + "<br>"
}
stringarray[i].innerHTML = realout;
}
this javascript is used to add line indicators to the code field (something may people requested) but i cant get it to work as a greasemonkey / google chrome plugin it only works for the first line :/ but pasted in url bar or browser console it works fine so if anybody has an idea what is causing this please help :3