Advertisement
Foxscotch

work in progress

Oct 27th, 2015
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. // ==UserScript==
  2. // @name         Extended Who's Online
  3. // @namespace    http://foxscotch.us/
  4. // @version      1.0
  5. // @description  Script that places all pages of the BLF Who's Online list onto one page.
  6. // @author       Foxscotch
  7. // @match        http://forum.blockland.us/*
  8. // @grant        none
  9. // ==/UserScript==
  10.  
  11.  
  12. var includeGuests = true;
  13. var automatic = false;
  14.  
  15. var createParameterDict = function () {
  16.     var parameters = {};
  17.     var paramsWithValues = window.location.search.slice(1).split(';');
  18.  
  19.     for (var i = 0; i < paramsWithValues.length; i++) {
  20.         var paramThenValue = paramsWithValues[i].split('=');
  21.         if (paramThenValue[1]) {
  22.             parameters[paramThenValue[0]] = paramThenValue[1];
  23.         }
  24.         else {
  25.             parameters[paramThenValue[0]] = true;
  26.         }
  27.     }
  28.    
  29.     return parameters;
  30. };
  31.  
  32. var parameters = createParameterDict();
  33.  
  34. function addTable () {
  35.     var newUserTable = this.response.getElementsByTagName('table')[2].children[0];
  36.     for (var j = 1; j < newUserTable.children.length - 1 ; j++) {
  37.         var currentEntry = newUserTable.children[j];
  38.         if (currentEntry.children[0].children[0].innerHTML != 'Guest') {
  39.             userTable.insertBefore(currentEntry, pagination);
  40.         }
  41.     }
  42. }
  43.  
  44. function removeGuests () {
  45.     for (var i = 1; i < userTable.children.length - 1; i++) {
  46.         if (userTable.children[i].children[0].children[0].innerHTML == 'Guest') {
  47.             userTable.removeChild(userTable.children[i]);
  48.         }
  49.     }
  50. };
  51.  
  52. if (parameters.action == 'who') {
  53.     var userTable = document.getElementsByTagName('table')[2].children[0];
  54.     var pageCount = Number(document.getElementsByClassName('navPages')[document.getElementsByClassName('navPages').length - 1].innerHTML);
  55.     var pagination = userTable.children[userTable.children.length - 1];
  56.    
  57.     var url = String(window.location);
  58.     if (parameters.start) {
  59.         url = url.replace(/;?start=[\d]+/, '');
  60.     }
  61.    
  62.     for (var i = 2; i <= pageCount; i++) {
  63.         var request = new XMLHttpRequest();
  64.         request.responseType = 'document';
  65.         request.onload = addTable;
  66.         request.open('GET', url + ';start=' + ((i - 2) * 30));
  67.         request.send();
  68.     }
  69.    
  70.     window.onload = removeGuests;
  71. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement