From a1123ddad0cda804f7b2c24bc0df266c8bcb690a Mon Sep 17 00:00:00 2001 From: David Cormier Date: Sun, 13 Oct 2013 14:44:37 -0400 Subject: [PATCH] plugins: automatically hide lines that ends with nsfw --- js/plugins.js | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/js/plugins.js b/js/plugins.js index e11ef1e..56624f2 100644 --- a/js/plugins.js +++ b/js/plugins.js @@ -28,6 +28,8 @@ var Plugin = function(contentForMessage) { */ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) { + var nsfwRegexp = new RegExp('nsfw$', 'i'); + /* * Defines the plugin manager object */ @@ -54,9 +56,16 @@ plugins.service('plugins', ['userPlugins', '$sce', function(userPlugins, $sce) var content = []; for (var i = 0; i < plugins.length; i++) { + + var visible = true; + + if (message.match(nsfwRegexp)) { + var visible = false; + } + var pluginContent = plugins[i].contentForMessage(message); if (pluginContent) { - var pluginContent = {'visible': true, + var pluginContent = {'visible': visible, 'content': $sce.trustAsHtml(pluginContent) } content.push(pluginContent);