Changeset 366c13c in Klonkt


Ignore:
Timestamp:
06/30/2026 11:54:52 PM (2 months ago)
Author:
Robin Genis <roboburr@…>
Branches:
main
Children:
2f50c53
Parents:
b31c119
Message:

feat(media): suppress right-click menu on covers/images/videos (friction)

Delegated contextmenu handler that preventDefaults on visual media so the
art isn't one right-click from Save as. Friction only — public files stay
reachable via devtools/network; middle/Ctrl-click (open in new tab) still
works. Text/links/UI keep their normal right-click menu.

  • src/views/shell.ejs — document-level contextmenu guard on img/video + cover containers

Co-Authored-By: Claude <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • src/views/shell.ejs

    rb31c119 r366c13c  
    772772})();
    773773
     774// Light anti-grab friction: suppress the right-click menu on visual media (covers, images,
     775// videos) so the art isn't one right-click away from "Save as". Friction, NOT protection —
     776// the files are public and reachable via devtools/network. Middle/Ctrl-click (open in new
     777// tab) still works; only the context menu is blocked. Delegated → covers htmx-swapped content.
     778(function () {
     779  if (window.__noMediaCtxWired) return; window.__noMediaCtxWired = true;
     780  document.addEventListener('contextmenu', function (e) {
     781    if (e.target.closest('img, video, .grid-tile, .post-list-cover, .post-cover, .tl-media-img')) {
     782      e.preventDefault();
     783    }
     784  });
     785})();
     786
    774787// iOS animated-cover → video: an animated WebP is janky on iOS Safari, so on iOS we swap any
    775788// <img data-ios-mp4="…"> for a muted, looping, inline <video> (the WebP's matching MP4). Every
Note: See TracChangeset for help on using the changeset viewer.