Skip to content

Instantly share code, notes, and snippets.

@ismasan
Forked from juque/bulkIntercom.js
Last active December 23, 2015 16:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ismasan/6662122 to your computer and use it in GitHub Desktop.
Save ismasan/6662122 to your computer and use it in GitHub Desktop.
//
// BulkIntercom
// ------------
// Author: Juan Pablo Aqueveque - juque.cl
//
//
// Bulk method for archiving intercom.io messages.
//
// Tired of clicking checkbox fields
// and scrolling to the bottom time and again to
// the end of times?.
// Try this from your browser console:
// Target
var $table = $('#MessageThreadBody');
var when = $table.find('.when');
// regular expression, all messages 29 days old.
// this could be: "1 month" or "2 months" or "months"
// or all together maybe:
// var rg = /5 days|1 month|2 months/
var rg = /29 days/
// finding, triggering and checking field
$.each(when,function(index,value){
var txt = $(value).find('time').text();
if ( txt.match(rg) ) {
var cb = $(value).parent('tr').find('input[type=checkbox]');
cb.trigger('click').attr('checked',true);
}
});
// and now... click the "Close" button and go take a nap.
//
// version: Looking for messages from user
// ---------------------------------------
//
// var $table = $('#MessageThreadBody');
// var fromUser = $table.find('.from_user');
// var rg = /Sergey Brin/
// $.each(fromUser,function(index,value){
// var txt = $(value).text();
// if ( txt.match(rg) ) {
// var cb = $(value).parent('tr').find('input[type=checkbox]');
// cb.trigger('click').attr('checked',true);
// }
// });
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment