Like SystemiConnectFri 15 Oct 2021, 04:50
Auto Save MessagesLGforumFri 26 Feb 2021, 13:31
New tutorial questionTheCrowMon 15 Feb 2021, 08:12
Support iOS Emojis (and other platforms)LGforumSun 14 Feb 2021, 01:25
LGforum (2806)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Mr.Easybb (1587)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Bloodbath (745)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Rukiafan (533)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Dom (513)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
puppycheese (446)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
pedro (330)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Neymar (301)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Hitsu (281)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 
Flora (275)
[PLUG-IN] Prevent External Links in the Chatbox Vote_lcap[PLUG-IN] Prevent External Links in the Chatbox Voting_bar[PLUG-IN] Prevent External Links in the Chatbox Vote_rcap 


[PLUG-IN] Prevent External Links in the Chatbox

LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Sun 03 Feb 2013, 12:41

Prevent External Links in the Chatbox

(Versions 1.3 - 1.9.1)

This small plug in will allow you to prevent users posting links to other sites in your chatbox, but they will still be able to post links to your site.
If you use the chatbox here at AvacWeb you'll notice I've implemented this at AvacWeb.

I've also added an option for you to allow sites which contain certain strings, fill in as many as you want.

Simply install this message hook:
Code:
avacweb_chat_config.message_hook.push(function(row, username, user_id, usr, msg) {
  var links = msg.getElementsByTagName('a'), whitelist = [location.hostname, 'youtube', 'twitter', 'facebook'];
  for(var i = 0, l; (l = links[i++]); ) {
      if(l.href.charAt(0) !== '/' && !l.href.match(RegExp('(' + whitelist.join('|') + ')', 'i'))) {
        l.href = '/';
        l.innerHTML = '[External links are banned in the chatbox]';
      }
  }
});
You can add your own sites where you see [ic]'twitter.', 'facebook.'[/ic] etc. Any links which contain those words will be allowed still.

You can also change this line [ic]l.innerHTML = '[External links are banned in the chatbox]';[/ic] to whatever you want it to say.
FloraFlora
Status : No status yet...

Posts : 275
Join date : 2011-11-18
Location : USA
Sun 03 Feb 2013, 13:10
Handy plug in, thank you!
avatarStr0ng
Status : No status yet...

Posts : 95
Join date : 2012-11-26
Tue 12 Feb 2013, 08:58
Good Pug-in!

But I was wondering if is possible to allow links to a specific external site..since we have a website on weebly where is main info about the forum etc.. and some rules etc are there, and is useful share links to pages of this site in chatbox. Thanks!

avatarGuest
Tue 12 Feb 2013, 09:36
Thanks, but before activing it, I'd like to see the possibility of whitelisting some, like YouTube.
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Wed 13 Feb 2013, 16:51
I've edited this to contain a "whitelist".
avatarStr0ng
Status : No status yet...

Posts : 95
Join date : 2012-11-26
Wed 13 Feb 2013, 17:09
Yush!! It worked! A lot of thanks! Very Happy
avatarGuest
Wed 13 Feb 2013, 18:15
Thanks LG! Beauty! Smile
blitzkriegblitzkrieg
Status : No status yet...

Posts : 39
Join date : 2013-02-16
Age : 25
Location : Romania
Sat 23 Feb 2013, 10:53
Not working for me Sad Why is that? I pasted this code

Code:
[panda=js]        avacweb_chat_config.message_hook.push(function(row, username, user_id, usr, msg) {
          var links = msg.getElementsByTagName('a'), whitelist = [location.hostname, 'youtube', 'twitter', 'facebook'];
          for(var i = 0, l; (l = links[i++]); ) {
              if(l.href.charAt(0) !== '/' && !l.href.match(RegExp('(' + whitelist.join('|') + ')', 'i'))) {
                l.href = '/';
                l.innerHTML = '[Link-urile către alte site-uri sunt interzise]';
              }
          }
        });

Into the AWC js code on my forum and it's not replacing links e.g. from www.google.com ... any help? Thanks!
FloraFlora
Status : No status yet...

