Last active
November 24, 2016 22:41
-
-
Save Tiny-Giant/c1952bc4624e721196628771610c4411 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /* jshint esnext: true */ | |
| const counts = { | |
| NAA: { mod: 0, review: 0, owner: 0 }, | |
| VLQ: { mod: 0, review: 0, owner: 0 } | |
| }; | |
| const start = 1; | |
| const total = 2; | |
| const pages = [], posts = []; | |
| while(pages.length < total) pages.push(pages.length + start); | |
| const flagHandler = flag => posts.push({ | |
| post: $('.answer-link.deleted-answer > a.answer-hyperlink[href]', flag).attr('href').split('#')[1], | |
| type: $('.revision-comment', flag).html() | |
| }); | |
| const pageHandler = HTML => $('.flagged-post', $.parseHTML(HTML)).filter(el => /not an answer|very low quality/.test($('.revision-comment', el).html())).each(flagHandler); | |
| const postHandler = (post, HTML) => { | |
| const $info = $('.deleted-answer-info', $.parseHTML(HTML)); | |
| if ($info.find('.mod-flair').length) { | |
| counts[post.type].mod++; | |
| } else if (/owner/.test($info.text())) { | |
| counts[post.type].owner++; | |
| } else { | |
| counts[post.type].review++; | |
| } | |
| }; | |
| const getPages = () => { | |
| const page = pages.pop(); | |
| if(page === undefined) { | |
| getPosts(); | |
| return; | |
| } | |
| $.get(`/users/flag-summary/4639281?group=1&status=2&page=${ page }`, HTML => { pageHandler(HTML); getPages(); }); | |
| }; | |
| const getPosts = () => { | |
| const post = posts.pop(); | |
| if(post === undefined) { | |
| console.log(counts); | |
| return; | |
| } | |
| $.get(`/posts/ajax-load-realtime/${ post.post }`, HTML => { postHandler(post, HTML); getPosts(); }); | |
| }; | |
| const scanLink = $('<a>').attr('href', '#').click(event => { event.preventDefault(); getPages(); }).html('stats'); | |
| const wrapper = $('<div>').css('padding-bottom', '10px').append(scanLink); | |
| $('#mainbar.user-flag-history').prepend(wrapper); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment