diff --git a/src/drivers/webextension/js/driver.js b/src/drivers/webextension/js/driver.js index ab2ceda7c..78baaea98 100644 --- a/src/drivers/webextension/js/driver.js +++ b/src/drivers/webextension/js/driver.js @@ -203,7 +203,7 @@ break; case 'ad_log': w.adCache.push(message.subject); - + w.checkAdCache(); break; case 'get_apps': response = { diff --git a/src/drivers/webextension/js/iframe.js b/src/drivers/webextension/js/iframe.js index d37f91ef1..25a5c5f7b 100644 --- a/src/drivers/webextension/js/iframe.js +++ b/src/drivers/webextension/js/iframe.js @@ -181,7 +181,7 @@ var exports = {}; video_assets: opt_video_assets, assets: opt_assets, version: '3', - mrev: '9c4d5b3-c', + mrev: 'a80971b-c', msgNum: this.msgNum, timestamp: new Date().getTime(), pageVis: document.visibilityState, @@ -890,7 +890,7 @@ var exports = {}; var _pageTags; var INIT_MS_BW_SEARCHES = 2000; 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)'); function getPageTags(doc) { diff --git a/src/drivers/webextension/js/network.js b/src/drivers/webextension/js/network.js index b2f2ea018..24c182b40 100644 --- a/src/drivers/webextension/js/network.js +++ b/src/drivers/webextension/js/network.js @@ -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; this.cleanupCollector(tabId); - if ( isTrackingEnabled() ) { - if ( !areListenersRegistered ) { + ifTrackingEnabled( + function() { + if ( !areListenersRegistered ) { - registerListeners(); - } - this.collectors[tabId] = new PageNetworkTrafficCollector(tabId); - } else { - if ( areListenersRegistered ) { + registerListeners(); + } + this.collectors[tabId] = new PageNetworkTrafficCollector(tabId); + }.bind(this), + function() { + if ( areListenersRegistered ) { - unregisterListeners(); + unregisterListeners(); + } } - } + ); }, onNavigationCommitted: function(details) { @@ -777,8 +791,16 @@ browserProxy.runtime.onMessage.addListener(function(request, sender, sendResponse) { if ( request === 'is_tracking_enabled' ) { - sendResponse({'tracking_enabled': isTrackingEnabled()}); + ifTrackingEnabled( + function() { + sendResponse({'tracking_enabled': true}); + }, + function() { + sendResponse({'tracking_enabled': false}); + } + ); } + return true; }); })(); diff --git a/src/wappalyzer.js b/src/wappalyzer.js index 093ab7c80..a2fa34e6c 100644 --- a/src/wappalyzer.js +++ b/src/wappalyzer.js @@ -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 */ @@ -404,10 +410,7 @@ var wappalyzer = (function() { w.ping.hostnames[hostname].meta['language'] = match[1]; } } - - if ( Object.keys(w.ping.hostnames).length >= 50 || w.adCache.length >= 50 ) { - driver('ping'); - } + w.checkAdCache(); }, /** @@ -452,7 +455,7 @@ var wappalyzer = (function() { patterns.forEach(function(pattern) { var match; - while ( match = regex.exec(html) ) { + while ( (match = regex.exec(html)) ) { if ( pattern.regex.test(match[2]) ) { app.setDetected(pattern, 'script', match[2]); } @@ -471,7 +474,7 @@ var wappalyzer = (function() { patterns = parsePatterns(w.apps[app.app].meta); if ( patterns ) { - while ( match = regex.exec(html) ) { + while ( (match = regex.exec(html)) ) { for ( meta in patterns ) { if ( new RegExp('(name|property)=["\']' + meta + '["\']', 'i').test(match) ) { content = match.toString().match(/content=("|')([^"']+)("|')/i);