diff --git a/build/CommentCoreLibrary.js b/build/CommentCoreLibrary.js index ce15407..6298082 100644 --- a/build/CommentCoreLibrary.js +++ b/build/CommentCoreLibrary.js @@ -839,8 +839,10 @@ var CommentManager = (function() { } for(;this.position < this.timeline.length;this.position++){ if(this.options.limit > 0 && this.runline.length > this.limiter) break; - if(this.validate(this.timeline[this.position]) && this.timeline[this.position]['stime']<=time){ - this.send(this.timeline[this.position]); + if(this.timeline[this.position]['stime']<=time){ + if(this.validate(this.timeline[this.position])){ + this.send(this.timeline[this.position]); + } }else{ break; } diff --git a/build/CommentFilter.js b/build/CommentFilter.js new file mode 100644 index 0000000..003b85a --- /dev/null +++ b/build/CommentFilter.js @@ -0,0 +1,129 @@ +/** + * Created by Dev on 2015/9/2. + */ +function CommentFilter(){ + this.modifiers = []; + this.runtime = null; + this.blockList = []; + this.rules = [{ + item: "mode", + operator: "=", + subject: 4, + //底部弹幕 + }]; + this.config = { + useRegExp: false + }; + this.allowTypes = { + "1":true, + "4":true, + "5":true, + "6":true, + "7":true, + "8":true, + "17":true + }; + var rule_modifiers = [{ + item: "mode", + operator: "=", + subject: 4, + //底部弹幕 + },{ + item: 'color', + operator: '!=', + subject: parseInt('FFFFFF') + },{ + item: 'text', + operator: 'contain', + subject: '逗逼', + isdiy: true + }]; + this.doModify = function(cmt){ + for(var k=0;k': + case 'big than': + case 'bigger': + deal = compare('>'); break; + case '<': + case 'small than': + case 'smaller': + deal = compare('<'); break; + case '>=': + deal = compare('>='); break; + case '<=': + deal = compare('<='); break; + case 'has': + case 'contain': + deal = (function(){ + if (config.useRegExp){ + return function(a, b){ + var reg = new RegExp(b); + return reg.test(a); + } + } else { + return function(a, b){ + return a.indexOf(b) > -1; + } + } + })(); + break; + default: + deal = function(){return true;}; break; + } + this.rules[i].item = this.rules[i].item.toLowerCase(); + console.log(cmtData); + result = !(deal(cmtData[this.rules[i].item], this.rules[i].subject)); + } + return result; + }; + this.addRule = function(rule){ + this.rules.push(rule); + }; + this.delRule = function(index){ + this.rules.splice(index, 1); + }; + this.addModifier = function(f){ + this.modifiers.push(f); + }; + this.runtimeFilter = function(cmt){ + if(this.runtime == null) + return cmt; + return this.runtime(cmt); + }; + this.setRuntimeFilter = function(f){ + this.runtime = f; + } +}