Skip to content

Commit d8fac5c

Browse files
committed
Publish 2025-10-29
1 parent 411ce82 commit d8fac5c

File tree

4 files changed

+103
-32
lines changed

4 files changed

+103
-32
lines changed

plus/activate/index.html

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ <h1 class="title">
2929
Dark Reader Plus Activation<br>
3030
</p>
3131

32-
<form>
32+
<form class="js-form">
3333
<div class="line js-email"></div>
3434
<button class="js-submit">
3535
<span class="button-progress"></span>
@@ -38,7 +38,14 @@ <h1 class="title">
3838
<label class="js-result"></label>
3939
</form>
4040

41-
<section>
41+
<section class="edge-problem js-edge-problem-block" style="display: none;">
42+
<p>
43+
Please use <strong>Edge browser</strong> for the activation.<br>
44+
Open <a class="js-edge-link" href="#">this link</a> in Edge. <button class="copy-button js-copy">Copy</button>
45+
</p>
46+
</section>
47+
48+
<section class="contact-section js-contacts">
4249
<p>
4350
For any questions please <a href="mailto:[email protected]?subject=[Plus]%20Key">contact us</a>.
4451
</p>

plus/activate/script.js

Lines changed: 75 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,76 @@
1-
const elEmail = document.querySelector('.js-email');
2-
const submit = document.querySelector('button');
3-
const label = document.querySelector('label');
4-
5-
const params = new URLSearchParams(location.search);
6-
elEmail.textContent = params.get('email');
7-
8-
submit.addEventListener('click', async (e) => {
9-
e.preventDefault();
10-
label.textContent = '';
11-
const email = params.get('email');
12-
const key = params.get('key');
13-
if (email.includes('@') && key) {
14-
submit.classList.add('button-loading');
15-
setTimeout(() => {
16-
document.addEventListener('__darkreader_activationResult__', (e) => {
17-
const {result} = e.detail;
18-
if (result) {
19-
submit.classList.add('button-success');
20-
submit.textContent = 'Complete';
21-
} else {
22-
submit.classList.add('button-failure');
23-
submit.textContent = 'Error';
24-
}
25-
});
26-
document.dispatchEvent(new CustomEvent('__darkreader_activate__', {detail: {email, key}}));
27-
}, 2000 + Math.round(500 * Math.random()));
1+
function run() {
2+
const elEmail = document.querySelector('.js-email');
3+
const submit = document.querySelector('button');
4+
const label = document.querySelector('label');
5+
6+
if (!navigator.userAgent.includes('Edg')) {
7+
/** @type {HTMLElement} */
8+
const edgeProblemBlock = document.querySelector('.js-edge-problem-block');
9+
edgeProblemBlock.style.display = '';
10+
11+
/** @type {HTMLAnchorElement} */
12+
const edgeLink = document.querySelector('.js-edge-link');
13+
edgeLink.href = location.href;
14+
15+
/** @type {HTMLElement} */
16+
const form = document.querySelector('.js-form');
17+
form.style.display = 'none';
18+
19+
/** @type {HTMLElement} */
20+
const contacts = document.querySelector('.js-contacts');
21+
contacts.style.display = 'none';
22+
23+
/** @type {HTMLElement} */
24+
const footer = document.querySelector('footer');
25+
footer.style.backgroundColor = 'inherit';
26+
27+
/** @type {HTMLButtonElement} */
28+
const copyButton = document.querySelector('.js-copy');
29+
copyButton.addEventListener('click', () => {
30+
const input = document.createElement('input');
31+
input.value = location.href;
32+
document.body.append(input);
33+
input.select();
34+
document.execCommand('copy');
35+
input.remove();
36+
37+
copyButton.textContent = 'Copied';
38+
copyButton.classList.add('copy-button--copied');
39+
});
40+
footer.style.backgroundColor = 'inherit';
41+
return;
42+
}
43+
44+
const hash = location.hash;
45+
let email = '';
46+
let key = '';
47+
if (hash.startsWith('#v1=')) {
48+
[email, key] = atob(hash.slice(4)).split('::');
49+
elEmail.textContent = email;
50+
location.hash = '';
51+
history.pushState('', document.title, location.pathname);
2852
}
29-
});
53+
54+
submit.addEventListener('click', async (e) => {
55+
e.preventDefault();
56+
label.textContent = '';
57+
if (email.includes('@') && key) {
58+
submit.classList.add('button-loading');
59+
setTimeout(() => {
60+
document.addEventListener('__darkreader_activationResult__', (e) => {
61+
const {result} = e.detail;
62+
if (result) {
63+
submit.classList.add('button-success');
64+
submit.textContent = 'Complete';
65+
} else {
66+
submit.classList.add('button-failure');
67+
submit.textContent = 'Error';
68+
}
69+
});
70+
document.dispatchEvent(new CustomEvent('__darkreader_activate__', {detail: {email, key}}));
71+
}, 2000 + Math.round(500 * Math.random()));
72+
}
73+
});
74+
}
75+
76+
run();

plus/activate/style.css

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,20 @@ label {
7575
.button-failure {
7676
background-color: #803449;
7777
}
78+
79+
.copy-button {
80+
height: 2em;
81+
min-width: 5em;
82+
width: auto;
83+
84+
&::before {
85+
content: '⎘ ';
86+
font-size: 125%;
87+
}
88+
89+
&.copy-button--copied {
90+
&::before {
91+
display: none;
92+
}
93+
}
94+
}

plus/restore/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,15 +29,15 @@ <h1 class="title">
2929
Restore activation key<br>
3030
</p>
3131

32-
<form>
32+
<form class="js-form">
3333
<input type="email" class="js-email" placeholder="[email protected]">
3434
<button class="js-submit">
3535
Restore
3636
</button>
3737
<label class="js-result"></label>
3838
</form>
3939

40-
<section>
40+
<section class="contact-section">
4141
<p>
4242
For any questions please <a href="mailto:[email protected]?subject=[Plus]%20Key">contact us</a>.
4343
</p>

0 commit comments

Comments
 (0)