Guest User

Untitled

a guest
May 31st, 2015
30
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name        cheqbook mass categorize
  3. // @namespace   cheqbook
  4. // @description cheqbook mass categorize
  5. // @include     https://secure.cheqbook.com/companies/*/accounts?*
  6. // @version     1
  7. // @grant       none
  8. // ==/UserScript==
  9.  
  10. /*
  11.   Change 'Categorize All Uncategorized' to alter the name of the new action button.
  12.   Change if(document.cbinputs[i].value == 'Uncategorized')  from Uncategorized to another category to set target txns
  13.   Change 'Computers & Peripherals' to set new category name for txns
  14.   Change 'status status-0' to 'status status-1' (or 2, 3, 4) to choose which status target txns should have (red, yellow, blue, etc)
  15. */
  16.  
  17. var referenceNode = document.getElementById('bulk_actions');
  18. referenceNode.insertAdjacentHTML('afterEnd', '&nbsp;&nbsp;<button name="btnSubmitProcessRequest" id="btnSubmitProcessRequest" class="btn" type="button" onclick="document.processChecks();">Categorize All Uncategorized</button>')
  19.  
  20. document.processChecks = function() {
  21.   document.cbinputs = document.getElementsByClassName('ui-autocomplete-input');
  22.   for (var i = 0; i < document.cbinputs.length; i++) {
  23.     if(document.cbinputs[i].value == 'Uncategorized') //only currently uncategorized ones
  24.       document.cbinputs[i].value = 'Computers & Peripherals';
  25.   }
  26.   document.cbbtns = document.getElementsByClassName('status');
  27.   for (var j = 0; j < document.cbbtns.length; j++) {
  28.     if(document.cbbtns[j].className == 'status status-0') //only red ones
  29.       {
  30.         setTimeout('document.cbbtns[' + j + '].click()', 200 * j); //don't slam with async queries, delay a little bit
  31.         setTimeout('console.log("Marking green button number ' + j + '")', 200 * j);
  32.       }
  33.   }
  34. }
RAW Paste Data