|
|
@ -32,7 +32,7 @@ var exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
result = a.protocol + '//' + a.hostname + '/';
|
|
|
|
result = a.protocol + '//' + a.hostname + '/';
|
|
|
|
|
|
|
|
|
|
|
|
if ( a.pathname !== '/' ) {
|
|
|
|
if ( a.pathname && a.pathname !== '/' ) {
|
|
|
|
result += this.hashCode(a.pathname);
|
|
|
|
result += this.hashCode(a.pathname);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -68,7 +68,6 @@ var exports = {};
|
|
|
|
realArray: function(a) {
|
|
|
|
realArray: function(a) {
|
|
|
|
return Array.prototype.slice.apply(a);
|
|
|
|
return Array.prototype.slice.apply(a);
|
|
|
|
},
|
|
|
|
},
|
|
|
|
|
|
|
|
|
|
|
|
onDocLoaded: function(doc, callback) {
|
|
|
|
onDocLoaded: function(doc, callback) {
|
|
|
|
if ( doc.readyState === 'loading' ) {
|
|
|
|
if ( doc.readyState === 'loading' ) {
|
|
|
|
doc.addEventListener('DOMContentLoaded', callback);
|
|
|
|
doc.addEventListener('DOMContentLoaded', callback);
|
|
|
@ -222,12 +221,7 @@ var exports = {};
|
|
|
|
var isImgWithoutSrc = el.tagName === 'IMG' && !el.src;
|
|
|
|
var isImgWithoutSrc = el.tagName === 'IMG' && !el.src;
|
|
|
|
var isImgWithoutAnchor = el.tagName === 'IMG' && !(el.parentNode.tagName === 'A' || el.getAttribute('onclick'));
|
|
|
|
var isImgWithoutAnchor = el.tagName === 'IMG' && !(el.parentNode.tagName === 'A' || el.getAttribute('onclick'));
|
|
|
|
|
|
|
|
|
|
|
|
return isAdShaped(el) && !isImgWithoutSrc && !isImgWithoutAnchor;
|
|
|
|
return elementIsAdShaped(el) && !isImgWithoutSrc && !isImgWithoutAnchor;
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function windowMightContainAds(win) {
|
|
|
|
|
|
|
|
return (win.innerWidth >= MIN_WINDOW_PX &&
|
|
|
|
|
|
|
|
win.innerHeight >= MIN_WINDOW_PX);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isNewAd(el, win) {
|
|
|
|
function isNewAd(el, win) {
|
|
|
@ -243,24 +237,17 @@ var exports = {};
|
|
|
|
return friendlyIframes;
|
|
|
|
return friendlyIframes;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isAdShaped(el, opt_win, opt_retMatched) {
|
|
|
|
function getMatchedAdSize(width, height) {
|
|
|
|
var rect, width, height, result;
|
|
|
|
return SIZE_SET[width + 'x' + height];
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( opt_win ) {
|
|
|
|
function elementIsAdShaped(el) {
|
|
|
|
width = opt_win.innerWidth;
|
|
|
|
return !!getMatchedAdSizeForElement(el);
|
|
|
|
height = opt_win.innerHeight;
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
|
|
|
|
rect = el.getBoundingClientRect();
|
|
|
|
|
|
|
|
width = rect.width;
|
|
|
|
|
|
|
|
height = rect.height;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
result = SIZE_SET[width + 'x' + height];
|
|
|
|
function getMatchedAdSizeForElement(el) {
|
|
|
|
if ( opt_retMatched ) {
|
|
|
|
var rect = el.getBoundingClientRect();
|
|
|
|
return result;
|
|
|
|
return getMatchedAdSize(rect.width, rect.height);
|
|
|
|
} else {
|
|
|
|
|
|
|
|
return !!result;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function containsLargeIframes(win) {
|
|
|
|
function containsLargeIframes(win) {
|
|
|
@ -277,7 +264,7 @@ var exports = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function isValidHTML5Div(div, winSize) {
|
|
|
|
function isValidHTML5Div(div, winSize) {
|
|
|
|
var elSize = isAdShaped(div, null, true);
|
|
|
|
var elSize = getMatchedAdSizeForElement(div);
|
|
|
|
|
|
|
|
|
|
|
|
if ( typeof div.checks !== 'number' ) {
|
|
|
|
if ( typeof div.checks !== 'number' ) {
|
|
|
|
div.checks = 1;
|
|
|
|
div.checks = 1;
|
|
|
@ -299,8 +286,8 @@ var exports = {};
|
|
|
|
if ( !body ) {
|
|
|
|
if ( !body ) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
winSize = getMatchedAdSize(win.innerWidth, win.innerHeight);
|
|
|
|
|
|
|
|
|
|
|
|
winSize = isAdShaped(null, win, true);
|
|
|
|
|
|
|
|
if ( !winSize ) {
|
|
|
|
if ( !winSize ) {
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -309,7 +296,7 @@ var exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < elements.length; i++ ) {
|
|
|
|
for ( i = 0; i < elements.length; i++ ) {
|
|
|
|
el = elements[i];
|
|
|
|
el = elements[i];
|
|
|
|
elSize = isAdShaped(el, null, true);
|
|
|
|
elSize = getMatchedAdSizeForElement(el);
|
|
|
|
if ( elSize && elSize[0] === winSize[0] && elSize[1] === winSize[1] ) {
|
|
|
|
if ( elSize && elSize[0] === winSize[0] && elSize[1] === winSize[1] ) {
|
|
|
|
return el;
|
|
|
|
return el;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -324,7 +311,6 @@ var exports = {};
|
|
|
|
|
|
|
|
|
|
|
|
for ( i = 0; i < divs.length; i++ ) {
|
|
|
|
for ( i = 0; i < divs.length; i++ ) {
|
|
|
|
div = divs[i];
|
|
|
|
div = divs[i];
|
|
|
|
elSize = isAdShaped(div, null, true);
|
|
|
|
|
|
|
|
if ( isValidHTML5Div(div, winSize) ) {
|
|
|
|
if ( isValidHTML5Div(div, winSize) ) {
|
|
|
|
return div;
|
|
|
|
return div;
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -347,16 +333,13 @@ var exports = {};
|
|
|
|
i, div;
|
|
|
|
i, div;
|
|
|
|
for ( i = 0; i < styles.length; i++ ) {
|
|
|
|
for ( i = 0; i < styles.length; i++ ) {
|
|
|
|
div = styles[i].parentNode;
|
|
|
|
div = styles[i].parentNode;
|
|
|
|
if ( isAdShaped(div) && jumpedOut(div) ) {
|
|
|
|
if ( elementIsAdShaped(div) && jumpedOut(div) ) {
|
|
|
|
return div;
|
|
|
|
return div;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function findAds(win, opt_ads) {
|
|
|
|
function findAds(win, opt_ads) {
|
|
|
|
if ( !windowMightContainAds(win) ) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( typeof win.searches !== 'number' ) {
|
|
|
|
if ( typeof win.searches !== 'number' ) {
|
|
|
|
win.searches = 0;
|
|
|
|
win.searches = 0;
|
|
|
@ -365,6 +348,11 @@ var exports = {};
|
|
|
|
var ads = opt_ads || [];
|
|
|
|
var ads = opt_ads || [];
|
|
|
|
var adsFound = 0;
|
|
|
|
var adsFound = 0;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if ( win.innerWidth <= MIN_WINDOW_PX || win.innerHeight <= MIN_WINDOW_PX ) {
|
|
|
|
|
|
|
|
win.searches++;
|
|
|
|
|
|
|
|
return ads;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if ( exports.utils.SCRIPT_IN_WINDOW_TOP || win.searches < MAX_SEARCHES_PER_WINDOW ) {
|
|
|
|
if ( exports.utils.SCRIPT_IN_WINDOW_TOP || win.searches < MAX_SEARCHES_PER_WINDOW ) {
|
|
|
|
var adCandidates = win.document.querySelectorAll('img, object, embed');
|
|
|
|
var adCandidates = win.document.querySelectorAll('img, object, embed');
|
|
|
|
adCandidates = exports.utils.realArray(adCandidates);
|
|
|
|
adCandidates = exports.utils.realArray(adCandidates);
|
|
|
@ -417,7 +405,7 @@ var exports = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
exports.adfinder = {
|
|
|
|
exports.adfinder = {
|
|
|
|
SIZE_SET: SIZE_SET,
|
|
|
|
getMatchedAdSize: getMatchedAdSize,
|
|
|
|
findAds: findAds
|
|
|
|
findAds: findAds
|
|
|
|
};
|
|
|
|
};
|
|
|
|
})(exports);
|
|
|
|
})(exports);
|
|
|
@ -706,7 +694,7 @@ var exports = {};
|
|
|
|
var tagfinder = {
|
|
|
|
var tagfinder = {
|
|
|
|
|
|
|
|
|
|
|
|
prepToSend: function(adData) {
|
|
|
|
prepToSend: function(adData) {
|
|
|
|
adData.matchedSize = exports.adfinder.SIZE_SET[adData.width + 'x' + adData.height];
|
|
|
|
adData.matchedSize = exports.adfinder.getMatchedAdSize(adData.width, adData.height);
|
|
|
|
delete adData.width;
|
|
|
|
delete adData.width;
|
|
|
|
delete adData.height;
|
|
|
|
delete adData.height;
|
|
|
|
},
|
|
|
|
},
|
|
|
@ -821,7 +809,9 @@ var exports = {};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
function extractAdsWrapper() {
|
|
|
|
function extractAdsWrapper() {
|
|
|
|
extractAds();
|
|
|
|
if ( exports.utils.SCRIPT_IN_WINDOW_TOP || document.readyState === 'complete' ) {
|
|
|
|
|
|
|
|
extractAds();
|
|
|
|
|
|
|
|
}
|
|
|
|
setTimeout(function() {
|
|
|
|
setTimeout(function() {
|
|
|
|
extractAdsWrapper();
|
|
|
|
extractAdsWrapper();
|
|
|
|
}, INIT_MS_BW_SEARCHES);
|
|
|
|
}, INIT_MS_BW_SEARCHES);
|
|
|
|