repl.it
@SigmaG/

GetListOfAllEmployeesThroughGAPage

JavaScript

No description

fork
loading
main.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
/*
1. fetch this page https://script.google.com/macros/s/AKfycbxOAwY1_-cby5xiYDH1e452_NvypIq4n_uVn7RYg0M-ok_ajA/exec
2. set the DOM
3. query the user IDs
*/

function forEach(list, fn){
    if(!list) return;

    for(var i = 0, len = list.length; i < len; i++){
        fn.call(null, list[i]);
    }
}

function getList(){
    var xhr = new XMLHttpRequest();
    xhr.open("GET", "https://script.google.com/macros/s/AKfycbxOAwY1_-cby5xiYDH1e452_NvypIq4n_uVn7RYg0M-ok_ajA/exec");
    xhr.send();
    xhr.onload = function(){
        var matches = this.response.match(/https:\\\/\\\/meta\.stackexchange\.com\\\/users\\\/(\d+)\\\/[^\\]+?\\\\\\x22 class\\\\u003d\\\\\\x22usercard/g);
            userIDs = [];

        matches.forEach(function(match){
            userIDs.push(+match.match(/\d+/)[0]);
        });
        
        var temp, i = 0, len = userIDs.length, j;

        for(; i < len; i++){
            for(j = 0; j < len - 1 - i; j++){
                if(userIDs[j] > userIDs[j + 1]){
                    temp = userIDs[j];
                    userIDs[j] = userIDs[j + 1];
                    userIDs[j + 1] = temp;
                }
            }
        }

        i = 0;

        for(; i < len; i++){
            console.log(userIDs[i]);
        }
    };
}

function sort(array){
    
}

getList();
Native Browser JavaScript