Files
nearxos c91cf6dd05 Update first-boot configuration and scripts for enhanced kiosk functionality</message>
<message>Modify the first-boot configuration to include the gir1.2-gtklayershell-0.1 package for improved GTK layer shell support. Update the first-boot script to enhance the portal status reporting with connection timeouts. Additionally, implement a restart mechanism for the kanshi service in rotation scripts to ensure immediate application of configuration changes. Introduce a Chromium kiosk extension to disable text selection, improving user experience in kiosk mode. These changes streamline the setup process and enhance the overall functionality of the kiosk environment.
2026-02-23 18:07:14 +02:00

38 lines
1.5 KiB
JavaScript

// Disable text selection: inject CSS and clear any selection (including from scrollbar).
(function() {
var style = document.createElement('style');
style.id = 'kiosk-no-select';
style.textContent = [
'html, body, body *, body *::before, body *::after {',
' user-select: none !important; -webkit-user-select: none !important;',
' -moz-user-select: none !important; -ms-user-select: none !important;',
'}',
'input:focus, textarea:focus, [contenteditable="true"]:focus {',
' user-select: text !important; -webkit-user-select: text !important;',
'}'
].join('');
(document.head || document.documentElement).appendChild(style);
function allowSelect(el) {
return el && (el.tagName === 'INPUT' || el.tagName === 'TEXTAREA' || el.isContentEditable);
}
function preventSelect(e) {
if (allowSelect(e.target)) return;
e.preventDefault();
}
function clearSelection() {
var sel = document.getSelection();
if (!sel || sel.rangeCount === 0) return;
var node = sel.anchorNode;
var el = node && (node.nodeType === 1 ? node : node.parentElement);
if (el && !allowSelect(el)) sel.removeAllRanges();
}
document.addEventListener('selectstart', preventSelect, true);
document.addEventListener('contextmenu', preventSelect, true);
document.addEventListener('selectionchange', clearSelection, true);
document.addEventListener('mousedown', function(e) { if (!allowSelect(e.target)) clearSelection(); }, true);
})();