admin:online-platform-cms:3rd-party-scripts:content-hidder-script

USAGE

SUB_DOMAIN

Add subdomain name so script starts only on specific subdomain. If you want script turned off, leave it `undefined` or just `""`. Make sure there is no space between quotes, otherwise script will work no matter subdomain name.

HIDDEN_CONTENT

Here you can add specific website parts to be hidden. Class / ID has to be unique, otherwise it will hide all content that match written class/id. 

REDIRECT_TO_MAIN_PAGE_AFTER_REGISTRATION

Set this to "true" if you want that after complete registration user will be redirected to your main page and hider script disabled. There is one downside with it - after redirect user will have to re-login to his account.

REDIRECT_TO_MAIN_PAGE_AFTER_LOGIN

Set this to "true" if you want that after login user will be redirected to your main page and hider script disabled. There is one downside with it - after redirect user will have to re-login to his account.

HIDDEN_GAMES

Here you can add games that you want to be hidden in header. If you pass `'undefined'` to hidden games array it will hide all expandable menus. It is important to know that if you want the best experience with the script you should add `'.left-menu.side-menu-toggle-wrapper'` to HIDDEN_CONTENT array, to hide mobile side menu, since this script can't handle it.
Available games :
  1. dogs
  2. prematch
  3. betgames-iframe
  4. betgames-rng-wheel
  5. live
  6. lottery
  7. horses
  8. keno
  9. roulette
  10. greyhounds
  11. pragmatic
  12. agtslots
  13. roulette-live
  14. dogs
  15. betgames-rng-wheel
  16. undefined (hides every expandable header menu)

HIDDER SCRIPT

const SUB_DOMAIN = '';
const REDIRECT_TO_MAIN_PAGE_AFTER_REGISTRATION = true;
const REDIRECT_TO_MAIN_PAGE_AFTER_LOGIN = true;
const HIDDEN_CONTENT = [
  '.banner-row.center',
  '.banner-row.right',
  '.header-cms-links-row',
  '#cms-footer-content-holder',
  '.left-menu.side-menu-toggle-wrapper'
];
const HIDDEN_GAMES = [
  'horses',
  'lottery',
  'roulette',
  'horses',
  'keno',
  'betgames-iframe',
  'greyhounds',
  'undefined',
  'pragmatic',
  'agtslots',
  'roulette-live',
  'dogs',
  'evolution',
  'betgames-rng-wheel'
];

const getElement = async selector => {
  while (document.querySelectorAll(selector).length === 0) {
    await new Promise(resolve => requestAnimationFrame(resolve))
  }

  return document.querySelectorAll(selector);
}

function hidePageContent() {
  HIDDEN_CONTENT.forEach(element => {
    getElement(element).then((selector) => {
      selector.forEach((elem) => {
        elem.remove();
      })
    })
  });
  HIDDEN_GAMES.forEach(game => {
    getElement('.website-game-' + game).then((selector) => {
      selector.forEach((elem) => {
        elem.remove();
      })
    })
  })
}

function addMeta() {
  const meta = document.createElement("meta");
  meta.name = "robots";
  meta.content = "noindex";
  document.head.appendChild(meta);
}

function getParsedSubDomain() {
  const host = window.location.host;
  return host.split('.')[1] ? host.split('.')[0] : ' ';
}

function redirectToMainPage() {
  const host = window.location.origin;
  const newURL = host.replace(SUB_DOMAIN + '.', '');
  window.location.assign(newURL);
}

function startHider() {
  const parsedSubDomain = getParsedSubDomain();
  if (parsedSubDomain !== SUB_DOMAIN) return;

  addMeta();
  hidePageContent();
  window.addEventListener('resize', hidePageContent);
  document.addEventListener('routeChange', hidePageContent);
  document.addEventListener('cmsPageLoaded', hidePageContent);
  if (REDIRECT_TO_MAIN_PAGE_AFTER_REGISTRATION) {
    document.body.addEventListener('userRegisterComplete', redirectToMainPage);
  }
  if (REDIRECT_TO_MAIN_PAGE_AFTER_LOGIN) {
    document.body.addEventListener('userLogIn', redirectToMainPage);
  }
}

startHider();
  • admin/online-platform-cms/3rd-party-scripts/content-hidder-script.txt
  • Last modified: 2023/04/12 12:14
  • by ignas-bogusis