1
0
Fork 0
mirror of https://github.com/FrankerFaceZ/FrankerFaceZ.git synced 2025-07-07 11:38:32 +00:00

Update readme to mention installing gulp. Also a bug fix for the link thing I just added.

This commit is contained in:
SirStendec 2015-08-09 02:31:55 -04:00
parent 315a91ab5c
commit 82ba070fb9
6 changed files with 42 additions and 153 deletions

View file

@ -15,6 +15,8 @@ server for development. To get everything you need:
1. Install node.js 1. Install node.js
2. Run ```npm install``` within the FrankerFaceZ directory. 2. Run ```npm install``` within the FrankerFaceZ directory.
3. Run ```npm install --global gulp``` to install gulp globally, making it
possible to use the ```gulp``` command.
From there, you can use gulp to build the extension from source simply by From there, you can use gulp to build the extension from source simply by

View file

@ -4589,22 +4589,27 @@ FFZ.get_capitalization = function(name, callback) {
// --------------------- // ---------------------
FFZ.prototype._remove_banned = function(tokens) { FFZ.prototype._remove_banned = function(tokens) {
var banned_words = _.union(['j.mp', 'bit.ly'], this.settings.banned_words); var banned_words = this.settings.banned_words,
if ( ! banned_words || ! banned_words.length ) banned_links = ['j.mp', 'bit.ly'],
has_banned_words = banned_words && banned_words.length;
if ( !has_banned_words && (! banned_links || ! banned_links.length) )
return tokens; return tokens;
if ( typeof tokens == "string" ) if ( typeof tokens == "string" )
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),
new_tokens = []; new_tokens = [];
for(var i=0; i < tokens.length; i++) { for(var i=0; i < tokens.length; i++) {
var token = tokens[i]; var token = tokens[i];
if ( ! _.isString(token ) ) { if ( ! _.isString(token ) ) {
if ( token.emoticonSrc && regex.test(token.altText) ) if ( token.emoticonSrc && has_banned_words && regex.test(token.altText) )
new_tokens.push(token.altText.replace(regex, "$1***")); new_tokens.push(token.altText.replace(regex, "$1***"));
else if ( token.isLink && regex.test(token.href) ) else if ( token.isLink && has_banned_words && regex.test(token.href) )
new_tokens.push({ new_tokens.push({
isLink: true, isLink: true,
href: token.href, href: token.href,
@ -4612,10 +4617,18 @@ 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) )
new_tokens.push({
isLink: true,
href: token.href,
isDeleted: true,
isLong: false,
censoredHref: token.href.replace(link_regex, "$1***")
});
else else
new_tokens.push(token); new_tokens.push(token);
} else } else if ( has_banned_words )
new_tokens.push(token.replace(regex, "$1***")); new_tokens.push(token.replace(regex, "$1***"));
} }
@ -7674,8 +7687,6 @@ require('./ember/moderation-card');
require('./ember/chat-input'); require('./ember/chat-input');
//require('./ember/teams'); //require('./ember/teams');
// Analytics: require('./tracking');
require('./debug'); require('./debug');
require('./ext/betterttv'); require('./ext/betterttv');
@ -7866,8 +7877,6 @@ FFZ.prototype.init_ember = function(delay) {
this.setup_emoticons(); this.setup_emoticons();
this.setup_badges(); this.setup_badges();
//this.setup_piwik();
//this.setup_router(); //this.setup_router();
this.setup_colors(); this.setup_colors();
this.setup_tokenization(); this.setup_tokenization();

8
script.min.js vendored

File diff suppressed because one or more lines are too long

View file

@ -824,22 +824,27 @@ FFZ.get_capitalization = function(name, callback) {
// --------------------- // ---------------------
FFZ.prototype._remove_banned = function(tokens) { FFZ.prototype._remove_banned = function(tokens) {
var banned_words = _.union(['j.mp', 'bit.ly'], this.settings.banned_words); var banned_words = this.settings.banned_words,
if ( ! banned_words || ! banned_words.length ) banned_links = ['j.mp', 'bit.ly'],
has_banned_words = banned_words && banned_words.length;
if ( !has_banned_words && (! banned_links || ! banned_links.length) )
return tokens; return tokens;
if ( typeof tokens == "string" ) if ( typeof tokens == "string" )
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),
new_tokens = []; new_tokens = [];
for(var i=0; i < tokens.length; i++) { for(var i=0; i < tokens.length; i++) {
var token = tokens[i]; var token = tokens[i];
if ( ! _.isString(token ) ) { if ( ! _.isString(token ) ) {
if ( token.emoticonSrc && regex.test(token.altText) ) if ( token.emoticonSrc && has_banned_words && regex.test(token.altText) )
new_tokens.push(token.altText.replace(regex, "$1***")); new_tokens.push(token.altText.replace(regex, "$1***"));
else if ( token.isLink && regex.test(token.href) ) else if ( token.isLink && has_banned_words && regex.test(token.href) )
new_tokens.push({ new_tokens.push({
isLink: true, isLink: true,
href: token.href, href: token.href,
@ -847,10 +852,18 @@ 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) )
new_tokens.push({
isLink: true,
href: token.href,
isDeleted: true,
isLong: false,
censoredHref: token.href.replace(link_regex, "$1***")
});
else else
new_tokens.push(token); new_tokens.push(token);
} else } else if ( has_banned_words )
new_tokens.push(token.replace(regex, "$1***")); new_tokens.push(token.replace(regex, "$1***"));
} }

View file

@ -125,8 +125,6 @@ require('./ember/moderation-card');
require('./ember/chat-input'); require('./ember/chat-input');
//require('./ember/teams'); //require('./ember/teams');
// Analytics: require('./tracking');
require('./debug'); require('./debug');
require('./ext/betterttv'); require('./ext/betterttv');
@ -317,8 +315,6 @@ FFZ.prototype.init_ember = function(delay) {
this.setup_emoticons(); this.setup_emoticons();
this.setup_badges(); this.setup_badges();
//this.setup_piwik();
//this.setup_router(); //this.setup_router();
this.setup_colors(); this.setup_colors();
this.setup_tokenization(); this.setup_tokenization();

View file

@ -1,131 +0,0 @@
var FFZ = window.FrankerFaceZ,
constants = require('./constants'),
PIWIK = ("https:" == document.location.protocol ? 'https:' : 'http:') + '//sir.stendec.me/ffz_piwik/';
// --------------------
// Initialization
// --------------------
FFZ.prototype.setup_piwik = function() {
if ( window._paq != undefined ) {
this.log("Piwik is already present. Disabling analytics.");
this._tracking = false;
return;
}
if ( localStorage['ffzTracking'] == "false" ) {
this.log("The user has opted out of tracking. Disabling analytics.");
this._tracking = false;
return;
}
this.log("Initializing Piwik.");
this._tracking = true;
var _paq = window._paq = [];
_paq.push(['setSiteId', 1]);
_paq.push(['setTrackerUrl', PIWIK + 'piwik.php']);
if ( this.has_bttv )
_paq.push(['setCustomVariable', '3', 'BetterTTV', BetterTTV.info.versionString()]);
var user = this.get_user(), f = this;
if ( user ) {
_paq.push(['setCustomVariable', '1', 'Partnered', user.is_partner ? "Yes" : "No"])
_paq.push(['setCustomVariable', '2', 'User Type', user.is_staff ? "Staff" : (user.is_admin ? "Admin" : "User")]);
_paq.push(['setUserId', user.login]);
Twitch.api.get("channels/" + user.login)
.done(function(data) {
if ( data.logo )
f.track('setCustomVariable', '4', 'Avatar', data.logo);
}).always(function() { f.track_page(); });
} else
this.track_page();
// If someone turned analytics back ON, track that.
if ( localStorage['ffzTracking'] == "true" ) {
this.track('trackEvent', 'Analytics', 'Enable');
localStorage.removeItem('ffzTracking');
}
var script = document.createElement('script');
script.type = 'text/javascript';
script.defer = true;
script.async = true;
script.src = PIWIK + 'piwik.js';
document.head.appendChild(script);
}
// --------------------
// Command
// --------------------
FFZ.chat_commands.analytics = function(room, args) {
var enabled, args = args && args.length ? args[0].toLowerCase() : null;
if ( args == "y" || args == "yes" || args == "true" || args == "on" )
enabled = true;
else if ( args == "n" || args == "no" || args == "false" || args == "off" )
enabled = false;
if ( enabled === undefined )
return "Analytics are currently " + (localStorage.ffzTracking != "false" ? "enabled." : "disabled.");
// Track that someone turned off analytics.
if ( this._tracking && ! enabled && localStorage.ffzTracking != "false" )
this.track('trackEvent', 'Analytics', 'Disable');
localStorage.ffzTracking = enabled;
return "Analytics are now " + (enabled ? "enabled" : "disabled") + ". Please refresh your browser.";
}
FFZ.chat_commands.analytics.help = "Usage: /ffz analytics <on|off>\nEnable or disable FrankerFaceZ analytics. We collect some data about your browser and how you use FrankerFaceZ to help us improve the script. Turn off analytics if you'd rather we not.";
// --------------------
// Tracking Helpers
// --------------------
FFZ.prototype.track = function() {
if ( ! this._tracking )
return;
window._paq && _paq.push(Array.prototype.slice.call(arguments));
}
FFZ.prototype.track_page = function() {
if ( ! this._tracking )
return;
if ( this._old_url )
this.track('setReferrerUrl', this._old_url);
this._old_url = document.location.toString();
this.track('setCustomUrl', this._old_url);
this.track('deleteCustomVariable', '1', 'page');
this.track('deleteCustomVariable', '3', 'page');
var routes = App.__container__.resolve('router:main').router.currentHandlerInfos;
if ( ! routes || routes.length == 0 )
return;
var last = routes[routes.length - 1];
if ( last.name == "channel.index" && last.context ) {
var following = last.context.get("isFollowing.isFollowing");
if ( following !== undefined && following !== null )
this.track('setCustomVariable', '1', 'Following', (following ? "Yes" : "No"), 'page');
var game = last.context.get("game");
if ( game )
this.track("setCustomVariable", "3", "Game", game, "page");
this.track("trackPageView", document.title);
}
}