1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-09-17 10:16:57 +00:00

Most changes for 3.5.481. Closes #146.

This commit is contained in:
SirStendec 2017-05-09 16:49:24 -04:00
parent 557f56ee55
commit c76f5ab7f9
14 changed files with 261 additions and 60 deletions

View file

@ -360,7 +360,7 @@ FFZ.prototype.modify_channel_live = function(view) {
if ( game === 'Creative' )
tokens = f.tokenize_ctags(tokens);
var el = this.$(".cn-metabar__title .card__title");
var el = this.$(".cn-metabar > div:first-child .js-card__title");
el && el.html(f.render_tokens(tokens));
}.observes('channel.id', 'channel.status', 'channel.game'),

View file

@ -116,6 +116,9 @@ FFZ.prototype.modify_buy_game_now = function(view) {
itad_country: null,
ffz_init: function() {
if ( ! this.$().parents('.cmrc-game-details-box,.cmrc-channel-box').length || ! this.$('button').length )
return;
//f.log("Buy-Game-New Component", this);
this.itad_count = 0;
this.ffzUpdateITADPlain();
@ -138,7 +141,7 @@ FFZ.prototype.modify_buy_game_now = function(view) {
if ( document.body.dataset.currentPath === 'directory.game-details' )
el = document.querySelector('.game-details__page-title');
else
el = document.querySelector('.card__info [data-tt_content="current_game"]');
el = document.querySelector('.js-card__info [data-tt_content="current_game"]');
var output = el ? _.pluck(_.filter(el.childNodes, function(x) { return x.nodeType === document.TEXT_NODE }), 'textContent').join(' ').trim() : null;
@ -302,7 +305,7 @@ FFZ.prototype.modify_buy_game_now = function(view) {
// Add a by-line for IsThereAnyDeal.
var url = data[1].urls && data[1].urls.game || "https://isthereanydeal.com",
by_line = utils.createElement('span', 'ffz-attributiona',
by_line = utils.createElement('span', 'ffz-attributions',
'<hr>Source: <a rel="noreferrer" target="_blank" href="' + utils.quote_san(url) + '">IsThereAnyDeal.com</a><br><br>Any affiliate links in the provided data are the responsibility of IsThereAnyDeal and do not benefit FrankerFaceZ. You may consider visiting the store directly.' +
'<hr>Reminder: When you buy a game from other services, you miss out on the benefits of purchasing from Twitch directly including: supporting partnered streamers and earning <a target="_blank" href="https://blog.twitch.tv/twitch-crates-are-coming-soon-f50fa0cd4cdf">Twitch Crates</a> containing emotes and badges.');

View file

@ -2,7 +2,7 @@
utils = require("../utils"),
constants = require("../constants"),
TB_TOOLTIP = '<hr>This message was flagged by AutoMod. Should it be allowed?',
TB_TOOLTIP = 'This message was flagged by AutoMod. Should it be allowed?',
BAN_SPLIT = /[\/\.](?:ban ([^ ]+)|timeout ([^ ]+)(?: (\d+))?|timeout_message ([^ ]+) ([^ ]+)(?: (\d+))?)(?: (.*))?$/;
@ -11,6 +11,29 @@
// Settings
// ---------------------
FFZ.settings_info.automod_inline = {
type: "boolean",
value: true,
category: "Chat Moderation",
no_bttv: 6,
name: "AutoMod In-Line Actions",
help: "Display AutoMod controls as in-line mod icons instead of space wasting buttons.",
on_update: function(val) {
var CL = utils.ember_resolve('component:chat/chat-line'),
views = CL ? utils.ember_views() : [];
for(var vid in views) {
var view = views[vid];
if ( view instanceof CL && view.ffzRender )
view.ffzRender();
}
}
}
FFZ.settings_info.friend_notifications = {
type: "boolean",
value: false,
@ -841,7 +864,7 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
}
}.property("msgObject.message", "isChannelLinksDisabled", "currentUserNick", "msgObject.from", "msgObject.tags.emotes"),
lineChanged: Ember.observer("msgObject.deleted", "isModeratorOrHigher", "msgObject.ffz_old_messages", "ffzTokenizedMessage", "hasClickedFlaggedMessage", function() {
lineChanged: Ember.observer("msgObject.deleted", "isModeratorOrHigher", "msgObject.ffz_old_messages", "ffzTokenizedMessage", function() {
this.$(".mod-icons").replaceWith(this.buildModIconsHTML());
if ( this.get("msgObject.deleted") ) {
this.$(".message").replaceWith(this.buildDeletedMessageHTML());
@ -849,6 +872,13 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this.$(".deleted,.message").replaceWith(this.buildMessageHTML());
}),
clickedChanged: Ember.observer("hasClickedFlaggedMessage", function() {
if ( f.settings.automod_inline )
this.$(".mod-icons").replaceWith(this.buildModIconsHTML());
else
this.ffzRender();
}),
ffzUpdateBadges: function() {
this.$(".badges").html(f.render_badges(f.get_line_badges(this.get('msgObject'))));
},
@ -889,37 +919,35 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this_ul = this.get('ffzUserLevel'),
other_ul = room && room.room && room.room.get('ffzUserLevel') || 0,
shouldnt_show = is_whisper || this_ul >= other_ul || (f.settings.mod_buttons.length === 0 && ! is_tb),
shouldnt_show = (f.settings.mod_buttons.length === 0 && ! is_tb),
had_output = false,
output;
if ( ! is_pinned_cheer && shouldnt_show )
return '';
shouldnt_show = shouldnt_show || this_ul >= other_ul;
output = ['<span class="mod-icons">'];
if ( is_tb ) {
var clicked = this.get('hasClickedFlaggedMessage'),
inactive = clicked ? ' inactive' : '';
output.push('<a class="mod-icon html-tooltip tb-reject' + inactive + (clicked ? '' : '" title="Not Allowed' + TB_TOOLTIP) + '">Not Allowed</a>');
output.push('<a class="mod-icon html-tooltip tb-allow' + inactive + (clicked ? '' : '" title="Allowed' + TB_TOOLTIP) + '">Allowed</a>');
}
if ( is_pinned_cheer ) {
var parent = this.get('ffzPinnedParent');
had_output = true;
if ( parent && PinnedCheers && PinnedCheers.canDismissPinnedCheer(parent.get('userData.id'), parent.get('isViewerModeratorOrHigher')) )
output.push('<a class="mod-icon html-tooltip pc-dismiss" title="Dismiss for Everyone">Dismiss</a>');
if ( is_pinned_cheer !== 2 )
output.push('<a class="mod-icon html-tooltip pc-dismiss-local" title="Dismiss">Dismiss</a>');
}
if ( ! shouldnt_show )
if ( ! is_whisper )
for(var i=0, l = f.settings.mod_buttons.length; i < l; i++) {
var pair = f.settings.mod_buttons[i],
prefix = pair[0], btn = pair[1], had_label = pair[2], is_emoji = pair[3],
prefix = pair[0], btn = pair[1], had_label = pair[2], is_emoji = pair[3], non_mod = pair[4],
cmd, tip;
if ( ! non_mod && shouldnt_show )
continue;
if ( is_emoji ) {
var setting = f.settings.parse_emoji,
token = f.emoji_data[is_emoji],
@ -937,6 +965,8 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
}
}
had_output = true;
if ( btn === false ) {
if ( deleted )
output.push('<a class="mod-icon html-tooltip unban" title="Unban User" href="#">Unban</a>');
@ -958,7 +988,16 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
}
}
return output.join('') + '</span>';
if ( f.settings.automod_inline && is_tb ) {
var clicked = this.get('hasClickedFlaggedMessage'),
inactive = clicked ? ' inactive' : '';
had_output = true;
output.push('<a class="mod-icon html-tooltip tb-reject' + inactive + (clicked ? '' : '" title="Not Allowed<hr>' + TB_TOOLTIP) + '">Not Allowed</a>');
output.push('<a class="mod-icon html-tooltip tb-allow' + inactive + (clicked ? '' : '" title="Allowed<hr>' + TB_TOOLTIP) + '">Allowed</a>');
}
return had_output ? output.join('') + '</span>' : '';
},
buildFromHTML: function(is_recipient) {
@ -1081,6 +1120,18 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
return output + '</span>';
},
buildAutoModHTML: function() {
if ( this.get('hasClickedFlaggedMessage') )
return '<div class="system-msg">Thank you for your response!</div>';
return '<p class="inline-warning">' + TB_TOOLTIP + '</p>' +
'<div class="pd-y-1 clearfix">' +
'<a class="button button--small button--alert float-left mg-r-1 tb-button" data-action="no">Deny</a>' +
'<a class="button button--small float-left mg-r-1 tb-button" data-action="yes">Allow</a>' +
'<a class="button button--small button--text float-left tb-button" data-action="not sure">Not Sure</a>' +
'</div>';
},
ffzRender: function() {
var el = this.get('element'),
output = '<div class="indicator"></div>';
@ -1093,6 +1144,9 @@ FFZ.prototype._modify_chat_line = function(component, is_vod) {
this.buildDeletedMessageHTML() : this.buildMessageHTML();
}
if ( ! f.settings.automod_inline && this.get('msgObject.autoModRejected') )
output += this.buildAutoModHTML();
el.innerHTML = output;
},
@ -1302,7 +1356,8 @@ FFZ.prototype._modify_chat_subline = function(component, is_whisper) {
return;
var cl = e.target.classList,
from = this.get("msgObject.from");
from = this.get("msgObject.from"),
msg_id = this.get("msgObject.tags.id");
/*if ( cl.contains('ffz-old-messages') )
return f._show_deleted(this.get('msgObject.room'));*/
@ -1314,6 +1369,13 @@ FFZ.prototype._modify_chat_subline = function(component, is_whisper) {
} else if ( cl.contains('deleted-link') )
return f._deleted_link_click.call(e.target, e);
else if ( cl.contains('tb-button') ) {
jQuery(e.target).trigger('mouseout');
e.preventDefault();
this.actions.clickedAutoModResponse.call(this, msg_id, e.target.dataset.action);
}
else if ( cl.contains('mod-icon') ) {
jQuery(e.target).trigger('mouseout');
@ -1332,10 +1394,10 @@ FFZ.prototype._modify_chat_subline = function(component, is_whisper) {
);
else if ( cl.contains('tb-reject') )
this.actions.clickedAutoModResponse.call(this, this.get('msgObject.tags.id'), 'no');
this.actions.clickedAutoModResponse.call(this, msg_id, 'no');
else if ( cl.contains('tb-allow') )
this.actions.clickedAutoModResponse.call(this, this.get('msgObject.tags.id'), 'yes');
this.actions.clickedAutoModResponse.call(this, msg_id, 'yes');
else if ( ! from )
return;

View file

@ -381,7 +381,7 @@ FFZ.settings_info.mod_buttons = {
for(var i=0; i < this.settings.mod_buttons.length; i++) {
var pair = this.settings.mod_buttons[i],
prefix = pair[0], cmd = pair[1], had_prefix = pair[2];
prefix = pair[0], cmd = pair[1], had_prefix = pair[2], non_mod = pair[4];
if ( cmd === false )
cmd = "/ban";
@ -391,7 +391,7 @@ FFZ.settings_info.mod_buttons = {
cmd = '' + cmd;
prefix = had_prefix ? 'name:' + prefix + '=' : '';
old_val += (old_val.length ? '\n' : '') + prefix + cmd;
old_val += (old_val.length ? '\n' : '') + (non_mod ? 'nonmod:' : '') + prefix + cmd;
}
utils.prompt(
@ -406,6 +406,10 @@ FFZ.settings_info.mod_buttons = {
"name of the button. End the name with an equals sign. Only the first character will be displayed.<br>" +
"<strong>Example:</strong> <code>name:B=/ban {user}</code><hr>" +
"To create a button that will be visible even if you don't have moderator privileges over a user, " +
"start your line with <code>nonmod:</code><br>" +
"<strong>Example:</strong> <code>nonmod:/w some_bot !info {user}</code><hr>" +
"<strong>Allowed Variables</strong><br><table><tbody>" +
"<tr><td><code>{user}</code></td><td>target user's name</td>" +
"<td><code>{user_name}</code></td><td>target user's name</td></tr>" +
@ -430,11 +434,15 @@ FFZ.settings_info.mod_buttons = {
var cmd = vals[i],
prefix,
is_emoji = false,
name_match = /^name:([^=]+)=/.exec(cmd);
non_mod = /^nonmod:/.test(cmd);
if ( ! cmd || ! cmd.length )
continue;
if ( non_mod )
cmd = cmd.substr(7).trim();
var name_match = /^name:([^=]+)=/.exec(cmd);
if ( name_match ) {
label = name_match[1];
@ -447,6 +455,13 @@ FFZ.settings_info.mod_buttons = {
is_emoji = tokens[0].ffzEmoji;
cmd = cmd.substr(name_match[0].length).trim();
if ( ! non_mod ) {
non_mod = /^nonmod:/.test(cmd);
if ( non_mod )
cmd = cmd.substr(7).trim();
}
} else
label = undefined;
@ -487,7 +502,7 @@ FFZ.settings_info.mod_buttons = {
}
}
output.push([label, cmd, name_match != null, is_emoji]);
output.push([label, cmd, name_match != null, is_emoji, non_mod]);
}
f.settings.set('mod_buttons', output);

View file

@ -1330,17 +1330,20 @@ FFZ.prototype._modify_room = function(room) {
},
addFriendsWatchingMessage: function(msg) {
if ( f.settings.friend_notifications && ! document.hasFocus() )
f.show_notification(
msg.replace(/ *VoHiYo$/g, ''),
document.title,
"ffz_watching_notice",
(this.settings.notification_timeout*1000),
function() {
window.focus();
},
null,
'https://static-cdn.jtvnw.net/emoticons/v1/81274/3.0');
if ( f.settings.friend_notifications && ! document.hasFocus() ) {
var Chat = utils.ember_lookup('controller:chat');
if ( Chat && Chat.get('currentChannelRoom') === this )
f.show_notification(
msg.replace(/ *VoHiYo$/g, ''),
(this.get('channel.display_name') || this.get('id')) + " - Twitch",
"ffz_watching_notice",
(this.settings.notification_timeout*1000),
function() {
window.focus();
},
null,
'https://static-cdn.jtvnw.net/emoticons/v1/81274/3.0');
}
this.addMessage({
style: 'admin' + (f.has_bttv_6 ? '' : ' friend-watching'),