Last active
June 3, 2019 15:51
-
-
Save PentaHelix/68960949916bbd950b2bd4d02729e658 to your computer and use it in GitHub Desktop.
This file contains 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
// ==UserScript== | |
// @name New Userscript | |
// @namespace http://tampermonkey.net/ | |
// @version 0.1 | |
// @description try to take over the world! | |
// @author You | |
// @match https://github.com/*/*/issues* | |
// @grant window.close | |
// @grant GM_getValue | |
// @grant GM_setValue | |
// @grant GM_deleteValue | |
// @grant GM_addValueChangeListener | |
// @grant GM_openInTab | |
// @grant GM_registerMenuCommand | |
// ==/UserScript== | |
(function() { | |
'use strict'; | |
let isController = !GM_getValue('has-controller', false) | |
if (isController) { | |
GM_registerMenuCommand('Scrape issuers', run) | |
} else { | |
run() | |
} | |
})(); | |
function run () { | |
let isController = !GM_getValue('has-controller', false) | |
let users = GM_getValue('collected-users') || '[]' | |
users = JSON.parse(users) | |
if (isController) { | |
GM_setValue('has-controller', true) | |
GM_setValue('collected-users', users) | |
GM_setValue('done-collecting', false) | |
GM_addValueChangeListener('done-collecting', (a, b, c, remote) => { | |
if (!remote) return | |
console.log(new Set(JSON.parse(GM_getValue('collected-users')))) | |
GM_deleteValue('has-controller') | |
GM_deleteValue('collected-users') | |
GM_deleteValue('done-collecting') | |
}) | |
} | |
let els = document.querySelectorAll('a[data-hovercard-type="user"]') | |
for (let el of els) { | |
let name = el.innerHTML | |
users.push(name) | |
} | |
GM_setValue('collected-users', JSON.stringify(users)) | |
let next = document.querySelector('a[rel="next"]') | |
if (next) { | |
let url = "https://github.com" + next.getAttribute('href') | |
GM_openInTab(url, { | |
active: false, | |
setParent: true | |
}) | |
} else { | |
GM_setValue('done-collecting', true) | |
} | |
if (!isController) window.close() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment