This repository has been archived by the owner on Jul 19, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathoverride-default.js
74 lines (70 loc) · 9.31 KB
/
override-default.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
const initDataEncoded = new URLSearchParams(window.location.search).get('data')
// https://github.com/discohook/site/blob/main/common/base64/base64Encode.ts
const base64Encode = (utf8) => {
const encoded = encodeURIComponent(utf8)
const escaped = encoded.replace(/%[\dA-F]{2}/g, hex => {
return String.fromCharCode(Number.parseInt(hex.slice(1), 16))
})
return btoa(escaped)
}
const defaultEncoded = 'eyJtZXNzYWdlcyI6W3siZGF0YSI6eyJjb250ZW50IjoiSGV5LCB3ZWxjb21lIHRvIDw6ZGlzY29ob29rOjczNjY0ODM5ODA4MTYyMjAxNj4gKipEaXNjb2hvb2sqKiEgVGhlIGVhc2llc3Qgd2F5IHRvIHBlcnNvbmFsaXNlIHlvdXIgRGlzY29yZCBzZXJ2ZXIuXG5cblRoZXJlJ3MgbW9yZSBpbmZvIGJlbG93LCBidXQgeW91IGRvbid0IGhhdmUgdG8gcmVhZCBpdC4gSWYgeW91J3JlIHJlYWR5IHByZXNzICoqQ2xlYXIgQWxsKiogaW4gdGhlIHRvcCBvZiB0aGUgZWRpdG9yIHRvIGdldCBzdGFydGVkLlxuXG5EaXNjb2hvb2sgaGFzIGEgW3N1cHBvcnQgc2VydmVyXShodHRwczovL2Rpc2NvaG9vay5hcHAvZGlzY29yZCksIGlmIHlvdSBuZWVkIGhlbHAgZmVlbCBmcmVlIHRvIGpvaW4gaW4gYW5kIGFzayBxdWVzdGlvbnMsIHN1Z2dlc3QgZmVhdHVyZXMsIG9yIGp1c3QgY2hhdCB3aXRoIHRoZSBjb21tdW5pdHkuXG5cbld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ZWQhIn0seyJuYW1lIjoiT3RoZXIgZmVhdHVyZXMiLCJ2YWx1ZSI6IkRpc2NvaG9vayBjYW4gYWxzbyBncmFiIGltYWdlcyBmcm9tIHByb2ZpbGUgcGljdHVyZXMgb3IgZW1vamksIG1hbmFnZSB5b3VyIHdlYmhvb2tzLCBhbmQgbW9yZS4gSW52aXRlIHRoZSBib3QgYW5kIHVzZSAqKi9oZWxwKiogdG8gbGVhcm4gYWJvdXQgYWxsIHRoZSBib3Qgb2ZmZXJzISJ9XX1dLCJhdHRhY2htZW50cyI6W119fV19'
const overrideData = {
content: 'Hey, welcome to <:discohook:736648398081622016> **Discohook** (plus <:utilshook:886428915172798494> **Discohook Utils**)! The easiest way to personalise your Discord server.\n\nThere\'s more info below, but you don\'t have to read it. If you\'re ready press **Clear All** in the top of the editor to get started.\n\nDiscohook has a [support server](https://discohook.app/discord), if you need help feel free to join in and ask questions, suggest features, or just chat with the community.\n\nWe also have [complementary bot](https://discohook.app/bot) that may help out, featuring reaction roles and other utilities.\n_ _',
embeds: [
{
title: 'You have the Discohook Utils extension installed!',
description: 'If you\'re seeing this after loading into the default Discohook page, that means you installed the Discohook Utils browser extension successfully. Great job!\n\nBe sure to check out [the feature list](https://github.com/shayypy/discohook-utils-extension/blob/main/README.md#features) to see what all this extension can do for you.\n\n:warning: Chances are you\'ll need the Discohook Utils bot in your server! You can [invite it here](https://dutils.shay.cat/invite) if you haven\'t already.',
color: 16744959,
author: {
name: 'Discohook Utils',
url: 'https://dutils.shay.cat',
icon_url: 'https://cdn.discordapp.com/avatars/792842038332358656/da056550fd65a4d7e4636cb1707ca801.png?size=64'
}
},
{
title: 'What\'s this about?',
description: 'Discohook is a free tool that allows you to personalise your server to make your server stand out from the crowd. The main way it does this is using [webhooks](https://support.discord.com/hc/en-us/articles/228383668), which allows services like Discohook to send any messages with embeds to your server.\n\nTo get started with sending messages, you need a webhook URL, you can get one via the \'Integrations\' tab in your server\'s settings. If you\'re having issues creating a webhook, [the bot](https://discohook.app/bot) can help you create one for you.\n\nKeep in mind that Discohook can\'t do automation yet, it only sends messages when you tell it to. If you are looking for an automatic feed or custom commands this isn\'t the right tool for you.',
color: 5814783,
author: {
name: 'Discohook',
icon_url: 'https://cdn.discordapp.com/avatars/633565743103082527/fa47564fcd19857e833e97c6c0208966.png?size=64'
}
},
{
title: 'Discord bot',
description: 'Discohook has a bot as well, it\'s not strictly required to send messages it may be helpful to have it ready.\n\nBelow is a small but incomplete overview of what the bot can do for you.',
color: 5814783,
fields: [
{
name: 'Getting special formatting for mentions, channels, and emoji',
value: 'The **/format** command of the bot can give you special formatting for use in Discord messages that lets you create mentions, tag channels, or use emoji ready to paste into the editor!\n\nThere are [manual ways](https://discord.dev/reference#message-formatting) of doing this, but it\'s very error prone. The bot will make sure you\'ll always get the right formatting for your needs.'
},
{
name: 'Creating reaction roles',
value: 'You can manage reaction roles with the bot using the **/reaction-role** command.\n\nThe set-up process is very intuitive: type out **/reaction-role create**, paste a message link, select an emoji, and pick a role. Hit enter and you\'re done, your members can now react to any of your messages to pick their roles.'
},
{
name: 'Recover Discohook messages from your server',
value: 'It can also restore any message sent in your Discord server for you via the apps menu.\n\nTo get started, right-click or long-press on any message in your server, press on apps, and then press **Restore to Discohook**. It\'ll send you a link that leads to the editor page containing the message you selected!'
},
{
name: 'Other features',
value: 'Discohook can also grab images from profile pictures or emoji, manage your webhooks, and more. Invite the bot and use **/help** to learn about all the bot offers!'
}
],
author: {
name: 'Discohook',
icon_url: 'https://cdn.discordapp.com/avatars/633565743103082527/fa47564fcd19857e833e97c6c0208966.png?size=64'
}
}
],
attachment: [],
}
console.log('[Discohook Utils] Loaded override-default')
if (!initDataEncoded || initDataEncoded === defaultEncoded) {
// Page loaded without data param or user loaded default
console.debug('[Discohook Utils] Reloading with Discohook Utils landing page')
const url = new URL(window.location.href)
url.searchParams.set('data', base64Encode(JSON.stringify({ messages: [{ data: overrideData }]})))
window.location.href = url.toString()
}