Im trying to disable access to Inspect Element to prevent videos from being downloaded and etc…
import streamlit.components.v1 as components
import streamlit as st
my_js = """
document.addEventListener('contextmenu',(e)=>{
e.preventDefault();
}
);
document.onkeydown = function(e) {
if(event.keyCode == 123) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'I'.charCodeAt(0)) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'C'.charCodeAt(0)) {
return false;
}
if(e.ctrlKey && e.shiftKey && e.keyCode == 'J'.charCodeAt(0)) {
return false;
}
if(e.ctrlKey && e.keyCode == 'U'.charCodeAt(0)) {
return false;
}
}
"""
# Wrapt the javascript as html code
my_html = f"<script>{my_js}</script>"
st.title("Example Text")
components.html(my_html)
This is the code I’m using. but it only works for a limited area.
Really appreciate a help