Closed jpgohlke closed 10 years ago
This is only broken in the minified version of the script. We should try using a different minifier.
Any suggestions as to which one? I've tried javascriptcompressor.com
and jcompress.com
.
Might try using Google's Closure Compiler (http://closure-compiler.appspot.com/home) when I get home. It generated the following minified code:
(function(){function r(a){a=f.trim(a);var d=[];n.forEach(function(b){b.predicate(a)&&d.push(b.name)});return d}function s(a,d){p.forEach(function(b){b.def&&(a=b.predicate(a,d))});return a}var q="left right up down start select a b democracy anarchy wait".split(" "),t=["misty"],u="github.com reddit.com webchat.freenode.net/?channels=twitchplayspokemon sites.google.com/site/twitchplayspokemonstatus/ www.reddit.com/live/sw7bubeycai6hey4ciytwamw3a strawpoll.me imgur.com pokeworld.herokuapp.com".split(" "),m;try{m=unsafeWindow}catch(y){m=window}var f=m.jQuery,v=RegExp("^(("+q.join("|")+")\\d*)+$","i"),n=[{name:"TppFilterCommand",comment:"Hide commands (up, down, anarchy, etc)",def:!0,predicate:function(a){a=a.toLowerCase();a=a.split(/[\d\s]+/);for(var d=0;d<a.length;d++){var b=a[d];if(b){a:if(v.test(b))b=!0;else{for(var c=0;c<q.length;c++){var e;e=q[c];var f=b;if(0===e.length)e=f.length;else if(0===f.length)e=e.length;else{for(var h=[],g=0;g<=f.length;g++)h[g]=[g];for(var k=0;k<=e.length;k++)h[0][k]=k;for(g=1;g<=f.length;g++)for(k=1;k<=e.length;k++)f.charAt(g-1)==e.charAt(k-1)?h[g][k]=h[g-1][k-1]:h[g][k]=1+Math.min(h[g-1][k-1],h[g][k-1],h[g-1][k]);e=h[f.length][e.length]}if(2>=e){b=!0;break a}}b=!1}if(!b)return!1}}return!0}},{name:"TppFilterLink",comment:"Hide messages with non-whitelisted URLs",def:!0,predicate:function(a){a=a.toLowerCase();a=a.match(m.CurrentChat.linkify_re);if(!a)return!1;for(var d=0;d<a.length;d++){var b;a:{b=a[d];for(var c=0;c<u.length;c++)if(0<=b.indexOf(u[c])){b=!0;break a}b=!1}if(!b)return!0}return!1}},{name:"TppFilterDuplicateURL",comment:"Hide duplicate URLS",def:!0,predicate:function(a){for(var d=RegExp("(\\.[^\\.\\s]{1,3}(?:/[^\\.\\s]+(?:\\.[^\\.\\s]{1,3})?)?(?:\\?[^\\.\\s]+\\=[^\\.\\s]+(?:&[^\\.\\s]+\\=[^\\.\\s]+])*)?)","gi"),b=[],c;null!==(c=d.exec(a));){var e=/(\S*\=)\S*?/gi.exec(c[1]);null==e?b.push(c[1]):b.push(e[1])}if(null!=b)for(a={},d=0;d<b.length;++d){c=b[d];if(Object.prototype.hasOwnProperty.call(a,c))return!0;a[c]=!0}return!1}},{name:"TppFilterDonger",comment:"Hide dongers and ascii art. \u30fd\u0f3c\u0e88\u0644\u035c\u0e88\u0f3d\uff89",def:!1,predicate:function(a){for(var d=0,b=0;b<a.length;b++)if(127<a.charCodeAt(b)&&(d++,2<d))return!0;return!1}},{name:"TppFilterSmall",comment:'Hide one-word messages (Kappa, "yesss!", etc)',def:!1,predicate:function(a){return 2>a.split(/\s/g).length}},{name:"TppFilterUppercase",comment:"Hide ALLCAPS",def:!1,predicate:function(a){return a.toUpperCase()===a}},{name:"TppFilterSpam",comment:'Hide common spam ("MISTY")',def:!0,predicate:function(a){a=a.toLowerCase();for(var d=0;d<t.length;d++)if(-1!==a.indexOf(t[d]))return!0;return!1}}],p=[{name:"TppGUIColorDirected",comment:"Color Directed Messages (@Username)",def:!0,customCss:".chat_line_directed {,color: #0000FF;,font-weight: bold;,},.chat_line_directed_username {,color: #FF0000;,}".split(","),predicate:function(a,d){var b=function(a,d,c,f,k,z,A){a=d.replace(/(.*)(@)(\w+)(.*)/i,b);d==a&&(a='<span class="chat_line">'+a+"</span>");return a+('<span class="chat_line_directed">'+c+"</span>")+('<span class="chat_line_directed_username">'+f+"</span>")+('<span class="chat_line">'+k+"</span>")},c=d.replace(/(.*)(@)(\w+)(.*)/i,b);c!=d&&(a=a.replace(/<span class=\"chat_line\">.*<\/span>/i,c));return a}},{name:"TppGUIConvertALLCAPS",comment:"Convert ALLCAPS to lowercase",def:!0,customCss:[],predicate:function(a,d){return d===d.toUpperCase()?a.replace(/>.*</ig,function(b,a,d){return b.toLowerCase()}):a}}],w=function(){function a(){var b=f("#twitch_chat .js-chat-scroll");void 0==a.baseHeight&&(a.baseHeight=parseInt(b.css("bottom")));b.css("bottom",a.baseHeight+f("#TppControlPanel").height()+f(h).height())}var d=f("#chat_line_list"),b=[];n.forEach(function(a){a=a.name;b.push("#chat_line_list."+a+" li."+a+"{display:none}")});p.forEach(function(a){a.customCss.forEach(function(a){b.push(a)})});var c=document.createElement("style");c.appendChild(document.createTextNode(b.join("")));var e=document.createElement("div");e.id="TppControlPanel";e.className="hidden";var l=document.createElement("table");e.appendChild(l);n.forEach(function(a){var b=document.createElement("tr");l.appendChild(b);var c;c=document.createElement("td");var e=document.createElement("input");e.type="checkbox";e.checked=a.def;c.appendChild(e);b.appendChild(c);c=document.createElement("td");c.appendChild(document.createTextNode(a.comment));b.appendChild(c);a.def&&d.addClass(a.name);f(e).click(function(){d.toggleClass(a.name)})});p.forEach(function(a){var b=document.createElement("tr");l.appendChild(b);var c;c=document.createElement("td");var d=document.createElement("input");d.type="checkbox";d.checked=a.def;c.appendChild(d);b.appendChild(c);c=document.createElement("td");c.appendChild(document.createTextNode(a.comment));b.appendChild(c);f(d).click(function(){a.def=!a.def})});var h=document.createElement("button");h.appendChild(document.createTextNode("Chat Filter settings"));f(h).click(function(){f(e).toggleClass("hidden")});var g=document.getElementById("controls");document.body.appendChild(c);g.appendChild(h);g.appendChild(e);f(h).click(a);a()},x=function(){var a=m.CurrentChat;f("#chat_line_list li").each(function(){var a=f(this),b=a.find(".chat_line").text(),c=f(this)["0"].innerHTML,e=s(c,b);e!==c&&(c=c.replace('class="','style="display:none" class="original_message ')+e.replace('class="','class="modified_message '));r(b).forEach(function(b){a.addClass(b)})});a.line_buffer=800;a.insert_with_lock_in=function(){var a=this.set_currently_scrolling;this.set_currently_scrolling=function(){};for(var b,c,e="",l=[];0<this.queue.length;){b=this.queue.shift();if(b.linkid){var h=r(b.info.message).join(" ");b.line=b.line.replace('class="','class="'+h+" ");l.push({info:b.info,linkid:b.linkid});h=s(b.line,b.info.message);h!==b.line&&(b.line=b.line.replace('class="','style="display:none" class="original_message ')+h.replace('class="','class="modified_message '))}"#chat_line_list"===b.el&&(this.line_count+=1);c&&c!==b.el&&(f(c).append(e),e="");c=b.el;e+=b.line}c&&f(c).append(e);for(c=0;c<l.length;c++)b=l[c],this.setup_viewer_handlers(b.info,b.linkid);this.line_count>this.line_buffer&&(b=f("#chat_line_list li:hidden"),this.line_count-=b.length,b.remove(),this.line_count>this.line_buffer&&(b=f("#chat_line_list li:lt("+(this.line_count-this.line_buffer)+")"),this.line_count-=b.length,b.remove()),this.history_ended&&this.scroll_chat());var g=this;setTimeout(function(){g.history_ended&&(g.scroll_chat(),g.set_currently_scrolling=a,g.appending=!1)},1)}};f(function(){w();var a=setInterval(function(){"none"==f("#chat_loading_spinner").css("display")&&(clearInterval(a),x())},100)})})();
... Apparently it gives some line breaks, though, which isn't good.
Maybe with http://refresh-sf.com/yui/ ?
EDIT: Nope, not working too.
EDIT 2: Sorry, I'm stupid. Use this link, paste it in the URL(s)
tab and compress https://raw.github.com/jpgohlke/twitch-chat-filter/master/chat_filter.user.js
. It works for me now!
for YUI compressor try the option "Minify only, no symbol obfuscation."
@eltacodeldiablo Worked whiteout this option, too.