skip to Main Content

I have some HTML template, that has developed by HTML CSS Javascript and Jquery. I want to add a copyright text to all of my theme. But there’s a fact. If anybody remove the code or text, the theme will be automatically redirect to an URL. I saw this system in Blogger/Blogspot templates. They use a copyright text in all theme footer (Paid and Free). If anybody remove the code/make it invisible (visibility:hidden) or (display:none), the theme automatically redirect. They did it with just jquery and javascript.

How I can do it..?

2

Answers


  1. This will check for any changes within the footer. Try running it, and use your browser’s editor to either delete or edit the stuff inside <footer> OR you can also try to change the CSS on <div class="copyright">. The setInterval() timer is set to execute every 10 seconds.

    let footer = document.querySelector('footer');
    let copyright = document.getElementById('copyright');
    let originalFooter = footer.innerHTML;
    let originalCopyrightStyle = String.toString(getComputedStyle(copyright));
    
    function checkFooter() {
      let currentFooter = footer.innerHTML;
      let currentCopyrightStyle = String.toString(getComputedStyle(copyright));
    
      if ((currentFooter !== originalFooter) ||
        (currentCopyrightStyle !== originalCopyrightStyle)) {
        location.href = `https://www.youtube.com/`;
      }
    }
    
    setInterval(() => {
      checkFooter()
    }, 10000);
    <footer>
      <div id="copyright">
        This is my copyright, do not change it!
      </div>
    </footer>

    W3Schools:

    <!DOCTYPE html>
    <html lang="en">
    
    <head>
      <link rel="stylesheet" href="/style.css">
      <title>Document</title>
    </head>
    
    <body>
      <footer>
        <div id="copyright">
          This is my copyright, do not change it!
        </div>
      </footer>
    </body>
    
    <script>
      let footer = document.querySelector('footer');
      let copyright = document.getElementById('copyright');
      let originalFooter = footer.innerHTML;
      let originalCopyrightStyle = String.toString(getComputedStyle(copyright));
    
      function checkFooter() {
        let currentFooter = footer.innerHTML;
        let currentCopyrightStyle = String.toString(getComputedStyle(copyright));
    
        if ((currentFooter !== originalFooter) ||
          (currentCopyrightStyle !== originalCopyrightStyle)) {
          location.href = `https://www.youtube.com/`;
        }
      }
    
      setInterval(() => {
        checkFooter()
        console.log('check');
      }, 1000);
    </script>
    
    </html>
    Login or Signup to reply.
  2. Use an IntersectionObserver and check the element’s intersectionRatio to determine whether it’s been removed/hidden:

    btn.addEventListener('click', () => copyright.remove())
    btn1.addEventListener('click', () => copyright.style.display = "none")
    
    const observer = new IntersectionObserver((elems, obs) => {
      if(elems[0].intersectionRatio == 0) {
        console.log('elem hidden: redirect')
      }
    })
    observer.observe(copyright)
    <footer>
      <span id='copyright'> Copyright 2023 - Theme Title </span> | All Rights Reserved.
    </footer>
    
    <button id="btn">Remove copyright</button>
    <button id="btn1">Hide copyright</button>
    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search