How to disable right click/save-photo but enable it on access specific url

Description

+ Disable Right Click/save photo

+ Enable right click when users access specific url like this: yoursite?rel=false

#1. First, use this code to Code Injection to disable right click

<script>
document.addEventListener('contextmenu', event => event.preventDefault());

document.addEventListener('selectstart', event => event.preventDefault());

document.addEventListener('dragstart', event => event.preventDefault());

document.addEventListener('keydown', function(event) {
  if (event.ctrlKey && (event.keyCode === 83 || event.keyCode === 85 || event.keyCode === 73)) {
    event.preventDefault();
  }
  if (event.key === 'F12' || (event.ctrlKey && event.shiftKey && event.keyCode === 73)) {
    event.preventDefault();
  }
});

document.querySelectorAll('img').forEach(img => {
  img.setAttribute('draggable', 'false');
  img.style.pointerEvents = 'none';
  img.oncontextmenu = () => false;
});

const observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    if (mutation.type === 'childList') {
      mutation.addedNodes.forEach(function(node) {
        if (node.nodeType === 1) {
          const images = node.tagName === 'IMG' ? [node] : node.querySelectorAll('img');
          images.forEach(img => {
            img.setAttribute('draggable', 'false');
            img.style.pointerEvents = 'none';
            img.oncontextmenu = () => false;
          });
        }
      });
    }
  });
});

observer.observe(document.body, { childList: true, subtree: true });

document.onselectstart = () => false;
document.ondragstart = () => false;
</script>

Explain

+ Code will disable Right Click, disable F12, disable Ctrl U, disable Ctrl S, disable Ctrl I, disable drag image to download it

#2. Next, to disable #1 code when users access any url with ?rel=false, you can use this new code. You need to add it to Page Header Injection. Remember to remove #1 code

<script>
if (!window.location.search.includes('rel=false')) {

document.addEventListener('contextmenu', event => event.preventDefault());

document.addEventListener('selectstart', event => event.preventDefault());

document.addEventListener('dragstart', event => event.preventDefault());

document.addEventListener('keydown', function(event) {
  if (event.ctrlKey && (event.keyCode === 83 || event.keyCode === 85 || event.keyCode === 73)) {
    event.preventDefault();
  }
  if (event.key === 'F12' || (event.ctrlKey && event.shiftKey && event.keyCode === 73)) {
    event.preventDefault();
  }
});

document.querySelectorAll('img').forEach(img => {
  img.setAttribute('draggable', 'false');
  img.style.pointerEvents = 'none';
  img.oncontextmenu = () => false;
});

const observer = new MutationObserver(function(mutations) {
  mutations.forEach(function(mutation) {
    if (mutation.type === 'childList') {
      mutation.addedNodes.forEach(function(node) {
        if (node.nodeType === 1) {
          const images = node.tagName === 'IMG' ? [node] : node.querySelectorAll('img');
          images.forEach(img => {
            img.setAttribute('draggable', 'false');
            img.style.pointerEvents = 'none';
            img.oncontextmenu = () => false;
          });
        }
      });
    }
  });
});

observer.observe(document.body, { childList: true, subtree: true });

document.onselectstart = () => false;
document.ondragstart = () => false;

}
</script>