]> git.mxchange.org Git - friendica-addons.git/blob - nsfw/README
Merge branch '3.6-release'
[friendica-addons.git] / nsfw / README
1 NSFW
2
3 "Not safe for work"
4
5 Scans the message content for the string 'nsfw' 
6 (case insensitive) and if found replaces the content
7 with a "click to open/close" link, default is closed.
8
9 If you click on the 'Not safe for work' addon under
10 /settings/addon a text field appears, where you can
11 extend the list of search terms. The terms must be
12 seperated by commas.
13
14 It is also possible to enter profile URLs as values.
15 This is quite useful for the case, that you perhaps
16 don't want to see postings by person_A, but person_B
17 is one of your contacts and person_B used to reshare
18 postings by person_A.
19
20 You can also make use of regular expressions.
21 They also have to be seperated by commas and the
22 regex itself has to be enclosed with slashes:
23
24         ... nsfw, /<REGEX>/, politics,...
25
26 ---------------
27 A few examples:
28 ---------------
29
30 1)
31 Let's say you don't want to see postings which contain
32 the term 'fake news'
33
34 The term could appear in several ways:
35
36 fakenews, fake news, fake_news, fake-news, f@ke news,
37 f4ke news, f4k3 n3ws, and so on and so on and so on.
38
39 You could write every possible version of it as single
40 item into your NSFW-filter list, but this can also be
41 done with a single regex, which matches all of them:
42
43         /f[@4a]k[3e][-_ ]n[3e]w[sz]/
44
45
46 2)
47 Another use case could be, that you are simply not
48 interested in postings about christmas.
49
50         /christmas(?:[-_ ]?(?:tree|time|eve|pudding))?/
51
52
53 ATTENTION:
54
55 It is absolutely important, that you use grouping
56 parentheses instead of capturing parentheses!!
57
58 Grouping parentheses are:
59
60         (?: )
61
62 If you use capturing parentheses, which are
63
64         ( )
65
66 it will produce errors and the regex won't work and
67 at least your targets will not get collapsed.
68
69
70
71 3)
72 Another possibility is the usage of a so called
73 'lookbehind' construct. I'll give an example followed
74 by a descripton:
75
76         /(?<!the )\badvent\b/
77
78 The \b is a word boundary, what matches the beginning
79 and the end of a word. The simple pattern of 'advent'
80 would match advent iteself, but also adventure.
81 This can be prevented by
82
83         /\badvent\b/
84
85 The first part of the regex above
86
87         (?<!the )
88
89 is a negative lookbehind. It makes \badvent\b only
90 match, if there is no 'the ' before \badvent\b or in
91 words:
92
93 It looks for 'advent', but doesn't match 'the advent'.
94
95
96 For more informations take a look at the PCRE regex
97 dialect.