mirror of https://github.com/calzoneman/sync.git
Allow users to strip images from chat.
This commit is contained in:
parent
97cb751573
commit
aded7b1f38
|
@ -2,7 +2,7 @@
|
|||
"author": "Calvin Montgomery",
|
||||
"name": "CyTube",
|
||||
"description": "Online media synchronizer and chat",
|
||||
"version": "3.18.6",
|
||||
"version": "3.18.7",
|
||||
"repository": {
|
||||
"url": "http://github.com/calzoneman/sync"
|
||||
},
|
||||
|
|
|
@ -113,6 +113,7 @@ mixin us-chat
|
|||
option(value="always") Always
|
||||
+rcheckbox("us-sendbtn", "Add a send button to chat")
|
||||
+rcheckbox("us-no-emotes", "Disable chat emotes")
|
||||
+rcheckbox("us-strip-image", "Remove images from chat")
|
||||
|
||||
mixin us-mod
|
||||
#us-mod.tab-pane
|
||||
|
|
|
@ -67,6 +67,7 @@ var FILTER_TO = 0;
|
|||
var NO_STORAGE = typeof localStorage == "undefined" || localStorage === null;
|
||||
var SOCKETIO_CONNECT_ERROR_COUNT = 0;
|
||||
var HAS_CONNECTED_BEFORE = false;
|
||||
var IMAGE_MATCH = /<img\s[^>]*?src\s*=\s*['\"]([^'\"]*?)['\"][^>]*?>/gi;
|
||||
|
||||
function getOpt(k) {
|
||||
var v = NO_STORAGE ? readCookie(k) : localStorage.getItem(k);
|
||||
|
@ -120,7 +121,8 @@ var USEROPTS = {
|
|||
secure_connection : getOrDefault("secure_connection", false),
|
||||
show_shadowchat : getOrDefault("show_shadowchat", false),
|
||||
emotelist_sort : getOrDefault("emotelist_sort", true),
|
||||
no_emotes : getOrDefault("no_emotes", false)
|
||||
no_emotes : getOrDefault("no_emotes", false),
|
||||
strip_image : getOrDefault("strip_image", false)
|
||||
};
|
||||
|
||||
/* Backwards compatibility check */
|
||||
|
|
|
@ -642,6 +642,7 @@ function showUserOptions() {
|
|||
$("#us-ping-sound").val(USEROPTS.boop);
|
||||
$("#us-sendbtn").prop("checked", USEROPTS.chatbtn);
|
||||
$("#us-no-emotes").prop("checked", USEROPTS.no_emotes);
|
||||
$("#us-strip-image").prop("checked", USEROPTS.strip_image);
|
||||
|
||||
$("#us-modflair").prop("checked", USEROPTS.modhat);
|
||||
$("#us-shadowchat").prop("checked", USEROPTS.show_shadowchat);
|
||||
|
@ -675,6 +676,7 @@ function saveUserOptions() {
|
|||
USEROPTS.boop = $("#us-ping-sound").val();
|
||||
USEROPTS.chatbtn = $("#us-sendbtn").prop("checked");
|
||||
USEROPTS.no_emotes = $("#us-no-emotes").prop("checked");
|
||||
USEROPTS.strip_image = $("#us-strip-image").prop("checked");
|
||||
|
||||
if (CLIENT.rank >= 2) {
|
||||
USEROPTS.modhat = $("#us-modflair").prop("checked");
|
||||
|
@ -1433,6 +1435,16 @@ function sendVideoUpdate() {
|
|||
|
||||
/* chat */
|
||||
|
||||
function stripImages(msg){
|
||||
if (!USEROPTS.strip_image) {
|
||||
return msg;
|
||||
}
|
||||
return msg.replace(IMAGE_MATCH, function(match,img){
|
||||
return CHANNEL.opts.enable_link_regex ?
|
||||
'<a target="_blank" href="'+img+'">'+img+'</a>' : img;
|
||||
});
|
||||
}
|
||||
|
||||
function formatChatMessage(data, last) {
|
||||
// Backwards compat
|
||||
if (!data.meta || data.msgclass) {
|
||||
|
@ -1452,6 +1464,7 @@ function formatChatMessage(data, last) {
|
|||
if (data.meta.forceShowName)
|
||||
skip = false;
|
||||
|
||||
data.msg = stripImages(data.msg);
|
||||
data.msg = execEmotes(data.msg);
|
||||
|
||||
last.name = data.username;
|
||||
|
@ -1519,8 +1532,8 @@ function addChatMessage(data) {
|
|||
if (data.meta.shadow && !USEROPTS.show_shadowchat) {
|
||||
return;
|
||||
}
|
||||
var div = formatChatMessage(data, LASTCHAT);
|
||||
var msgBuf = $("#messagebuffer");
|
||||
var div = formatChatMessage(data, LASTCHAT);
|
||||
// Incoming: a bunch of crap for the feature where if you hover over
|
||||
// a message, it highlights messages from that user
|
||||
var safeUsername = data.username.replace(/[^\w-]/g, '\\$');
|
||||
|
|
Loading…
Reference in New Issue