Skip to content

Instantly share code, notes, and snippets.

@techygrrrl
Last active January 30, 2023 04:01
Embed
What would you like to do?
A user script that can be run with ViolentMonkey, TamperMonkey, GreaseMonkey, or any other user script runner. Pop open the console and look at the scopes! Logs both as a table and as JSON.
// ==UserScript==
// @name Twitch scope scraper
// @namespace https://techygrrrl.stream
// @version 0.1
// @description A user script that can be run with ViolentMonkey, TamperMonkey, GreaseMonkey, or any other user script runner. Pop open the console and look at the scopes! Logs both as a table and as JSON.
// @author techygrrrl
// @match https://dev.twitch.tv/docs/authentication/scopes/*
// @grant none
// @icon https://i.imgur.com/U3Ke5uu.png
// ==/UserScript==
var data = []
var scopesTable = document.querySelector("table");
var rows = scopesTable.querySelectorAll("tr");
rows.forEach((row) => {
var [scopeNameCell, scopeDescriptionCell] = row.querySelectorAll("td");
if (!scopeNameCell || !scopeDescriptionCell) {
// The first row uses `td` but should use `th` 🤷🏻‍♀️
return;
}
var scopeName = scopeNameCell.innerText;
var scopeDescriptionHtml = scopeDescriptionCell.innerHTML;
data.push({
scopeName,
scopeDescriptionHtml
})
});
console.log('🔏 Scraping scopes')
console.log(JSON.stringify(data, null, 2))
console.table(data)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment