Change href without destroying link
<p>I'm trying to remove a landing page when I click on a link on a page. The page isn't mine so I'm trying to change the href with a user script.</p>

<p>Without any modification, the link looks like this:</p>

<pre><code>https://www.domain.com/out.php?u=http%3A%2F%2Fwww.youtube.com%2Fwatch%3Fv%3DPUZ1bC-1XjA%26amp%3Bfeature%3Drelated
</code></pre>

<p>What I want:</p>

<pre><code>http://www.youtube.com/watch?v=PUZ1bC-1XjA&amp;feature=related
</code></pre>

<p>What I got so far:</p>

<pre><code>http://www.youtube.com%2fwatch%3fv%3dpuz1bc-1xja%26amp%3bfeature%3drelated/
</code></pre>

<p>But that adress doesn't work in the browser.</p>

<p>This is my current code:</p>

<pre><code>$('a').each(function(index) {
            var aLink = $(this).attr('href');
            if(aLink) {
                if(aLink.indexOf("out.php?u=") &gt; 0) {
                    aLink = aLink.substring(51);
                    console.log(aLink);
                    $(this).attr('href', "http://"+aLink);
                    console.log($(this).prop('href'));
                }

            }
        });
</code></pre>

<p>All help and tips are appreciated. </p>
