-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathios-experiment.html
112 lines (96 loc) · 4.35 KB
/
ios-experiment.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
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
---
---
<!doctype html>
<html lang=en>
<head>
{% comment %} Only include GA snippet in production and if values in _config.yml match the actual site. {% endcomment %}
{% if jekyll.environment != 'development' and site.github.repository_nwo == site.ga.nwo %}
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src="https://www.googletagmanager.com/gtag/js?id={{ site.ga.tid }}"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', '{{ site.ga.tid }}');
</script>
{% endif %}
<meta charset=utf-8>
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no">
<title>WhatsApp Spoilers</title>
<meta name="description" content="Hide content behind a "Read more" button in a WhatsApp message.">
<meta property="og:title" content="WhatsApp Spoilers"/>
<meta property="og:description" content="Hide content behind a "Read more" button in a WhatsApp message.">
<meta property="og:image" content="https://yi-jiayu.github.io/whatsapp-spoilers/spoiler.png">
<link rel="icon" type="image/png" href="favicon-32x32.png" sizes="32x32">
<link rel="icon" type="image/png" href="favicon-16x16.png" sizes="16x16">
<!-- Bootstrap CSS -->
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.0.0-beta.2/css/bootstrap.min.css"
integrity="sha384-PsH8R72JQ3SOdhVi3uxftmaW6Vc51MKb0q5P2rRUpPvrszuE4W1povHYgTpBfshb" crossorigin="anonymous">
</head>
<body>
<div class="container">
<h1 class="mt-3">WhatsApp Spoilers</h1>
<h3><small class="text-muted">Hide content behind a "Read more" button in a WhatsApp message.</small></h3>
<img src="spoiler.png" class="img-fluid my-3">
<form>
<div class="form-group">
<label for="warning">Warning: </label>
<input type="text" class="form-control" id="warning" value="[SPOILER]">
</div>
<div class="form-group">
<label for="padding">Number of characters to pad with</label>
<input type="number" class="form-control" id="padding" value="10000">
</div>
<div class="form-group">
<label for="padding">Code point for padding character</label>
<input type="text" class="form-control" id="pad-char" value="0x200B" required>
<small class="form-text text-muted">Eg. <code>0x200B</code> for zero-width space. See <a
href="http://jkorpela.fi/chars/spaces.html">http://jkorpela.fi/chars/spaces.html</a> for examples of
Unicode whitespace characters.</small>
</div>
<div class="form-group">
<label for="content">Content: </label>
<textarea id="content" class="form-control mb-2"></textarea>
<button class="btn btn-primary" type="submit">Submit</button>
</div>
</form>
<div class="form-group">
<label for="message">Message (copy this): </label>
<textarea id="message" class="form-control mb-2" readonly></textarea>
<button class="btn btn-primary" id="copy" onclick=copySpoilerMessage()>Copy to clipboard</button>
</div>
<div class="text-right"><a href="https://github.com/yi-jiayu/whatsapp-spoilers">GitHub</a></div>
</div>
<script>
"use strict";
function createSpoilerMessage() {
var warning = document.getElementById('warning').value;
var content = document.getElementById('content').value;
var padding = Number(document.getElementById('padding').value);
var padChar = String.fromCharCode(document.getElementById('pad-char').value);
var message = warning + ' ' + padChar.repeat(padding) + content;
document.getElementById('message').value = message;
document.getElementById('copy').textContent = "Copy to clipboard (".concat(message.length, " chars)");
}
function copySpoilerMessage() {
document.getElementById('message').select();
document.execCommand('copy');
}
document.querySelector('form').addEventListener('submit', function (e) {
createSpoilerMessage();
e.preventDefault();
});
document.getElementById('copy').addEventListener('click', function () {
copySpoilerMessage();
});
var padCharInput = document.getElementById('pad-char');
padCharInput.addEventListener('input', function (e) {
if (isNaN(padCharInput.value)) {
padCharInput.setCustomValidity('Not a valid number!');
} else {
padCharInput.setCustomValidity('');
}
});
</script>
</body>
</html>