Skip to content

Instantly share code, notes, and snippets.

@techygrrrl
Last active November 20, 2023 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save techygrrrl/9d56dda7382026fb2c1227c8c2c46c0a to your computer and use it in GitHub Desktop.
Save techygrrrl/9d56dda7382026fb2c1227c8c2c46c0a to your computer and use it in GitHub Desktop.
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 jsonData = []
const sqlData = [
// Chat scopes are not on this page for some reason
"('channel:moderate'),",
"('chat:read'),",
"('chat:edit'),",
]
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;
sqlData.push(`('${scopeName}'),`)
});
const sortedSqlData = sqlData.sort()
console.log('🔏 Scraping scopes')
console.table(jsonData)
console.log('--------- JSON data:')
console.log(JSON.stringify(jsonData, null, 2))
console.log('--------- SQL data:')
console.table(sortedSqlData.join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment