-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.html
More file actions
118 lines (106 loc) · 3.23 KB
/
index.html
File metadata and controls
118 lines (106 loc) · 3.23 KB
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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
<!DOCTYPE html>
<!-- https://chatgpt.com/c/68a4aa9a-a4c4-8331-98c9-c7719bc95275 -->
<html>
<head>
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<style>
body {
font-size: 16px;
line-height: 1.5;
font-family: Arial, sans-serif;
margin: 20px;
}
a {
font-size: 18px;
display: block;
padding: 10px;
margin: 5px 0;
text-decoration: none;
color: #0066cc;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #f9f9f9;
}
a:hover {
background-color: #e9e9e9;
}
button {
font-size: 18px;
padding: 10px;
margin: 50px 0;
border: 1px solid #ddd;
border-radius: 5px;
background-color: #0066cc;
color: #fff;
cursor: pointer;
}
button:hover {
background-color: #004c99;
}
input[type="text"] {
font-size: 16px;
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ccc;
border-radius: 5px;
}
</style>
</head>
<script>
window.addEventListener('DOMContentLoaded', () => {
const logArea = document.getElementById('status');
const log = (msg) => {
console.log(msg);
const entry = document.createElement('div');
entry.textContent = `${new Date().toISOString()} ${msg}`;
logArea.prepend(entry);
};
const openButton = document.getElementById('open-from-clipboard');
if (!openButton) {
return;
}
openButton.addEventListener('click', async () => {
log('Button tapped');
if (!navigator.clipboard?.readText) {
log('Clipboard API unavailable');
return;
}
try {
const text = (await navigator.clipboard.readText()).trim();
log(`Clipboard contents: "${text}"`);
if (!text) {
log('Clipboard empty');
return;
}
const parsed = new URL(text);
log(`Parsed host: ${parsed.host}`);
if (parsed.host !== '0j5wk.app.link') {
log('Not a Branch link, aborting');
return;
}
const intent = `intent://${parsed.host}${parsed.pathname}${parsed.search}` +
'#Intent;scheme=https;package=com.howwellapp.howwellapp.dev;' +
`S.browser_fallback_url=${encodeURIComponent(parsed.href)};end`;
log('Launching intent: ${intent}');
window.location.replace(intent);
} catch (err) {
log(`Clipboard read failed: ${err.message}`);
}
});
});
</script>
<body>
<h3>Prod</h3>
<a href="https://f2v4n.app.link/GgdubEEuMWb">How Well App</a>
<h3>Dev</h3>
<a href="https://0j5wk.app.link/Z6f0nDsPwXb">How Well App</a>
<button id="open-from-clipboard">Open link from clipboard</button>
<p id="status"></p>
<div id="manual-fallback" hidden>
<label for="manual-link">Paste Branch dev link:</label>
<input id="manual-link" type="text" autocomplete="off" spellcheck="false" placeholder="https://0j5wk.app.link/...">
<button id="open-manual">Open pasted link</button>
</div>
</body>
</html>