Ad tracking updates

main
Elbert Alias 7 years ago
parent 087fc5ed2b
commit 02e705a6c1

@ -203,7 +203,7 @@
break; break;
case 'ad_log': case 'ad_log':
w.adCache.push(message.subject); w.adCache.push(message.subject);
w.checkAdCache();
break; break;
case 'get_apps': case 'get_apps':
response = { response = {

@ -181,7 +181,7 @@ var exports = {};
video_assets: opt_video_assets, video_assets: opt_video_assets,
assets: opt_assets, assets: opt_assets,
version: '3', version: '3',
mrev: '9c4d5b3-c', mrev: 'a80971b-c',
msgNum: this.msgNum, msgNum: this.msgNum,
timestamp: new Date().getTime(), timestamp: new Date().getTime(),
pageVis: document.visibilityState, pageVis: document.visibilityState,
@ -890,7 +890,7 @@ var exports = {};
var _pageTags; var _pageTags;
var INIT_MS_BW_SEARCHES = 2000; var INIT_MS_BW_SEARCHES = 2000;
var PAGE_TAG_RE = new RegExp('gpt|oascentral'); var PAGE_TAG_RE = new RegExp('gpt|oascentral');
var POST_MSG_ID = '1490888598-28717-31700-14775-21098'; var POST_MSG_ID = '1498662251-16965-9321-27566-5783';
var AD_SERVER_RE = new RegExp('^(google_ads_iframe|oas_frame|atwAdFrame)'); var AD_SERVER_RE = new RegExp('^(google_ads_iframe|oas_frame|atwAdFrame)');
function getPageTags(doc) { function getPageTags(doc) {

@ -114,9 +114,20 @@
} }
} }
function isTrackingEnabled() { function ifTrackingEnabled(ifCallback, elseCallback) {
return parseInt(localStorage.tracking, 10); browser.storage.local.get('tracking').then(function(item) {
if ( item.hasOwnProperty('tracking') ) {
if ( item.tracking ) {
ifCallback();
} else {
elseCallback();
}
} else {
ifCallback();
}
});
} }
@ -195,18 +206,21 @@
var tabId = details.tabId; var tabId = details.tabId;
this.cleanupCollector(tabId); this.cleanupCollector(tabId);
if ( isTrackingEnabled() ) { ifTrackingEnabled(
function() {
if ( !areListenersRegistered ) { if ( !areListenersRegistered ) {
registerListeners(); registerListeners();
} }
this.collectors[tabId] = new PageNetworkTrafficCollector(tabId); this.collectors[tabId] = new PageNetworkTrafficCollector(tabId);
} else { }.bind(this),
function() {
if ( areListenersRegistered ) { if ( areListenersRegistered ) {
unregisterListeners(); unregisterListeners();
} }
} }
);
}, },
onNavigationCommitted: function(details) { onNavigationCommitted: function(details) {
@ -777,8 +791,16 @@
browserProxy.runtime.onMessage.addListener(function(request, sender, sendResponse) { browserProxy.runtime.onMessage.addListener(function(request, sender, sendResponse) {
if ( request === 'is_tracking_enabled' ) { if ( request === 'is_tracking_enabled' ) {
sendResponse({'tracking_enabled': isTrackingEnabled()}); ifTrackingEnabled(
function() {
sendResponse({'tracking_enabled': true});
},
function() {
sendResponse({'tracking_enabled': false});
}
);
} }
return true;
}); });
})(); })();

@ -367,6 +367,12 @@ var wappalyzer = (function() {
} }
}, },
checkAdCache: function() {
if ( Object.keys(w.ping.hostnames).length >= 50 || w.adCache.length >= 50 ) {
driver('ping');
}
},
/** /**
* Track detected applications * Track detected applications
*/ */
@ -404,10 +410,7 @@ var wappalyzer = (function() {
w.ping.hostnames[hostname].meta['language'] = match[1]; w.ping.hostnames[hostname].meta['language'] = match[1];
} }
} }
w.checkAdCache();
if ( Object.keys(w.ping.hostnames).length >= 50 || w.adCache.length >= 50 ) {
driver('ping');
}
}, },
/** /**
@ -452,7 +455,7 @@ var wappalyzer = (function() {
patterns.forEach(function(pattern) { patterns.forEach(function(pattern) {
var match; var match;
while ( match = regex.exec(html) ) { while ( (match = regex.exec(html)) ) {
if ( pattern.regex.test(match[2]) ) { if ( pattern.regex.test(match[2]) ) {
app.setDetected(pattern, 'script', match[2]); app.setDetected(pattern, 'script', match[2]);
} }
@ -471,7 +474,7 @@ var wappalyzer = (function() {
patterns = parsePatterns(w.apps[app.app].meta); patterns = parsePatterns(w.apps[app.app].meta);
if ( patterns ) { if ( patterns ) {
while ( match = regex.exec(html) ) { while ( (match = regex.exec(html)) ) {
for ( meta in patterns ) { for ( meta in patterns ) {
if ( new RegExp('(name|property)=["\']' + meta + '["\']', 'i').test(match) ) { if ( new RegExp('(name|property)=["\']' + meta + '["\']', 'i').test(match) ) {
content = match.toString().match(/content=("|')([^"']+)("|')/i); content = match.toString().match(/content=("|')([^"']+)("|')/i);

Loading…
Cancel
Save