Skip to content
WJunction - Webmaster Forum

Modify code for clickable links - DLE

Status
Not open for further replies.

BlackJACK

Established Member
377
2010
96
This code does NOT support url's starting with https:
If I change the http to https in the code below, then it does not support the first one
I'm NO coder. Will appreciate if someone could help me out. Need support for all url's

Code:
$(function() {
    var sickw = /^http:\/\/(fileparadox|uploadable|terafile|filefactory|uploadable|ul|ryushare|bitshare|turbobit|secureupload|rapidgator|uploaded|k2s|netload|www.fileparadox|www.uploadable.ch|www.terafile.co|www.filefactory|www.uploadable|www.ul|www.ryushare|www.bitshare|www.turbobit|www.secureupload|www.rapidgator|www.uploaded|www.k2s.cc|www.netload)\.[\S]+$/;
    $('body *').contents().filter(function() {
        return this.nodeType == 3 &&
            $(this).text().trim() !== '' &&
            $(this).text().trim().match(sickw);
    }).each(function() {
        $(this).replaceWith('<a href="' + $(this).text().trim() + '"target="_blank" rel="sickw.com">' + $(this).text().trim() + '</a>');
    });
});
 

5 comments

Code:
$(function() {
    var sickw = /^https?:\/\/(fileparadox|uploadable|terafile|filefactory|uploadable|ul|ryushare|bitshare|turbobit|secureupload|rapidgator|uploaded|k2s|netload|www.fileparadox|www.uploadable.ch|www.terafile.co|www.filefactory|www.uploadable|www.ul|www.ryushare|www.bitshare|www.turbobit|www.secureupload|www.rapidgator|www.uploaded|www.k2s.cc|www.netload)\.[\S]+$/;
    $('body *').contents().filter(function() {
        return this.nodeType == 3 &&
            $(this).text().trim() !== '' &&
            $(this).text().trim().match(sickw);
    }).each(function() {
        $(this).replaceWith('<a href="' + $(this).text().trim() + '"target="_blank" rel="sickw.com">' + $(this).text().trim() + '</a>');
    });
});
 
Code:
$(function() {
    var sickw = /^https?:\/\/(fileparadox|uploadable|terafile|filefactory|uploadable|ul|ryushare|bitshare|turbobit|secureupload|rapidgator|uploaded|k2s|netload|www.fileparadox|www.uploadable.ch|www.terafile.co|www.filefactory|www.uploadable|www.ul|www.ryushare|www.bitshare|www.turbobit|www.secureupload|www.rapidgator|www.uploaded|www.k2s.cc|www.netload)\.[\S]+$/;
    $('body *').contents().filter(function() {
        return this.nodeType == 3 &&
            $(this).text().trim() !== '' &&
            $(this).text().trim().match(sickw);
    }).each(function() {
        $(this).replaceWith('<a href="' + $(this).text().trim() + '"target="_blank" rel="sickw.com">' + $(this).text().trim() + '</a>');
    });
});


Thank you but it's not working. None working now
 
Then something else is wrong because all I changed there was "http" to "https?" which in regular expressions terms means "http OR https" which is what you were asking for. The "?" character after the letter "s" means "match s, one or zero times", thus making it optional. The regex will fail if it is test against text which has multiple lines. So depending on the context you might need to add multiline and global flags like so:

Code:
$(function() {
    var sickw = /^https?:\/\/(fileparadox|uploadable|terafile|filefactory|uploadable|ul|ryushare|bitshare|turbobit|secureupload|rapidgator|uploaded|k2s|netload|www.fileparadox|www.uploadable.ch|www.terafile.co|www.filefactory|www.uploadable|www.ul|www.ryushare|www.bitshare|www.turbobit|www.secureupload|www.rapidgator|www.uploaded|www.k2s.cc|www.netload)\.[\S]+$/mg;
    $('body *').contents().filter(function() {
        return this.nodeType == 3 &&
            $(this).text().trim() !== '' &&
            $(this).text().trim().match(sickw);
    }).each(function() {
        $(this).replaceWith('<a href="' + $(this).text().trim() + '"target="_blank" rel="sickw.com">' + $(this).text().trim() + '</a>');
    });
});
 
Status
Not open for further replies.

About the author

B
Established Member · Joined
377
Messages
96
Reactions
216
Points
Grow your business

Advertise on WJunction

Connect with an established international community of webmasters, hosting providers, developers and online entrepreneurs.

  • Premium & Premium+ Sticky
  • Dedicated section banners
  • Site-wide banner advertising
Explore advertising options
Back
Top Bottom