ctreffe / alfred

Alfred - A library for rapid experiment development
MIT License
10 stars 1 forks source link

Add content protection element to alfred #202

Open ctreffe opened 2 years ago

ctreffe commented 2 years ago

In some cases, experimenters might want to protect the contents of an experiment from being copied or saved by participants. One example of this is an agreement we have to make with Hogrefe when implementing one of their questionnaires in alfred. We are only allowed to use their instruments, when we provide a certain level of protection against participants saving any questionnaire content.

So far, we have provided three layers of basic protection:

myPage += al.Style('@media print{* { display: none;}}')  # Disable Printing

myPage += al.JavaScript('document.onselectstart=new Function("return false");function ds(e){return false;}function ra(){return true;}document.onmousedown=ds;document.onclick=ra;')  # Disable text selection & copying

myPage += al.JavaScript('document.addEventListener("contextmenu", event => event.preventDefault());$(document).bind("keydown", function(e) {if(e.ctrlKey && (e.which == 83) || (e.which == 85)) {e.preventDefault();alert("Nicht erlaubt");return false;}});')  # Disable context menu and disable shortcut to show source code

While this is far from perfect, each component offers at least a hurdle for participants who want to copy or save the contents of an alfred page. At least, Hogrefe has allowed us to use their questionnaires based on these elements.

Maybe we can improve and build on the ideas shown above and integrate them into a content protection element, not unlike our ExitEnabler class?

ctreffe commented 2 years ago

Let's call this element ContentProtector(), similar to ExitEnabler().