Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

gitbook-plugin-adsense

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

gitbook-plugin-adsense - npm Package Compare versions

Comparing version 0.0.7 to 0.0.9

.eslintrc

44

book/plugin.js

@@ -1,11 +0,11 @@

require(["gitbook"], function(gitbook) {
var adInsertPoint = '.page-inner section'
, ad
;
/* eslint-env browser */
gitbook.events.bind("start", function(e, cnf) {
var config = cnf.adsense
, adsByGoogleScript
;
require(['gitbook'], function (gitbook) {
var adInsertPoint = '.page-inner section'
, adPosition = 'bottom'
, ad;
gitbook.events.bind('start', function (e, cnf) {
const config = cnf.adsense;
// Use custom insert point if defined

@@ -16,4 +16,9 @@ if (config.element) {

// Use custom position if defined
if (config.position) {
adPosition = config.position;
}
// Inject script to head.
adsByGoogleScript = document.createElement('script');
var adsByGoogleScript = document.createElement('script');
adsByGoogleScript.src = '//pagead2.googlesyndication.com/pagead/js/adsbygoogle.js';

@@ -27,2 +32,3 @@ adsByGoogleScript.setAttribute('async', true);

ad.className = 'adsbygoogle';
ad.setAttribute('data-ad-client', config.client);

@@ -33,13 +39,25 @@ ad.setAttribute('data-ad-slot', config.slot);

// Add the ad to the DOM
document.querySelector(adInsertPoint).appendChild(ad);
var element = document.querySelector(adInsertPoint);
(adsbygoogle = window.adsbygoogle || []).push({});
if (adPosition === 'top') {
element.insertBefore(ad, element.firstChild);
} else {
element.appendChild(ad);
}
(adsbygoogle = window.adsbygoogle || []).push({}); // eslint-disable-line
});
// I insert ad again when switching pages
gitbook.events.bind("page.change", function() {
gitbook.events.bind('page.change', function () {
if (ad) {
document.querySelector(adInsertPoint).appendChild(ad);
var element = document.querySelector(adInsertPoint);
if (adPosition === 'top') {
element.insertBefore(ad, element.firstChild);
} else {
element.appendChild(ad);
}
}
});
});
module.exports = {
book: {
assets: "./book",
assets: './book',
js: [
"plugin.js"
'plugin.js'
]
}
};

@@ -5,3 +5,3 @@ {

"main": "index.js",
"version": "0.0.7",
"version": "0.0.9",
"engines": {

@@ -42,3 +42,7 @@ "gitbook": ">=2.5.1"

}
},
"devDependencies": {
"eslint": "^3.19.0",
"eslint-config-tidal": "^1.1.3"
}
}

@@ -28,3 +28,4 @@ Google Adsense for GitBook

"format": "auto",
"element": ".page-inner section"
"element": ".page-inner section",
"position": "top"
}

@@ -34,1 +35,2 @@ }

```
Allowed positions are `top` and `bottom` (default)
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc