@@ -1112,6 +1112,14 @@ var CommentManager = (function() {
11121112 */
11131113var CommentFilter = (function () {
11141114
1115+ /**
1116+ * Matches a rule against an input that could be the full or a subset of
1117+ * the comment data.
1118+ *
1119+ * @param rule - rule object to match
1120+ * @param cmtData - full or portion of comment data
1121+ * @return boolean indicator of match
1122+ */
11151123 function _match (rule, cmtData) {
11161124 var path = rule.subject.split('.');
11171125 var extracted = cmtData;
@@ -1168,6 +1176,10 @@ var CommentFilter = (function () {
11681176 }
11691177 }
11701178
1179+ /**
1180+ * Constructor for CommentFilter
1181+ * @constructor
1182+ */
11711183 function CommentFilter() {
11721184 this.rules = [];
11731185 this.modifiers = [];
@@ -1184,16 +1196,37 @@ var CommentFilter = (function () {
11841196 };
11851197 }
11861198
1199+ /**
1200+ * Runs all modifiers against current comment
1201+ *
1202+ * @param cmt - comment to run modifiers on
1203+ * @return modified comment
1204+ */
11871205 CommentFilter.prototype.doModify = function (cmt) {
11881206 return this.modifiers.reduce(function (c, f) {
11891207 return f(c);
11901208 }, cmt);
11911209 };
11921210
1211+ /**
1212+ * Executes a method defined to be executed right before the comment object
1213+ * (built from commentData) is placed onto the runline.
1214+ *
1215+ * @deprecated
1216+ * @param cmt - comment data
1217+ * @return cmt
1218+ */
11931219 CommentFilter.prototype.beforeSend = function (cmt) {
11941220 return cmt;
11951221 };
11961222
1223+ /**
1224+ * Performs validation of the comment data before it is allowed to get sent
1225+ * by applying type constraints and rules
1226+ *
1227+ * @param cmtData - comment data
1228+ * @return boolean indicator of whether this commentData should be shown
1229+ */
11971230 CommentFilter.prototype.doValidate = function (cmtData) {
11981231 if ((!this.allowUnknownTypes ||
11991232 cmtData.mode.toString() in this.allowTypes) &&
@@ -1211,13 +1244,26 @@ var CommentFilter = (function () {
12111244 });
12121245 };
12131246
1247+ /**
1248+ * Adds a rule for use with validation
1249+ *
1250+ * @param rule - object containing rule definitions
1251+ * @throws Exception when rule mode is incorrect
1252+ */
12141253 CommentFilter.prototype.addRule = function (rule) {
12151254 if (rule.mode !== 'accept' && rule.mode !== 'reject') {
12161255 throw new Error('Rule must be of accept type or reject type.');
12171256 }
12181257 this.rules.push(rule);
12191258 };
12201259
1260+ /**
1261+ * Adds a modifier to be used
1262+ *
1263+ * @param modifier - modifier function that takes in comment data and
1264+ * returns modified comment data
1265+ * @throws Exception when modifier is not a function
1266+ */
12211267 CommentFilter.prototype.addModifier = function (f) {
12221268 if (typeof f !== 'function') {
12231269 throw new Error('Modifiers need to be functions.');
@@ -1870,7 +1916,7 @@ var BilibiliFormat = (function () {
18701916 BilibiliFormat.TextParser = function (params) {
18711917 this._allowInsecureDomParsing = true;
18721918 this._attemptEscaping = true;
1873- this._canSecureParse = false;
1919+ this._canSecureNativeParse = false;
18741920 if (typeof params === 'object') {
18751921 this._allowInsecureDomParsing = params.allowInsecureDomParsing === false ? false : true;
18761922 this._attemptEscaping = params.attemptEscaping === false ? false : true;
0 commit comments