forked from inulute/perplexity-ai-app
-
Notifications
You must be signed in to change notification settings - Fork 0
/
url-open.html
80 lines (74 loc) · 2.72 KB
/
url-open.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
74
75
76
77
78
79
80
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link href='https://fonts.googleapis.com/css?family=Varela Round' rel='stylesheet'>
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/all.min.css">
<link rel="stylesheet" href="./external.css">
<title>Login</title>
<style>
body {
user-select: none; /* Prevent text selection on the whole body */
}
</style>
</head>
<body>
<div id="content">
<div id="logo2"></div>
<h3>A sign-in link has been sent to your email address</h3>
<input type="text" id="url-input" placeholder="Enter URL" onkeydown="handleCtrlA(event)">
<div class="button-container">
<button class="button" onclick="pasteAndCheck()"><i class="fas fa-paste"></i> Paste</button>
<button class="button" onclick="loginAndLoad()"><i class="fas fa-sign-in-alt"></i> Login</button>
</div>
<div class="instructions">
<p>- To sign in, go to your email.</p>
<p>- Open the Perplexity login email.</p>
<p>- Right-click on the "Sign In" button.</p>
<p>- Copy the link and paste it in the text box above.</p>
</div>
<p id="warning"></p>
</div>
<script>
function focusUrlInput() {
var urlInput = document.getElementById("url-input");
urlInput.focus();
}
function handleCtrlA(event) {
if (event.ctrlKey && event.key === 'a') {
event.preventDefault(); // Prevent default Ctrl+A behavior
var urlInput = document.getElementById("url-input");
urlInput.setSelectionRange(0, urlInput.value.length); // Select the text within the input box
}
}
function pasteAndCheck() {
var urlInput = document.getElementById("url-input");
var warning = document.getElementById("warning");
warning.textContent = "";
navigator.clipboard.readText()
.then((pastedUrl) => {
if (pastedUrl.trim() !== "") {
urlInput.value = pastedUrl;
}
})
.catch((err) => {
console.error('Failed to read clipboard contents: ', err);
});
}
function loginAndLoad() {
var urlInput = document.getElementById("url-input");
var warning = document.getElementById("warning");
warning.textContent = "";
var expectedPattern = "https://www.perplexity.ai/api/auth/callback/email?callbackUrl";
if (!urlInput.value.startsWith(expectedPattern)) {
warning.textContent = "Warning: The URL doesn't start with the expected pattern.";
return;
}
console.log("Logging in or loading URL:", urlInput.value);
// Redirect to the specified URL
window.location.href = urlInput.value;
}
</script>
</body>
</html>