website/web/static/js/right-click.js
2023-11-28 11:04:57 -08:00

18 lines
564 B
JavaScript

// Right-click button handler, to dissuade downloading.
document.addEventListener('DOMContentLoaded', () => {
const $modal = document.querySelector("#rightclick-modal"),
$button = $modal.querySelector("button"),
cls = 'is-active';
(document.querySelectorAll('img, video') || []).forEach(node => {
node.addEventListener('contextmenu', (e) => {
$modal.classList.add(cls);
e.preventDefault();
});
});
$button.addEventListener('click', () => {
$modal.classList.remove(cls);
});
});