I need to check every script tag's src value and if there is a match, I would like to change that script tags src attribute... Something like this:
var scripts = document.getElementsByTagName("script")[0].src
for (i=0;i<scripts.length;i++){
if(scripts[i] == "something.js"){
document.getElementsByTagName("script")[i].src = "this.js"
}
else {}
}}
ifblock - see how you're getting the same script element you just looked up for the comparison? This should hopefully have prompted you to consider Álvaro's version, to just look through the scripts and modify the src(s) that matched (asides from the fact that you can't use.srcon a nodelist!). 2) An emptyelseblock is not required and can be omitted.