Whitelisting LinkOut Domains

From KickApps Documentation

Jump to: navigation, search

Description

This code snippet will create a list of accepted domains which will bypass the "linkOut" page. You can add as many domains as you'd like.

Code

$j(function(){
    
    whitelistedDomains = [
        "http://DOMAIN-1.com",
        "http://www.DOMAIN-2.net",
        "http://DOMAIN-3.org"
    ]

    $j('a[href*=linkOut.kickAction]').each(function(i,e){
        var link = /.*url=(.*)&h/im.exec(unescape(e.href))[1]

        for (var i = 0, len = whitelistedDomains.length; i < len; i++) {
            var re = new RegExp("^" + whitelistedDomains[i], 'im')
            if (link.match(re)) {
                e.href = link;
            }
        }
    });
});