Former Member
inherit
guest@proboards.com
222576
0
Nov 28, 2024 2:24:53 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 1, 2015 16:12:36 GMT -8
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Nov 3, 2015 4:35:50 GMT -8
Here's a very basic script for you. I won't be expanding it (i.e plugin settings, but anyone else can modify it if you need additions).
Add to your global header (I suppose you could throw it into a plugin if you wish, I just decided not too as I wrote it in the console).
<script>
$(function(){
(function(){
return { hostname: new RegExp(location.host), init: function(){ this.parse_old_shouts(); this.monitor_shoutbox(); }, parse_old_shouts: function(){ var shouts = $(".shoutbox_messages div.shoutbox-post"); this.parse_shouts(shouts); }, monitor_shoutbox: function(){ var self = this; $.ajaxPrefilter(function(opts, orig_opts){ if(orig_opts.url == proboards.data("shoutbox_update_url")){ var orig_success = orig_opts.success; opts.success = function(){ orig_success.apply(this, self.parse_realtime_shouts.apply(self, arguments)); }; } }); }, parse_realtime_shouts: function(){ if(arguments && arguments.length && arguments[0].shoutbox_post){ var container = $("<span />").html(arguments[0].shoutbox_post); var posts = container.find("div.shoutbox-post"); this.parse_shouts(posts); arguments[0].shoutbox_post = container.html(); }
return arguments || []; }, parse_shouts: function(shouts){ var self = this; shouts.each(function(){ var message = $(this).find("span.message"); message.find("a").each(function(){ if(!self.hostname.test($(this).attr("href"))){ $(this).replaceWith("<em>[Link Removed]</em>"); } }); }); } };
})().init(); });
</script>
|
|
Former Member
inherit
guest@proboards.com
222576
0
Nov 28, 2024 2:24:53 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 3, 2015 5:54:44 GMT -8
thank u peter, its perfect, iv changed the text 'link removed' to 'goldenbeatz thread links only' so all is good thanks.
q ... how long did it take for u to write this ?
|
|
Former Member
inherit
guest@proboards.com
225992
0
Nov 28, 2024 2:24:53 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 3, 2015 7:02:56 GMT -8
Elegant solution Peter. My initial approach would have been to patch into the "beforeSend" method. I didn't even consider "$.ajaxPrefilter", excellent.
|
|
inherit
2671
0
May 14, 2013 14:40:03 GMT -8
Peter
🐺
10,615
February 2002
peter3
|
Post by Peter on Nov 3, 2015 8:45:19 GMT -8
thank u peter, its perfect, iv changed the text 'link removed' to 'goldenbeatz thread links only' so all is good thanks. q ... how long did it take for u to write this ? Not long, probably around 5 mins + 1-2 mins of testing. When you have wrote so many plugins / mods for so long, most of it is just repeating things you have done on other plugins (i.e in this case I had knowledge of ajax filters and the shout structure from a while back). So while it might seem impressive that it was done in so little time, it's not really, as it's stuff that was stored away in my tiny brain just waiting to be typed out again
|
|
Former Member
inherit
guest@proboards.com
222576
0
Nov 28, 2024 2:24:53 GMT -8
Former Member
0
January 1970
Former Member
|
Post by Former Member on Nov 3, 2015 9:21:15 GMT -8
haha funny. thanks again ?
|
|