1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-06-30 08:08:32 +00:00

3.5.16. Made hiding of shortened links an option. Added option to disable all FFZ notifications. Fixed deleted links from mods when links are disabled.

This commit is contained in:
SirStendec 2015-08-21 19:00:48 -04:00
parent 56392cd879
commit 3238fbcd68
10 changed files with 230 additions and 66 deletions

View file

@ -17,8 +17,9 @@ FFZ.basic_settings.delayed_chat = {
}, },
category: "Chat", category: "Chat",
no_bttv: true,
name: "Delayed Chat", name: "Delay and Filter Chat",
help: "Delay the appearance of chat messages to allow time for moderation and completely hide removed messages.", help: "Delay the appearance of chat messages to allow time for moderation and completely hide removed messages.",
get: function() { get: function() {
@ -89,6 +90,8 @@ FFZ.settings_info.chat_delay = {
value: 0, value: 0,
category: "Chat Appearance", category: "Chat Appearance",
no_bttv: true,
name: "Artificial Chat Delay", name: "Artificial Chat Delay",
help: "Delay the appearance of chat messages to allow for moderation before you see them.", help: "Delay the appearance of chat messages to allow for moderation before you see them.",
@ -156,6 +159,8 @@ FFZ.settings_info.remove_bot_ban_notices = {
type: "boolean", type: "boolean",
value: false, value: false,
no_bttv: true,
category: "Chat Filtering", category: "Chat Filtering",
name: "Remove Bot Ban Notices", name: "Remove Bot Ban Notices",
help: "Remove messages from bots announcing who was banned for what reason and for how long.", help: "Remove messages from bots announcing who was banned for what reason and for how long.",

View file

@ -134,6 +134,18 @@ FFZ.settings_info.hosted_sub_notices = {
}; };
FFZ.settings_info.filter_bad_shorteners = {
type: "boolean",
value: true,
category: "Chat Filtering",
no_bttv: true,
name: "Auto-Hide Potentially Dangerous Shortened Links",
help: "Replace potentially dangerous shortened links. Links are still accessible, but require an extra click to access."
};
FFZ.settings_info.banned_words = { FFZ.settings_info.banned_words = {
type: "button", type: "button",
value: [], value: [],
@ -825,7 +837,7 @@ FFZ.get_capitalization = function(name, callback) {
FFZ.prototype._remove_banned = function(tokens) { FFZ.prototype._remove_banned = function(tokens) {
var banned_words = this.settings.banned_words, var banned_words = this.settings.banned_words,
banned_links = ['j.mp', 'bit.ly'], banned_links = this.settings.filter_bad_shorteners ? ['goo.gl', 'j.mp', 'bit.ly'] : null,
has_banned_words = banned_words && banned_words.length; has_banned_words = banned_words && banned_words.length;
@ -836,10 +848,10 @@ FFZ.prototype._remove_banned = function(tokens) {
tokens = [tokens]; tokens = [tokens];
var regex = FFZ._words_to_regex(banned_words), var regex = FFZ._words_to_regex(banned_words),
link_regex = FFZ._words_to_regex(banned_links), link_regex = this.settings.filter_bad_shorteners && FFZ._words_to_regex(banned_links),
new_tokens = []; new_tokens = [];
for(var i=0; i < tokens.length; i++) { for(var i=0, l = tokens.length; i < l; i++) {
var token = tokens[i]; var token = tokens[i];
if ( ! _.isString(token ) ) { if ( ! _.isString(token ) ) {
if ( token.emoticonSrc && has_banned_words && regex.test(token.altText) ) if ( token.emoticonSrc && has_banned_words && regex.test(token.altText) )
@ -852,13 +864,13 @@ FFZ.prototype._remove_banned = function(tokens) {
isLong: false, isLong: false,
censoredHref: token.href.replace(regex, "$1***") censoredHref: token.href.replace(regex, "$1***")
}); });
else if ( token.isLink && link_regex.test(token.href) ) else if ( token.isLink && this.settings.filter_bad_shorteners && link_regex.test(token.href) )
new_tokens.push({ new_tokens.push({
isLink: true, isLink: true,
href: token.href, href: token.href,
isDeleted: true, isDeleted: true,
isLong: false, isLong: false,
censoredHref: token.href.replace(link_regex, "$1***") isShortened: true
}); });
else else
new_tokens.push(token); new_tokens.push(token);

View file

@ -1102,6 +1102,14 @@ FFZ.prototype._modify_room = function(room) {
if ( ! is_whisper ) if ( ! is_whisper )
msg.room = this.get('id'); msg.room = this.get('id');
// Look up color and labels.
if ( this.tmiRoom && msg.from ) {
if ( ! msg.color )
msg.color = msg.tags && msg.tags.color ? msg.tags.color : this.tmiSession.getColor(msg.from.toLowerCase());
if ( ! msg.labels )
msg.labels = this.tmiRoom.getLabels(msg.from);
}
// Tokenization // Tokenization
f.tokenize_chat_line(msg, false, this.get('roomProperties.hide_chat_links')); f.tokenize_chat_line(msg, false, this.get('roomProperties.hide_chat_links'));
@ -1144,13 +1152,12 @@ FFZ.prototype._modify_room = function(room) {
this.ffzUpdateChatters(msg.from); this.ffzUpdateChatters(msg.from);
} }
var out = this._super(msg);
// Color processing. // Color processing.
if ( msg.color ) if ( msg.color )
f._handle_color(msg.color); f._handle_color(msg.color);
return out; // Add the message.
return this._super(msg);
}, },
setHostMode: function(e) { setHostMode: function(e) {

View file

@ -21,7 +21,7 @@ FFZ.get = function() { return FFZ.instance; }
// Version // Version
var VER = FFZ.version_info = { var VER = FFZ.version_info = {
major: 3, minor: 5, revision: 14, major: 3, minor: 5, revision: 16,
toString: function() { toString: function() {
return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || ""); return [VER.major, VER.minor, VER.revision].join(".") + (VER.extra || "");
} }
@ -343,6 +343,7 @@ FFZ.prototype.init_ember = function(delay) {
this.find_bttv(10); this.find_bttv(10);
this.find_emote_menu(10); this.find_emote_menu(10);
//this.check_news();
this.check_ff(); this.check_ff();
var end = (window.performance && performance.now) ? performance.now() : Date.now(), var end = (window.performance && performance.now) ? performance.now() : Date.now(),

View file

@ -4,6 +4,8 @@ var FFZ = window.FrankerFaceZ,
TWITCH_BASE = "http://static-cdn.jtvnw.net/emoticons/v1/", TWITCH_BASE = "http://static-cdn.jtvnw.net/emoticons/v1/",
helpers, helpers,
EXPLANATION_TRAIL = '<hr>FFZ is hiding this link because this url shortener is known to be used by Twitch spam bots posting malicious links. Please use caution when visiting shortened links.',
SRCSETS = {}; SRCSETS = {};
build_srcset = function(id) { build_srcset = function(id) {
if ( SRCSETS[id] ) if ( SRCSETS[id] )
@ -112,14 +114,15 @@ var FFZ = window.FrankerFaceZ,
build_link_tooltip = function(href) { build_link_tooltip = function(href) {
var link_data = this._link_data[href], var link_data = this._link_data[href],
tooltip; tooltip;
if ( link_data && link_data.tooltip )
return link_data.tooltip;
if ( ! link_data ) if ( ! link_data )
return ""; return "";
if ( link_data.tooltip )
return link_data.tooltip;
if ( link_data.type == "youtube" ) { if ( link_data.type == "youtube" ) {
tooltip = this.settings.link_image_hover ? image_iframe(link_data.full || href, 'ffz-yt-thumb') : ''; tooltip = this.settings.link_image_hover ? image_iframe(link_data.full || href, 'ffz-yt-thumb') : '';
tooltip += "<b>YouTube: " + utils.sanitize(link_data.title) + "</b><hr>"; tooltip += "<b>YouTube: " + utils.sanitize(link_data.title) + "</b><hr>";
@ -323,7 +326,6 @@ FFZ.prototype.setup_tokenization = function() {
var long = e.length > 255; var long = e.length > 255;
if ( ! show_deleted && (delete_links || long) ) if ( ! show_deleted && (delete_links || long) )
return {isLink: true, isDeleted: true, isLong: long, href: e}; return {isLink: true, isDeleted: true, isLong: long, href: e};
//return {mentionedUser: '</span><a class="deleted-link" title="' + utils.quote_attr(e) + '" data-url="' + utils.quote_attr(e) + '" href="#">&lt;' + (e.length > 255 ? 'long link' : 'deleted link') + '&gt;</a><span class="mentioning">', own: true}
return {isLink: true, href: e}; return {isLink: true, href: e};
}) })
); );
@ -382,13 +384,13 @@ FFZ.prototype.tokenize_chat_line = function(msgObject, prevent_notification, del
// Standard tokenization // Standard tokenization
if ( helpers && helpers.linkifyMessage ) { if ( helpers && helpers.linkifyMessage ) {
var labels = msg.labels || [], var labels = msgObject.labels || [],
mod_or_higher = labels.indexOf("owner") !== -1 || mod_or_higher = labels.indexOf("owner") !== -1 ||
labels.indexOf("staff") !== -1 || labels.indexOf("staff") !== -1 ||
labels.indexOf("admin") !== -1 || labels.indexOf("admin") !== -1 ||
labels.indexOf("global_mod") !== -1 || labels.indexOf("global_mod") !== -1 ||
labels.indexOf("mod") !== -1 || labels.indexOf("mod") !== -1 ||
msg.style === 'admin'; msgObject.style === 'admin';
tokens = helpers.linkifyMessage(tokens, delete_links && !mod_or_higher); tokens = helpers.linkifyMessage(tokens, delete_links && !mod_or_higher);
} }
@ -573,7 +575,7 @@ FFZ.prototype.render_tokens = function(tokens, render_links) {
} }
if ( token.isLink ) { if ( token.isLink ) {
var text = token.title || (token.isLong && '<long link>') || (token.isDeleted && '<deleted link>') || token.href; var text = token.title || (token.isLong && '<long link>') || (token.isShortened && '<shortened link>') || (token.isDeleted && '<deleted link>') || token.href;
if ( ! render_links && render_links !== undefined ) if ( ! render_links && render_links !== undefined )
return utils.sanitize(text); return utils.sanitize(text);
@ -627,13 +629,18 @@ FFZ.prototype.render_tokens = function(tokens, render_links) {
// Deleted Links // Deleted Links
var actual_href = href; var actual_href = href;
if ( token.isDeleted ) { if ( token.isShortened ) {
cls = 'shortened-link deleted-link ' + cls;
tooltip = utils.sanitize(token.href) + EXPLANATION_TRAIL;
href = '#';
} else if ( token.isDeleted ) {
cls = 'deleted-link ' + cls; cls = 'deleted-link ' + cls;
tooltip = utils.sanitize(token.censoredHref || token.href); tooltip = utils.sanitize(token.censoredHref || token.href);
href = '#'; href = '#';
} }
return '<a class="' + cls + '" data-url="' + utils.quote_attr(actual_href) + '" href="' + utils.quote_attr(href || '#') + '" title="' + utils.quote_attr(tooltip || '') + '" target="_blank">' + utils.sanitize(text) + '</a>'; return '<a class="' + cls + '" data-original-url="' + utils.quote_attr(token.href) + '" data-url="' + utils.quote_attr(actual_href) + '" href="' + utils.quote_attr(href || '#') + '" title="' + utils.quote_attr(tooltip || '') + '" target="_blank">' + utils.sanitize(text) + '</a>';
} }
if ( token.mentionedUser ) if ( token.mentionedUser )
@ -947,7 +954,7 @@ FFZ.prototype._deleted_link_click = function(e) {
// Get the URL // Get the URL
var href = this.getAttribute('data-url'), var href = this.getAttribute('data-url'),
link = href, link = this.getAttribute('data-original-url') || href,
f = FrankerFaceZ.get(); f = FrankerFaceZ.get();
// Delete Old Stuff // Delete Old Stuff
@ -968,7 +975,7 @@ FFZ.prototype._deleted_link_click = function(e) {
this.textContent = link; this.textContent = link;
// Now, check for a tooltip. // Now, check for a tooltip.
var link_data = f._link_data[link]; var link_data = f._link_data[href];
if ( link_data && typeof link_data != "boolean" ) { if ( link_data && typeof link_data != "boolean" ) {
this.title = link_data.tooltip; this.title = link_data.tooltip;
if ( link_data.unsafe ) if ( link_data.unsafe )

View file

@ -2,6 +2,44 @@ var FFZ = window.FrankerFaceZ,
constants = require("../constants"); constants = require("../constants");
// -------------------
// Initialization
// -------------------
FFZ.prototype._has_news = false;
FFZ.prototype._news_id = 0;
FFZ.prototype.check_news = function(tries) {
jQuery.ajax(constants.SERVER + "script/news.json", {cache: false, dataType: "json", context: this})
.done(function(data) {
FFZ.ws_commands.update_news.bind(this)(data.id);
}).fail(function(data) {
if ( data.status === 404 )
return;
tries = (tries || 0) + 1;
if ( tries < 10 )
setTimeout(this.check_news.bind(this, tries), Math.floor(Math.random()*5)*1000);
});
}
FFZ.ws_commands.update_news = function(version) {
var old_version = parseInt(localStorage.ffzLastNewsId || "0") || 0;
if ( ! old_version || old_version === NaN || old_version < 0 )
old_version = 0;
if ( version <= old_version ) {
this._news_id = old_version;
return;
}
this._has_news = true;
this._news_id = version;
this.update_ui_link();
}
// ------------------- // -------------------
// About Page // About Page
// ------------------- // -------------------
@ -34,6 +72,42 @@ FFZ.menu_pages.about_changelog = {
}; };
FFZ.menu_pages.about_news = {
name: "News",
visible: false,
wide: true,
render: function(view, container) {
// Handle the news state.
if ( this._has_news ) {
this._has_news = false;
localStorage.ffzLastNewsId = this._news_id;
this.update_ui_link();
}
var heading = document.createElement('div');
heading.className = 'chat-menu-content center';
heading.innerHTML = '<h1>FrankerFaceZ</h1><div class="ffz-about-subheading">announcements and news</div>';
jQuery.ajax(constants.SERVER + "script/news.html", {cache: false, context: this})
.done(function(data) {
container.appendChild(heading);
container.innerHTML += data;
}).fail(function(data) {
var content = document.createElement('div');
content.className = 'chat-menu-content menu-side-padding';
content.textContent = 'There was an error loading the announcements from the server.';
container.appendChild(heading);
container.appendChild(content);
});
}
};
FFZ.menu_pages.about = { FFZ.menu_pages.about = {
name: "About", name: "About",
icon: constants.HEART, icon: constants.HEART,
@ -74,11 +148,29 @@ FFZ.menu_pages.about = {
}); });
// Advertising // Button Stuff
var btn_container = document.createElement('div'), var btn_container = document.createElement('div'),
ad_button = document.createElement('a'), ad_button = document.createElement('a'),
news_button = document.createElement('a'),
donate_button = document.createElement('a'),
message = "To use custom emoticons in " + (has_emotes ? "this channel" : "tons of channels") + ", get FrankerFaceZ from http://www.frankerfacez.com"; message = "To use custom emoticons in " + (has_emotes ? "this channel" : "tons of channels") + ", get FrankerFaceZ from http://www.frankerfacez.com";
// News
/*news_button.className = 'button ffz-news';
news_button.innerHTML = 'Announcements and News';
news_button.addEventListener('click', function() {
f._ui_change_page(view, inner, menu, container, 'about_news');
});
btn_container.appendChild(news_button);
btn_container.className = 'chat-menu-content center';
container.appendChild(btn_container);
btn_container = document.createElement('div');*/
// Advertising
ad_button.className = 'button primary'; ad_button.className = 'button primary';
ad_button.innerHTML = "Advertise in Chat"; ad_button.innerHTML = "Advertise in Chat";
ad_button.addEventListener('click', this._add_emote.bind(this, view, message)); ad_button.addEventListener('click', this._add_emote.bind(this, view, message));
@ -86,7 +178,6 @@ FFZ.menu_pages.about = {
btn_container.appendChild(ad_button); btn_container.appendChild(ad_button);
// Donate // Donate
var donate_button = document.createElement('a');
donate_button.className = 'button ffz-donate'; donate_button.className = 'button ffz-donate';
donate_button.href = "https://www.frankerfacez.com/donate"; donate_button.href = "https://www.frankerfacez.com/donate";
@ -97,6 +188,7 @@ FFZ.menu_pages.about = {
btn_container.className = 'chat-menu-content center'; btn_container.className = 'chat-menu-content center';
container.appendChild(btn_container); container.appendChild(btn_container);
// Credits // Credits
var credits = document.createElement('div'); var credits = document.createElement('div');

View file

@ -321,9 +321,19 @@ FFZ.prototype.build_ui_popup = function(view) {
menu.appendChild(el); menu.appendChild(el);
} }
// Render Current Page
var page = (this._last_page || "channel").split("_", 1)[0]; var page = (this._last_page || "channel").split("_", 1)[0];
this._ui_change_page(view, inner, menu, sub_container, page);
// Do we have news?
if ( this._has_news ) {
// Render news, then set the page back so our default doesn't change.
this._ui_change_page(view, inner, menu, sub_container, 'about_news');
this._last_page = page;
} else
// Render Current Page
this._ui_change_page(view, inner, menu, sub_container, page);
// Add the menu to the DOM. // Add the menu to the DOM.
this._popup = container; this._popup = container;

View file

@ -43,4 +43,5 @@ FFZ.prototype.update_ui_link = function(link) {
link.classList.toggle('live', live); link.classList.toggle('live', live);
link.classList.toggle('dark', dark); link.classList.toggle('dark', dark);
link.classList.toggle('blue', blue); link.classList.toggle('blue', blue);
link.classList.toggle('news', this._has_news);
} }

View file

@ -27,6 +27,16 @@ FFZ.prototype.setup_notifications = function() {
// Settings // Settings
// --------------------- // ---------------------
FFZ.settings_info.server_messages = {
type: "boolean",
value: true,
category: "Appearance",
name: "Server Notifications",
help: "Display global FrankerFaceZ notifications."
};
FFZ.settings_info.highlight_notifications = { FFZ.settings_info.highlight_notifications = {
type: "boolean", type: "boolean",
value: false, value: false,
@ -96,6 +106,9 @@ FFZ.settings_info.notification_timeout = {
// --------------------- // ---------------------
FFZ.ws_commands.message = function(message) { FFZ.ws_commands.message = function(message) {
if ( ! this.settings.server_messages )
return;
this.show_message(message); this.show_message(message);
} }

View file

@ -64,6 +64,17 @@ body:not(.ffz-minimal-chat):not(.ffz-menu-replace) .emoticon-selector-toggle + s
.ffz-ui-toggle.blue.live svg.svg-emoticons path { fill: rgba(47,88,185,0.5); } .ffz-ui-toggle.blue.live svg.svg-emoticons path { fill: rgba(47,88,185,0.5); }
.ffz-ui-toggle.blue.live:hover svg.svg-emoticons path { fill: rgba(47,88,185,1); } .ffz-ui-toggle.blue.live:hover svg.svg-emoticons path { fill: rgba(47,88,185,1); }
.ember-chat-container.dark .ffz-ui-toggle.news svg.svg-emoticons path,
.app-main.theatre .ffz-ui-toggle.news svg.svg-emoticons path,
.chat-container.dark .ffz-ui-toggle.news svg.svg-emoticons path,
.ember-chat .chat-interface .textarea-contain .ffz-ui-toggle.dark.news svg.svg-emoticons path,
.ffz-ui-toggle.news svg.svg-emoticons path { fill: rgba(117, 80, 0, 0.5); }
.ember-chat-container.dark .ffz-ui-toggle.news:hover svg.svg-emoticons path,
.app-main.theatre .ffz-ui-toggle.news:hover svg.svg-emoticons path,
.chat-container.dark .ffz-ui-toggle.news:hover svg.svg-emoticons path,
.ember-chat .chat-interface .textarea-contain .ffz-ui-toggle.dark.news:hover svg.svg-emoticons path,
.ffz-ui-toggle.news:hover svg.svg-emoticons path { fill: rgba(117, 80, 0, 0.8); }
.ember-chat-container.dark .ffz-ui-toggle.no-emotes svg.svg-emoticons path, .ember-chat-container.dark .ffz-ui-toggle.no-emotes svg.svg-emoticons path,
.app-main.theatre .ffz-ui-toggle.no-emotes svg.svg-emoticons path, .app-main.theatre .ffz-ui-toggle.no-emotes svg.svg-emoticons path,
@ -443,6 +454,8 @@ body:not(.ffz-minimal-chat):not(.ffz-menu-replace) .emoticon-selector-toggle + s
position: relative; position: relative;
} }
.list-header span.right { float: right; }
.chat-menu-content.collapsable .heading span.right { .chat-menu-content.collapsable .heading span.right {
padding-right: 15px; padding-right: 15px;
} }
@ -1244,17 +1257,20 @@ body:not(.ffz-chat-purge-icon) .ember-chat .mod-icons .purge { display: none; }
margin: -5px 0 5px; margin: -5px 0 5px;
} }
.button.ffz-news,
.button.ffz-donate { .button.ffz-donate {
margin-left: 10px; margin-left: 10px;
background: #00b132;
color: #fff !important; color: #fff !important;
padding: 0 10px; padding: 0 10px;
font-size: 12px; font-size: 12px;
} }
.button.ffz-donate:not(.disabled):hover { .button.ffz-donate { background: #00b132; }
background: #08c43d; .button.ffz-donate:not(.disabled):hover { background: #08c43d; }
}
.button.ffz-news { background: #755000; }
.button.ffz-news:not(.disabled):hover { background: #8a5f03; }
/* Dumb Fixes */ /* Dumb Fixes */