@SigmaG/

GetListOfAllEmployeesThroughGAPage

JavaScript

No description

fork
loading

This Plugin Crashed!

Error: Error: must not create an existing file {"type":"CREATE_FILE","wid":"0.757617242405892","path":"main.js","file":{"path":"main.js","content":{"asEncoding":{"base64":"LyoKMS4gZmV0Y2ggdGhpcyBwYWdlIGh0dHBzOi8vc2NyaXB0Lmdvb2dsZS5jb20vbWFjcm9zL3MvQUtmeWNieE9Bd1kxXy1jYnk1eGlZREgxZTQ1Ml9OdnlwSXE0bl91Vm43UllnME0tb2tfYWpBL2V4ZWMKMi4gc2V0IHRoZSBET00KMy4gcXVlcnkgdGhlIHVzZXIgSURzCiovCgpmdW5jdGlvbiBmb3JFYWNoKGxpc3QsIGZuKXsKICAgIGlmKCFsaXN0KSByZXR1cm47CgogICAgZm9yKHZhciBpID0gMCwgbGVuID0gbGlzdC5sZW5ndGg7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgZm4uY2FsbChudWxsLCBsaXN0W2ldKTsKICAgIH0KfQoKZnVuY3Rpb24gZ2V0TGlzdCgpewogICAgdmFyIHhociA9IG5ldyBYTUxIdHRwUmVxdWVzdCgpOwogICAgeGhyLm9wZW4oIkdFVCIsICJodHRwczovL3NjcmlwdC5nb29nbGUuY29tL21hY3Jvcy9zL0FLZnljYnhPQXdZMV8tY2J5NXhpWURIMWU0NTJfTnZ5cElxNG5fdVZuN1JZZzBNLW9rX2FqQS9leGVjIik7CiAgICB4aHIuc2VuZCgpOwogICAgeGhyLm9ubG9hZCA9IGZ1bmN0aW9uKCl7CiAgICAgICAgdmFyIG1hdGNoZXMgPSB0aGlzLnJlc3BvbnNlLm1hdGNoKC9odHRwczpcXFwvXFxcL21ldGFcLnN0YWNrZXhjaGFuZ2VcLmNvbVxcXC91c2Vyc1xcXC8oXGQrKVxcXC9bXlxcXSs/XFxcXFxceDIyIGNsYXNzXFxcXHUwMDNkXFxcXFxceDIydXNlcmNhcmQvZyk7CiAgICAgICAgICAgIHVzZXJJRHMgPSBbXTsKCiAgICAgICAgbWF0Y2hlcy5mb3JFYWNoKGZ1bmN0aW9uKG1hdGNoKXsKICAgICAgICAgICAgdXNlcklEcy5wdXNoKCttYXRjaC5tYXRjaCgvXGQrLylbMF0pOwogICAgICAgIH0pOwogICAgICAgIAogICAgICAgIHZhciB0ZW1wLCBpID0gMCwgbGVuID0gdXNlcklEcy5sZW5ndGgsIGo7CgogICAgICAgIGZvcig7IGkgPCBsZW47IGkrKyl7CiAgICAgICAgICAgIGZvcihqID0gMDsgaiA8IGxlbiAtIDEgLSBpOyBqKyspewogICAgICAgICAgICAgICAgaWYodXNlcklEc1tqXSA+IHVzZXJJRHNbaiArIDFdKXsKICAgICAgICAgICAgICAgICAgICB0ZW1wID0gdXNlcklEc1tqXTsKICAgICAgICAgICAgICAgICAgICB1c2VySURzW2pdID0gdXNlcklEc1tqICsgMV07CiAgICAgICAgICAgICAgICAgICAgdXNlcklEc1tqICsgMV0gPSB0ZW1wOwogICAgICAgICAgICAgICAgfQogICAgICAgICAgICB9CiAgICAgICAgfQoKICAgICAgICBpID0gMDsKCiAgICAgICAgZm9yKDsgaSA8IGxlbjsgaSsrKXsKICAgICAgICAgICAgY29uc29sZS5sb2codXNlcklEc1tpXSk7CiAgICAgICAgfQogICAgfTsKfQoKZnVuY3Rpb24gc29ydChhcnJheSl7CiAgICAKfQoKZ2V0TGlzdCgpOw=="},"asBuffer":null},"loaded":true}}
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