Make Hotfile, Fileserve, 10+ Filehost's Links Clickable

Status
Not open for further replies.
Lol @ this totally coming from my script. But whats the point of doing a new regex for each host? :/

Just put them all in one group, ie (?:hotfile\.com|netload\.in)

Also, you need to escape your dots in the regex...

Why even release this nubby script, srsly?
 
Could somebody help please?
If I want a specify domain clickable but there's "http://anonym.to?" before the address using this script , how should I edit it?
I try to use

PHP:
newNode.innerHTML=text.replace(re_link8, '<a href="http://www.anonym.to/?$1" target="_blank">$1</a>');
And it fails, somebody helps me ? how to edit it? Thanks!

Edit: Forgot to put a "}". Now finally works.
 
if we only want HF + FS live links( Clickable), then how we will do it?
Code:
jQuery.fn.textNodes = function() {
    var ret = [];
    this.contents().each(function() {
        var fn = arguments.callee;
        if(this.nodeType == 3) {
            ret.push(this);
        } else if(this.nodeType==1 &&!(
        this.tagName.toLowerCase()=='script' ||
        this.tagName.toLowerCase()=='head' ||
        this.tagName.toLowerCase()=='iframe' ||
        this.tagName.toLowerCase()=='textarea' ||
        this.tagName.toLowerCase()=='option' ||
        this.tagName.toLowerCase()=='style' ||
        this.tagName.toLowerCase()=='title' ||
        this.tagName.toLowerCase()=='a')){
            jQuery(this).contents().each(fn);
        }
    });
    return ret;
}

jQuery.fn.hfautolink = function() {
    re_link2 = new RegExp('(https?://(?:[A-Z0-9]\.)*(?:hotfile.com)[-()A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|])', "ig");
    re_link3 = new RegExp('https?://(?:[A-Z0-9]\.)*(?:hotfile.com)[-()A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|]', "i");
    re_link4 = new RegExp('(https?://(?:[A-Z0-9]\.)*(?:fileserve.com)[-()A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|])', "ig");
    re_link5 = new RegExp('https?://(?:[A-Z0-9]\.)*(?:fileserve.com)[-()A-Z0-9+&@#/%?=~_|!:,.;]*[A-Z0-9+&@#/%=~_|]', "i");

    this.each(function(i){
        jQuery.each($(this).textNodes(), function(i, node){
            text = node.nodeValue;
            if(re_link3.test(text)){
                newNode=document.createElement('span');
                text=jQuery('<div/>').text(text).html();
                newNode.innerHTML=text.replace(re_link2, '<a href="$1" target="_blank">$1</a>');
                node.parentNode.replaceChild(newNode, node);
            }
            else if(re_link5.test(text)){
                newNode=document.createElement('span');
                text=jQuery('<div/>').text(text).html();
                newNode.innerHTML=text.replace(re_link4, '<a href="$1" target="_blank">$1</a>');
                node.parentNode.replaceChild(newNode, node);
            }

        });
    });
}

$(function() {
    $("div").hfautolink();
});
 
thanks for share. I'm using different method for making links clickable on my forums now, but yours is much simpler.
 
Status
Not open for further replies.
Back
Top