Skip to content

Commit

Permalink
decrease settimeout
Browse files Browse the repository at this point in the history
  • Loading branch information
umitdincel committed Mar 19, 2018
1 parent 5925190 commit 5ad5c37
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion pinter.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,29 @@ var setCredentials = function(messages) {
senderID = getSenderID('left', messages);
me = getOwnerFbID('right', messages);

if(!senderID || !me)
return

return {'me': me, 'sender': senderID};
}

var getSenderID = function(direction, messages){
var anyMessageBox = messages.find('div[data-tooltip-position="'+ direction +'"]')[0];
var threadid = $(anyMessageBox).attr('threadid');

if(!threadid)
return

return threadid.substr(5,);
}

var parseOwnerID = function(participants) {
participants_arr = participants.split('fbid:');
last_ind = participants_arr[2].indexOf('":');

if(!participants_arr)
return

return participants_arr[2].substr(0, last_ind);
}

Expand Down Expand Up @@ -134,6 +143,10 @@ var scanMessages = function() {
$$$('div[message]', function() {
var messageRows = $('div[message].clearfix');
var credentials = setCredentials(messageRows);

if(!credentials)
return

var senderID = credentials.sender;
var me = credentials.me;
var conversationKey = me + '_' + senderID;
Expand Down Expand Up @@ -177,7 +190,7 @@ var scanMessages = function() {

$$$('div[role="gridcell"]', function() {
$('div[role="gridcell"][id^="row_header_id_user"]').on('click', function() {
setTimeout(scanMessages, 2000);
setTimeout(scanMessages, 100);
});
});

Expand Down

0 comments on commit 5ad5c37

Please sign in to comment.