Skip to content
This repository has been archived by the owner on Jul 22, 2019. It is now read-only.

ckomop0x-archived-projects/adblock

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

23 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

rambler-adblock

NPM version

Usage

Технические требования подключения контентных площадок к системе AdBlock.Rambler

Node.js

To install:

npm i rambler-adblock --save

To use:

'use strict';

import * as adblock from 'rambler-adblock';

const DEBUG = document.body.getAttribute('data-prod'); // true||false
const PLATE_TEXT = 'Воспользуйтесь опцией отключения рекламы. Если у вас она уже активирована, то нажмите сюда.';
const PLATE_URL = DEBUG ?
  `https://noadblock.rambler.ru/verify?content=${location.hostname}` :
  `https://adblock.rambler.ru/verify?content=${location.hostname}`;

adblock.init(DEBUG)
  .then(start)
  .catch(start);

function start(isAdblock) {
  if (isAdblock.ad) {
    console.log('Показать рекламу');
  }
  if (isAdblock.plate) {
    showPlate();
  }
}

function showPlate() {
  var plate = document.createElement('div');
  plate.className = 'adblock-plate';
  plate.innerHTML = `<a href="${PLATE_URL}" class="adblock-plate__link">${PLATE_TEXT}</a><span class="adblock-plate__close"></span>`;
  document.body
    .insertBefore(plate, document.body.firstChild)
    .querySelector('.adblock-plate__close')
    .addEventListener('click', function(e) {
      adblock.delaySubscribe();
      this.parentNode.parentNode.removeChild(plate);
      e.preventDefault();
    });
}

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%