Hi, I am trying to write a small add-on, which replaces several words on page with another. it is a political joke in a minor central-European language. When I try to upload, I got a message:
Your add-on failed validation with 1 error.
- JavaScript syntax error.
It should be in row 1, column 1 of my JS file. I will not lie. According to validator, there are some minor issues in my code (1 unexpected for, 1 row longer than 80 char). But not in row 1, column 1. Here is my code (shortened):
var bab = ["Premiér Andrej Babiš",
"Premiéra Andreje Babiše",
...
"Babiš"
];
var bur = [“Agent StB Bureš”,
…
“Bureš”
];
function replacer (first, second) {
var reg = new RegExp(first, “g”);
var elements = document.getElementsByTagName("*");
for (var i = 0; i < elements.length; i++) {
var element = elements[i];
for (var j = 0; j < element.childNodes.length; j++) {
var node = element.childNodes[j];
if (node.nodeType === 3) {
var text = node.nodeValue;
var replacedText = text.replace(reg, second);
if (replacedText !== text) {
element.replaceChild(document.createTextNode(replacedText), node);
}
}
}
}
}
for (var i = 0; i < bab.length; i++){
replacer (bab[i], bur[i]);
}
The add-on works OK in the temporary mode. How to change it to pass test? It is my first attempt to make a Firefox add-on.