Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save Kurotaku-sama/b9a691e997506b320a8795fe7592381a to your computer and use it in GitHub Desktop.
Save Kurotaku-sama/b9a691e997506b320a8795fe7592381a to your computer and use it in GitHub Desktop.
Adds buttons to send commands in the Twitch chat
// ==UserScript==
// @name Twitch GameGiveawaysTV command buttons
// @namespace https://kurotaku.de
// @version 1.0.2
// @description Adds buttons to send commands in the Twitch chat
// @author Kurotaku
// @license MIT
// @match https://www.twitch.tv/gamegiveawaystv*
// @match https://www.twitch.tv/*/gamegiveawaystv/chat*
// @icon https://static.twitchcdn.net/assets/favicon-32-e29e246c157142c94346.png
// @updateURL https://gist.github.com/Kurotaku-sama/b9a691e997506b320a8795fe7592381a/raw/Twitch%2520GameGiveawaysTV%2520command%2520buttons.user.js
// @downloadURL https://gist.github.com/Kurotaku-sama/b9a691e997506b320a8795fe7592381a/raw/Twitch%2520GameGiveawaysTV%2520command%2520buttons.user.js
// @require https://gist.github.com/Kurotaku-sama/9ebeb659500f6eee2f780344948e1e8f/raw/kuros_library.user.js
// @require https://gist.github.com/Kurotaku-sama/a5a08a94398ea55123f8c09069fe68ee/raw/kuros_twitch_button_library.user.js
// @require https://openuserjs.org/src/libs/sizzle/GM_config.js
// @grant GM_getValue
// @grant GM_setValue
// @grant GM_registerMenuCommand
// ==/UserScript==
let twitch_channel = 'gamegiveawaystv';
(async function() { // Must be here and not inside kuros_twitch_button_library.user.json otherwise loading order is wrong
await init_gm_config(); // Initialize the configuration
main();
})();
async function init_gm_config() {
GM_registerMenuCommand('Settings', () => {
GM_config.open();
});
let frame = document.createElement('div');
document.body.appendChild(frame);
GM_config.init(
{
'id': 'configuration',
'title': 'Twitch hitsquadgodfather config',
'fields':
{
'script_enabled':
{
'label': 'Enable/Disable the script',
'type': 'checkbox',
'default': true
},
'auth_username':
{
'label': 'Username',
'type': 'textbox'
},
'auth_oauth':
{
'label': 'Oauth (required for IRC connection to chat!)<br>Can be generated here: https://twitchapps.com/tmi/',
'type': 'textbox'
},
'voucher_buttons': {
'label': 'Voucher redemption buttons',
'type': 'checkbox',
'default': true
},
'buttons_general':
{
'label': 'General buttons',
'type': 'checkbox',
'default': true
},
'bypass_shadowban': {
'label': 'Prevent Shadowban:<br>Enable this only, if you get shadowbanned after a couple of commands.<br>(Shadowban is when your messages are temporarily not appear)',
'type': 'checkbox',
'default': false
},
},
'events': {
'save': () => {location.reload()},
},
'frame': frame,
});
}
function generate_command_buttons() {
let buttongroups = "";
if(GM_config.get("buttons_general"))
buttongroups += `${btngrp_label("General")}
<div class="k-buttongroup">
${btngrp_button("arrow", "Arrow")}
${btngrp_button("battle", "Battle")}
${btngrp_button("gamecoins", "Gamecoins")}
</div>`;
insert_command_button(buttongroups);
}
async function generate_voucher_buttons() {
insert_voucher_buttons(
generate_voucher_button("Get 100 GameCoins", 500, "+100 GC") +
generate_voucher_button("Get 1000 GameCoins", 4900, "+1k GC") +
generate_voucher_button("Get 10000 GameCoins", 48000, "+10k GC")
);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment