User:Jacky720/common.js

alert("test"); // other code is breaking alert?

/* Let's see what happens. * Subsequent code from https://stackoverflow.com/questions/20253652/how-do-you-send-console-messages-and-errors-to-alert * (I'm editing on a school computer, so I can't access the console.) */

/*window.addEventListener("error", handleError, true);

function handleError(evt) { if (evt.message) { // Chrome sometimes provides this alert("error: "+evt.message +" at linenumber: "+evt.lineno+" of file: "+evt.filename); } else { alert("error: "+evt.type+" from element: "+(evt.srcElement || evt.target)); } }*/ // Back at home, don't need it.

// And here's my code.

var element; const colors = ["cyan", "red", "yellow", "orange", "green", "blue", "purple"];

for (var i = 0; i < document.getElementsByTagName('p').length + document.getElementsByTagName('li').length; i++) { if (i < document.getElementsByTagName('p').length) { element = document.getElementsByTagName('p')[i]; } else { element = document.getElementsByTagName('li')[i - document.getElementsByTagName('p').length]; }   for (var j = 0; j < colors.length; j++) { if (element.innerHTML.match(new RegExp(colors[j], i)) + 1) { alert("Matched color "+colors[j]) // Fixes problem with words like "reduced". Hopefully. /*element.innerHTML = element.innerHTML.replace(new RegExp(" "+colors[j]+"-", g), " "+colors[j]+" -"); element.innerHTML = element.innerHTML.replace(new RegExp(" "+colors[j]+" ", g), " "+colors[j]+" "); element.innerHTML = element.innerHTML.replace(new RegExp(" "+colors[j]+"-", g), " "+colors[j].charAt(0).toUpperCase+colors[j].slice(1)+" -"); element.innerHTML = element.innerHTML.replace(new RegExp(" "+colors[j]+" ", g), " "+colors[j].charAt(0).toUpperCase+colors[j].slice(1)+" ");*/ }   }    /*element.innerHTML = element.innerHTML.replace(/ cyan/g, " cyan "); element.innerHTML = element.innerHTML.replace(/ red/g, " red "); element.innerHTML = element.innerHTML.replace(/ yellow/g, " yellow "); element.innerHTML = element.innerHTML.replace(/ orange/g, " orange "); element.innerHTML = element.innerHTML.replace(/ green/g, " green "); element.innerHTML = element.innerHTML.replace(/ blue/g, " blue "); element.innerHTML = element.innerHTML.replace(/ purple/g, " purple ");*/ }