auto url modifier
<p>got a small script from <a href="http://stackoverflow.com/questions/11798336/change-all-website-links-to-affiliate-links-automatically?lq=1">http://stackoverflow.com/questions/11798336/change-all-website-links-to-affiliate-links-automatically?lq=</a>1 (the second one) to add affiliate tag into url</p>

<p>and this is what i put in the header of my page</p>

<pre><code>    &lt;script type="text/javascript" src="http://。。。。。。/js/jquery-1.8.3.min.js"&gt;&lt;/script&gt;

&lt;script type='text/javascript'&gt;
$("a").click(function() {
    addAffiliate(this);
});

myCode = "http://moe.jlist.com/click/99999999?url=";
myAmazonCode = "&amp;tag=99999999"
    function addAffiliate(link) {
        alert("enterting script: " + link.href);
        if ((link.href).indexOf("jlist.com") &gt; -1 &amp;&amp; (link.href).indexOf(myCode) &lt; 0) {
                link.href = myCode + link.href;
        }else if((link.href).indexOf("amazon.com") &gt; -1 &amp;&amp; (link.href).indexOf(myAmazonCode) &lt; 0){
                link.href = link.href + myAmazonCode;   
        }
            alert(link.href);
            return true;
        }​
&lt;/script&gt;
</code></pre>

<p>however, it is not working, but it works on jsfiddle.net from the url provided by above link when i set the framework to 'onload' with jquery</p>

<p>secondly
i have convert codes from another shopping site that i want to integrate into my codes
this is a sample of wut they gave me</p>

<pre><code>    function convert_aff_links( $_body, $_aff_id = '9999999' )
{
    $_body = preg_replace
    (
        '@://(w+\.)?(playasia|play-asia)\.com/?([^/a-zA-Z])@',
        '://www.play-asia.com/SOap-23-' . '83-' . $_aff_id . '-50-00.html$3',
        $_body
    );

    $_body = preg_replace
    (
        '/paOS-(\d{2})/',
        'SOap-23-' . '83-' . $_aff_id . '-50-$1',
        $_body
    );

    return $_body;
}
</code></pre>

<p>thanks in advance</p>
