-
Notifications
You must be signed in to change notification settings - Fork 0
/
button.html
73 lines (64 loc) · 2.27 KB
/
button.html
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
package main
import (
"fmt"
"html/template"
"os"
"os/exec"
)
func main() {
COUNTRY_CODE := "your_country_code"
PHONE_NO := "your_phone_number"
REDIRECT_URL := "your_redirect_url"
// Generate the HTML code
html := generateHTML(COUNTRY_CODE, PHONE_NO, REDIRECT_URL)
// Create a temporary HTML file
file, err := os.Create("temp.html")
if err != nil {
fmt.Println("Error creating HTML file:", err)
return
}
defer file.Close()
// Write the HTML code to the file
_, err = file.WriteString(html)
if err != nil {
fmt.Println("Error writing to HTML file:", err)
return
}
// Open the HTML file in the default web browser
cmd := exec.Command("xdg-open", "temp.html") // For Linux
err = cmd.Start()
if err != nil {
fmt.Println("Error opening browser:", err)
}
}
func generateHTML(countryCode, phoneNo, redirectURL string) string {
tmpl := `<!DOCTYPE html>
<html>
<head></head>
<body>
<button style="display: flex; align-items: center; justify-content: space-between; padding: 10px 15px; background-color: #02BD7E; font-weight: bold; color: #ffffff; border: none; border-radius: 3px; font-size: inherit; cursor: pointer;"
id="btn_ph_login"
name="btn_ph_login"
type="button"
onclick="window.open('https://auth.phone.email/sign-in?countrycode={{.CountryCode}}&phone_no={{.PhoneNo}}&redirect_url={{.RedirectURL}}', 'peLoginWindow', 'toolbar=0,scrollbars=0,location=0,statusbar=0,menubar=0,resizable=0, width=500, height=500, top=' + (screen.height - 500) / 2 + ', left=' + (screen.width - 500) / 2);">
<svg xmlns="http://www.w3.org/2000/svg" style="margin-right: 5px; fill: #ffffff" height="24" viewBox="0 -960 960 960" width="24">
<path d="M798-120q-125 0-247-54.5T329-329Q229-429 174.5-551T120-798q0-18 12-30t30-12h162q14 0 25 9.5t13 22.5l26 140q2 16-1 27t-11 19l-97 98q20 37 47.5 71.5T387-386q31 31 65 57.5t72 48.5l94-94q9-9 23.5-13.5T670-390l138 28q14 4 23 14.5t9 23.5v162q0 18-12 30t-30 12Z"/>
</svg>
Sign in with Phone Number
</button>
</body>
</html>`
data := struct {
CountryCode string
PhoneNo string
RedirectURL string
}{
CountryCode: countryCode,
PhoneNo: phoneNo,
RedirectURL: redirectURL,
}
t, _ := template.New("buttonTemplate").Parse(tmpl)
var outputHTML string
_ = t.Execute(os.Stdout, data)
return outputHTML
}