Skip to content

Commit

Permalink
Lint-only changes
Browse files Browse the repository at this point in the history
  • Loading branch information
nicjansma committed Sep 17, 2015
1 parent 7191835 commit 3081d93
Show file tree
Hide file tree
Showing 8 changed files with 224 additions and 226 deletions.
8 changes: 5 additions & 3 deletions .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -26,13 +26,15 @@
"no-lonely-if": 2,
"no-multiple-empty-lines": [1, {"max": 1}],
"no-nested-ternary": 2,
"space-after-function-name": [2, "never"],
"space-before-function-paren": [2, "never"],
"space-after-keywords": 1,
"space-before-blocks": 1,
"space-in-brackets": 1,
"object-curly-spacing": 1,
"computed-property-spacing": 1,
"array-bracket-spacing": 1,
"space-in-parens": 1,
"space-unary-ops": 1,
"spaced-line-comment": 1,
"spaced-comment": 1,
"max-len": [1, 120, 4],

//
Expand Down
4 changes: 2 additions & 2 deletions Gruntfile.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*eslint-env node*/
/*eslint-disable camelcase*/
/* eslint-env node */
/* eslint-disable camelcase */
module.exports = function(grunt) {
"use strict";

Expand Down
4 changes: 2 additions & 2 deletions dist/adblock-detector.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/adblock-detector.min.js.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

14 changes: 5 additions & 9 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,18 @@
"bugs": {
"url": "http://github.com/nicjansma/adblock-detector.js/issues"
},
"licenses": [
{
"type": "MIT",
"url": "http://github.com/nicjansma/adblock-detector.js/raw/master/LICENSE"
}
],
"license": "MIT",
"scripts": {
"test": "grunt travis --verbose"
},
"devDependencies": {
"grunt": ">= 0.4.0",
"grunt": ">= 0.4.5",
"grunt-contrib-clean": "^0.6.0",
"grunt-contrib-connect": "^0.9.0",
"grunt-contrib-uglify": ">0.0.0",
"grunt-mocha-phantomjs": "^0.6.1",
"grunt-mocha-phantomjs": "^0.6.2",
"gruntify-eslint": ">0.0.0",
"mocha-phantomjs": "^3.5.3"
"mocha-phantomjs": "^3.6.0",
"phantomjs": "~1.9.1"
}
}
302 changes: 151 additions & 151 deletions src/adblock-detector.js
Original file line number Diff line number Diff line change
@@ -1,151 +1,151 @@
/*eslint-env jquery,browser,amd*/
//
// adblock-detector.js
//
// Detects ad-blockers
//
// Copyright 2014 Nic Jansma
// http://nicj.net
//
// https://github.com/nicjansma/adblock-detector.js
//
// Licensed under the MIT license
//
(function() {
"use strict";

var AdblockDetector = {};

// save old AdblockDetector object for noConflict()
var root;
var previousObj;
if (typeof window !== "undefined") {
root = window;
previousObj = root.AdblockDetector;
}

//
// Functions
//
/**
* Changes the value of AdblockDetector back to its original value, returning
* a reference to the AdblockDetector object.
*
* @returns {AdblockDetector} This AdblockDetector
*/
AdblockDetector.noConflict = function() {
root.AdblockDetector = previousObj;
return AdblockDetector;
};

/**
* Determines if the target element (ad container) had its ads blocked.
*
* @param {Element} element Ad container element
*
* @returns {boolean} True if an ad-blocker was detected
*/
AdblockDetector.hasAdsBlocked = function(element) {
var $element = $(element);

// look for child IFRAMEs
var iframes = $element.find("iframe");

if (iframes.length > 0) {
try {
// FireFox
var adWindow = iframes[0].contentWindow;
if (adWindow && adWindow.document) {
var adDoc = adWindow.document;
var adDocFrames = $(adDoc).find("iframe");

if (adDocFrames.length > 0) {
if (adDocFrames[0].className !== "") {
// AdBlock Plus
return true;
} else if (!adDocFrames.is(":visible")) {
// Remove It Permanently (Firefox)
return true;
}
}
}
} catch (e) {
// Likely a cross-origin access exception. If thrown, it means
// the IFRAME was loaded from another origin, so it likely loaded
// a real ad.
return false;
}
} else {
// Google Chrome and Internet Explorer
return true;
}

return false;
};

/**
* @typedef AdblockDetector~detect
* @property {number} [timeout=3000] Timeout before document is checked
* @property {string} [selector=.ad-container] jQuery selector of ad containers
* @property {function} [blocked=null] Function that fires when a container"s ads have been blocked
* @property {function} [complete=null] Function that fires after all ads have been checked for being blocked
*/

/**
* Waits for document.ready and then looks for ads matching a selector to see if any ads were blocked.
*
* @param {AdblockDetector~detect} opts Options
*/
AdblockDetector.detect = function(opts) {
var defaults = {
timeout: 3000,
selector: ".ad-container",
blocked: null,
complete: null
};

var options = $.extend({}, defaults, opts);

$(function() {
// wait a few ms for AdBlocker to kick in
setTimeout(function() {
var adsBlockedCount = 0;
var adCount = 0;

// find all matching ad containers
$(options.selector).each(function(i, element) {
adCount++;

if (AdblockDetector.hasAdsBlocked(element)) {
adsBlockedCount++;

if (options.blocked) {
options.blocked(element);
}
}
});

if (options.complete) {
options.complete(adCount, adsBlockedCount);
}
}, options.timeout);
});
};

//
// Export to the appropriate location
//
if (typeof define === "function" && define.amd) {
//
// AMD / RequireJS
//
define([], function () {
return AdblockDetector;
});
} else if (typeof root !== "undefined") {
//
// Browser Global
//
root.AdblockDetector = AdblockDetector;
}
}(typeof window !== "undefined" ? window : undefined));
/* eslint-env jquery,browser,amd */
//
// adblock-detector.js
//
// Detects ad-blockers
//
// Copyright 2014 Nic Jansma
// http://nicj.net
//
// https://github.com/nicjansma/adblock-detector.js
//
// Licensed under the MIT license
//
(function() {
"use strict";

var AdblockDetector = {};

// save old AdblockDetector object for noConflict()
var root;
var previousObj;
if (typeof window !== "undefined") {
root = window;
previousObj = root.AdblockDetector;
}

//
// Functions
//
/**
* Changes the value of AdblockDetector back to its original value, returning
* a reference to the AdblockDetector object.
*
* @returns {AdblockDetector} This AdblockDetector
*/
AdblockDetector.noConflict = function() {
root.AdblockDetector = previousObj;
return AdblockDetector;
};

/**
* Determines if the target element (ad container) had its ads blocked.
*
* @param {Element} element Ad container element
*
* @returns {boolean} True if an ad-blocker was detected
*/
AdblockDetector.hasAdsBlocked = function(element) {
var $element = $(element);

// look for child IFRAMEs
var iframes = $element.find("iframe");

if (iframes.length > 0) {
try {
// FireFox
var adWindow = iframes[0].contentWindow;
if (adWindow && adWindow.document) {
var adDoc = adWindow.document;
var adDocFrames = $(adDoc).find("iframe");

if (adDocFrames.length > 0) {
if (adDocFrames[0].className !== "") {
// AdBlock Plus
return true;
} else if (!adDocFrames.is(":visible")) {
// Remove It Permanently (Firefox)
return true;
}
}
}
} catch (e) {
// Likely a cross-origin access exception. If thrown, it means
// the IFRAME was loaded from another origin, so it likely loaded
// a real ad.
return false;
}
} else {
// Google Chrome and Internet Explorer
return true;
}

return false;
};

/**
* @typedef AdblockDetector~detect
* @property {number} [timeout=3000] Timeout before document is checked
* @property {string} [selector=.ad-container] jQuery selector of ad containers
* @property {function} [blocked=null] Function that fires when a container"s ads have been blocked
* @property {function} [complete=null] Function that fires after all ads have been checked for being blocked
*/

/**
* Waits for document.ready and then looks for ads matching a selector to see if any ads were blocked.
*
* @param {AdblockDetector~detect} opts Options
*/
AdblockDetector.detect = function(opts) {
var defaults = {
timeout: 3000,
selector: ".ad-container",
blocked: null,
complete: null
};

var options = $.extend({}, defaults, opts);

$(function() {
// wait a few ms for AdBlocker to kick in
setTimeout(function() {
var adsBlockedCount = 0;
var adCount = 0;

// find all matching ad containers
$(options.selector).each(function(i, element) {
adCount++;

if (AdblockDetector.hasAdsBlocked(element)) {
adsBlockedCount++;

if (options.blocked) {
options.blocked(element);
}
}
});

if (options.complete) {
options.complete(adCount, adsBlockedCount);
}
}, options.timeout);
});
};

//
// Export to the appropriate location
//
if (typeof define === "function" && define.amd) {
//
// AMD / RequireJS
//
define([], function() {
return AdblockDetector;
});
} else if (typeof root !== "undefined") {
//
// Browser Global
//
root.AdblockDetector = AdblockDetector;
}
}(typeof window !== "undefined" ? window : undefined));
Loading

0 comments on commit 3081d93

Please sign in to comment.