Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save techygrrrl/f3eb8fec54c40aed5cc31bec71052f03 to your computer and use it in GitHub Desktop.

Select an option

Save techygrrrl/f3eb8fec54c40aed5cc31bec71052f03 to your computer and use it in GitHub Desktop.
Logs the Twitch EventSub subscription types to the console. Pop open the console and look at the data! Logs both as a table and as JSON.
// ==UserScript==
// @name Twitch EventSub subscription type 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/eventsub/eventsub-subscription-types/*
// @grant none
// @icon https://i.imgur.com/U3Ke5uu.png
// ==/UserScript==
var jsonData = []
var sqlData = []
var subscriptionTypesTable = document.querySelector('#subscription-types ~table');
var rows = subscriptionTypesTable.querySelectorAll("tbody tr");
var subNames = []
rows.forEach((row) => {
var [subTypeCell, subNameCell, versionCell, descriptionCell] = row.querySelectorAll("td");
var subType = subTypeCell.innerText;
var subName = subNameCell.innerText;
var description = descriptionCell.innerText;
var link = subTypeCell.querySelector('a')?.href
var version = versionCell.innerText;
sqlData.push(`('${subType}', '${subName}', '${version}', '${description}', '${link}'),`)
subNames.push(subName)
jsonData.push({
subType,
subName,
version,
description,
link,
})
});
console.log('🔏 Scraping EventSub subscription types')
console.table(jsonData)
console.log('--------- JSON data:')
console.log(JSON.stringify(jsonData, null, 2))
const sortedSubNames = subNames.sort()
console.log('--------- Subscription names:')
console.log(sortedSubNames.join('\n'))
console.log('--------- SQL data:')
const sortedSqlData = sqlData.sort()
console.table(sortedSqlData.join('\n'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment