Guest User

Untitled

a guest
Jul 19th, 2018
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. var commanderHistory = GM_getValue(Username + "_commander", "");
  2.     commanderHistory = commanderHistory.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ');
  3.    
  4.     var previousCommanders = commanderHistory.split(" ");
  5.     var lastCommander = previousCommanders[previousCommanders.length - 1];
  6.    
  7.     var commanderTimes;
  8.     var previousTimes;
  9.    
  10.     if (commander != lastCommander) {
  11.         commanderHistory = commanderHistory + " " + commander;
  12.         GM_setValue(Username + "_commander", commanderHistory);
  13.        
  14.         var timeStamp = getTimeStamp();
  15.        
  16.         commanderTimes = GM_getValue(Username + "_comm_times", "").trim();
  17.        
  18.         if (commanderTimes == "") {
  19.             commanderTimes = commanderTimes + timeStamp;
  20.         } else {
  21.             commanderTimes = commanderTimes + ":::" + timeStamp;
  22.         }
  23.        
  24.         GM_setValue(Username + "_comm_times", commanderTimes);
  25.     }
  26.    
  27.     var commanderTable = "";
  28.    
  29.     commanderTable += '<table id="table_commanders" class="table_lines" width="100%" cellspacing="0" cellpadding="6" border="0">';
  30.     commanderTable += ' <tbody>';
  31.     commanderTable += '     <tr style="cursor: pointer;">';
  32.     commanderTable += '         <th align="center" colspan="2">Commander History</th>';
  33.     commanderTable += '     </tr>';
  34.        
  35.     commanderTable += '     <tr>';
  36.     commanderTable += '         <th class="subh" align="left">Commander</th>';
  37.     commanderTable += '         <th class="subh" align="right">Date</th>';
  38.     commanderTable += '     </tr>';
  39.        
  40.     commanderTable += ' </tbody>';
  41.     commanderTable += '</table>';
  42.    
  43.     var toReplace = 'officers_nav()\n</script>';
  44.     var replaceWith = toReplace + '\n' + commanderTable;
  45.    
  46.     document.body.innerHTML = document.body.innerHTML.replace(toReplace, replaceWith);
  47.    
  48.     var i;
  49.    
  50.     var entryCommanders = GM_getValue(Username + "_commander", "").replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ').split(' ');
  51.     var entryTimes = GM_getValue(Username + "_comm_times", "").replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ').split(':::');
  52.    
  53.     var len = entryCommanders.length;
  54.    
  55.     for (i = 0; i < len; i++) {
  56.         var currComm = entryCommanders[i];
  57.         var currTime = entryTimes[i];
  58.        
  59.         if (currTime.replace(/(?:(?:^|\n)\s+|\s+(?:$|\n))/g,'').replace(/\s+/g,' ') == "") {
  60.             currTime = '&nbsp;';
  61.         }
  62.        
  63.         var newRow = "";
  64.        
  65.         newRow += '<tr>';
  66.         newRow += ' <td align="left"><b>' + currComm + '</b></td>';
  67.         newRow += ' <td align="right">' + currTime + '</td>';
  68.         newRow += '</tr>';
  69.        
  70.         document.getElementById('table_commanders').insertRow(-1).innerHTML = newRow;
  71.     }
Add Comment
Please, Sign In to add comment