Posts : 275
Join date : 2011-11-18
Location : USA
Sat 23 Feb 2013, 11:14
I thought the same at first. Try typing out the full url. Smile
blitzkriegblitzkrieg
Status : No status yet...

Posts : 39
Join date : 2013-02-16
Age : 25
Location : Romania
Sat 23 Mar 2013, 18:19
Still not working for me. Typed http://www.google.com and the link isn't replaced with the l.innerHTML from the JS.
blitzkriegblitzkrieg
Status : No status yet...

Posts : 39
Join date : 2013-02-16
Age : 25
Location : Romania
Fri 05 Jul 2013, 12:36
*bump*
Mr.EasybbMr.Easybb
Status : Love this site, that's why I'm back each day again... lol Samantha's co-owner now. Well deserved!

Posts : 1587
Join date : 2013-01-04
Mon 05 Aug 2013, 04:46
blitz did you add google to the whitelist?

Also since someone asked me how to change the context of the link so that it only shows up as [link] I'll post the rest of the code here for people to have. This will change any and all links to [link]


Code:
[panda=js]avacweb_chat_config.message_hook.push(function(row, username, user_id, usr, msg) {
  var links = msg.getElementsByTagName('a');
  for(var i = 0, l; (l = links[i++]); ) {
      if(l.href.charAt(0) !== '/') {
        l.innerHTML = '[LINK]';
      }
  }
});
Dark-AvengerDark-Avenger
Status : Hello

Posts : 166
Join date : 2013-10-27
Age : 49
Sun 04 May 2014, 22:17
Hi all,
Is it possible to have it in version 1.9?

Best Regards,
Dark-Avenger
LGforumLGforum
Status : Working to restore AWC!

Posts : 2806
Join date : 2011-10-05
Age : 30
Location : UK
Wed 07 May 2014, 18:23
This should work in 1.9 now.
avatarGuest
Thu 04 Dec 2014, 00:36
figured i would mod your code for a black list ..this will allow all links except for the ones in the black list

avacweb_chat_config.message_hook.push(function(row, username, user_id, usr, msg) {
var links = msg.getElementsByTagName('a'), blacklist = ['youtube','facebook'];
for(var i = 0, l; (l = links[i++]); ) {
if(l.href.charAt(0) !== '/' && !l.href.match(RegExp('(' + blacklist.join('|') + ')', 'i'))) {}else{
l.href = '/';
l.innerHTML = '[Youtube & Facebook links are banned in the chatbox please post them on the forum.]';
}
}
});
avatar----- fighter -----
Status : No status yet...

Posts : 4
Join date : 2015-01-06
Tue 06 Jan 2015, 14:47
LGforum wrote:[quotelink="http://www.avacweb.com/t875-plug-in-prevent-external-links-in-the-chatbox#8448"]

Prevent External Links in the Chatbox

(Versions 1.3+)

This small plug in will allow you to prevent users posting links to other sites in your chatbox, but they will still be able to post links to your site.
If you use the chatbox here at AvacWeb you'll notice I've implemented this at AvacWeb.

I've also added an option for you to allow sites which contain certain strings, fill in as many as you want.

Simply install this message hook:
Code:
avacweb_chat_config.message_hook.push(function(row, username, user_id, usr, msg) {
  var links = msg.getElementsByTagName('a'), whitelist = [location.hostname, 'youtube', 'twitter', 'facebook'];
  for(var i = 0, l; (l = links[i++]); ) {
      if(l.href.charAt(0) !== '/' && !l.href.match(RegExp('(' + whitelist.join('|') + ')', 'i'))) {
        l.href = '/';
        l.innerHTML = '[External links are banned in the chatbox]';
      }
  }
});
You can add your own sites where you see [ic]'twitter.', 'facebook.'[/ic] etc. Any links which contain those words will be allowed still.

You can also change this line [ic]l.innerHTML = '[External links are banned in the chatbox]';[/ic] to whatever you want it to say.

where put this code ?
BloodbathBloodbath
Status : No status yet...

Posts : 745
Join date : 2013-05-31
Age : 28
Tue 06 Jan 2015, 17:47
If you look at the Sticky topic in this subforum you'd have realized that this is answered in this topic here. I will reply to this as only answer to the total three times you posted this.
Sponsored content