Skip to content

Instantly share code, notes, and snippets.

View noodlebox's full-sized avatar
🍜

noodlebox

🍜
View GitHub Profile
@noodlebox
noodlebox / README.md
Last active October 13, 2022 00:40
Self-installer for BetterDiscord plugins

SelfInstaller.js

This snippet can be added to your BetterDiscord plugins to provide a simple, unintrusive self-installer.

Why do I need this?

A user downloads your plugin for BetterDiscord. Having only skimmed the #faq, he immediately double-clicks it (as he is wont to do with executable files from the internet). Then, a mysterious entity known as the Windows Script Host either spits out a non-sensical error message, or worse, provides no feedback at all. Soon afterwards, he suffers the harsh mocking of the more knowledgeable users of #support.

You can save him this embarassment.

You can save the valuable time of everyone in #support.

@noodlebox
noodlebox / getOwnerInstance.js
Created December 30, 2016 19:46
How to use ReactJS from the wrong end
// This is super hackish, and will likely break as Discord's internal API changes
// Anything using this or what it returns should be prepared to catch some exceptions
const getInternalInstance = e => e[Object.keys(e).find(k => k.startsWith("__reactInternalInstance"))];
function getOwnerInstance(e, {include, exclude=["Popout", "Tooltip", "Scroller", "BackgroundFlash"]} = {}) {
if (e === undefined) {
return undefined;
}
// Set up filter; if no include filter is given, match all except those in exclude
@noodlebox
noodlebox / tempfix.plugin.js
Last active January 9, 2017 19:27
Temporary BD Fix
//META{"name":"tempFix"}*//
/*@cc_on
@if (@_jscript)
// Offer to self-install for clueless users that try to run this directly.
var shell = WScript.CreateObject("WScript.Shell");
var fs = new ActiveXObject("Scripting.FileSystemObject");
var pathPlugins = shell.ExpandEnvironmentStrings("%APPDATA%\\BetterDiscord\\plugins");
var pathSelf = WScript.ScriptFullName;
// Put the user at ease by addressing them in the first person