I've got like 25 "if"s in my userscript for greasemonkey and now I would like to make a switch out of these.
It looks like this:
if (document.location.href.search("de.xyz.com") != -1) {
var lng = "de";
var gamepage = ".de.xyz.com";
var reg = /http:\/\/s(\d+)\.de\.xyz\.com\/(.*?)\.php(.*)/i;
}
Times 25, the only difference is the language of the page, for example not "de" but "en"
Now, how to make a switch out of that? I thought of something like this?
var lng
switch(document.location.href.search((lng) + ".xyz.com") != -1) {
case lng = "de":
var gamepage = ".de.xyz.com";
var reg = /http:\/\/s(\d+)\.de\.xyz\.com\/(.*?)\.php(.*)/i;
}
Use an array of objects and a for. Something like