You may have see various sites where URLs are encoded by an advertisement redirection service. I want to write a personal javascript snippet to remove this spam.
Mostly, the HTML will look like this:
<a target="_blank" href="http://ads.example.com/246619/http://www.example.net/path/I/want">SteamTable App</a>
The problem is that the URL path http://ads.example.com/246619/ is different for each link.
My attempt:
$(function() {
var x = $('div.content.clearfix a').get();
//alert(x.length);
for (i = 0; i < x.length; i++) {
var Href = $(x[i]).attr('href');
Href = Href.replace("http://ads.example.com/.*?/", "");
alert(Href); //success or not
$(x[i]).attr('href', Href);
}
});
I don't know why this isn't working.