Replace URL in an embed tag

1

I have a <embed> tag in my HTML:

<embed class="flash" src="http://example.com/swf/10/nome.swf">

I wanted to find a way to change the address to http://example.com/swf/5/nome.swf .

Ignoring flashvars, how can I do this in JavaScript? I need to use this in Tampermonkey.

    
asked by anonymous 06.04.2015 / 19:11

1 answer

2

See if it works:

Note: It assumes that you have included Jquery on your page.

<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script><script>$(document).ready(function(){$("embed.flash").each(function() {
        $(this).attr("src", $(this).attr("src").replace("/10/", "/5/"));
      });
    });
</script>

<embed class="flash" src="http://example.com/swf/10/nome.swf">
    
06.04.2015 / 19:22