Last active
September 30, 2017 14:48
-
-
Save thomasgroch/6e8d15141c7d49bf9abc6be0e669e138 to your computer and use it in GitHub Desktop.
Remove fixed height from workana chat system
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// ==UserScript== | |
// @name Workana++ | |
// @namespace https://www.workana.com/messages/index/ | |
// @version 0.3 | |
// @description Remove fixed height from workana chat system | |
// @author Thomas Groch | |
// @match http://www.workana.com/messages/index/* | |
// @match https://www.workana.com/messages/index/* | |
// @grant none | |
// @copyright 2017+, Thomas Groch | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
// Better notifications messages | |
var descs = []; | |
var titles = []; | |
$( "p.notification-desc" ).each(function( index ) { | |
descs.push( $( this ).text() ); | |
}); | |
$( "h6.notification-title" ).each(function( index ) { | |
title = $( this ).text(); | |
title = title.substr(0, title.indexOf(". publicou")); | |
titles.push( title ); | |
$( this ).text(descs[index]); | |
}); | |
$( "p.notification-desc" ).each(function( index ) { | |
$( this ).text(titles[index]); | |
}); | |
// Remove second scroll from chat | |
$("div.message-list.fixed-height").removeClass('fixed-height'); | |
// Make it biiiig! | |
$("#message-add div.col-md-8").attr("class", "col-md-12"); | |
// Bigger textarea to reply | |
$("#MessageContent").attr('style',"height: 400px;"); | |
// Scroll to last message | |
$('html, body').animate({ | |
scrollTop: $(".js-message:last").offset().top - ($(".navbar--primary").height()*1.1) | |
}, 2000); | |
function save(){ | |
console.log('Saving..'); | |
var current_surl = $("form.form_changes").attr('action'); | |
var current_message = $("textarea").val(); | |
var toSaveData = { | |
surl: current_surl, | |
data: current_message | |
}; | |
var savedData = JSON.parse(localStorage.getItem('workanaplusplus')); | |
if (savedData === null || savedData == undefined){ | |
savedData = []; | |
} | |
// find for existing data | |
var found = false; | |
$.each( savedData, function( key, value ) { | |
if(typeof value.surl !== undefined && value.surl == current_surl ){ | |
found = key; | |
} | |
}); | |
if(found !== false ){ | |
// overwride | |
savedData[found] = toSaveData; | |
}else{ | |
// add | |
savedData.push(toSaveData); | |
} | |
localStorage.setItem('workanaplusplus', JSON.stringify(savedData)); | |
} | |
function load(){ | |
console.log('Loading..'); | |
var savedData = localStorage.getItem('workanaplusplus'); | |
savedData = JSON.parse(savedData); | |
var current_surl = $("form.form_changes").attr('action'); | |
$.each( savedData, function( key, value ) { | |
if(typeof value.surl !== undefined && value.surl == current_surl ){ | |
$("textarea").val(value.data) | |
} | |
}); | |
} | |
function main_saveTextArea(){ | |
var savedData = localStorage.getItem('workanaplusplus'); | |
if(savedData == null){ | |
save(); | |
}else{ | |
load(); | |
} | |
} | |
function fn60sec() { | |
save(); | |
} | |
setInterval(fn60sec, 60*1000); | |
main_saveTextArea(); | |
})(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment