Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
V4NSH4J
GitHub Repository: V4NSH4J/discord-mass-DM-GO
Path: blob/main/discord/token_login.go
310 views
1
// Copyright (C) 2021 github.com/V4NSH4J
2
//
3
// This source code has been released under the GNU Affero General Public
4
// License v3.0. A copy of this license is available at
5
// https://www.gnu.org/licenses/agpl-3.0.en.html
6
7
package discord
8
9
import (
10
"context"
11
"fmt"
12
"os"
13
"strings"
14
15
"github.com/V4NSH4J/discord-mass-dm-GO/utilities"
16
"github.com/chromedp/cdproto/runtime"
17
"github.com/chromedp/chromedp"
18
)
19
20
func LaunchTokenLogin() {
21
var token string
22
utilities.LogWarn("You NEED Google Chrome installed to use this functionalit")
23
token = utilities.UserInput("Enter a token which you want to login into: ")
24
// Navigate to discord.com/login
25
// We have to place this token into local storage
26
// Refresh the page
27
byt, err := os.ReadFile("tokenLogin.js")
28
if err != nil {
29
utilities.LogErr("Error while opening tokenLogin.js %v", err)
30
utilities.ExitSafely()
31
}
32
x := strings.ReplaceAll(string(byt), "asdfgh", token)
33
opts := append(
34
chromedp.DefaultExecAllocatorOptions[3:],
35
chromedp.NoFirstRun,
36
chromedp.NoDefaultBrowserCheck,
37
)
38
parentCtx, cancel := chromedp.NewExecAllocator(context.Background(), opts...)
39
defer cancel()
40
ctx, cancel := chromedp.NewContext(parentCtx)
41
defer cancel()
42
if err := chromedp.Run(ctx,
43
chromedp.Navigate("https://discord.com/login"),
44
chromedp.ActionFunc(func(ctx context.Context) error {
45
_, exp, err := runtime.Evaluate(x).Do(ctx)
46
if err != nil {
47
return err
48
}
49
if exp != nil {
50
return exp
51
}
52
return nil
53
})); err != nil {
54
utilities.LogErr("Error while running chromedp. Error while evaluating %v", err)
55
utilities.ExitSafely()
56
}
57
utilities.LogInfo("Press ENTER to close browser and continue program")
58
fmt.Scanln()
59
60
}
61
62