forked from stylish-userstyles/stylish-chrome
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathanalytics.js
More file actions
28 lines (26 loc) · 762 Bytes
/
Copy pathanalytics.js
File metadata and controls
28 lines (26 loc) · 762 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
var _gaq = _gaq || [];
_gaq.push(['_setAccount', 'UA-8246384-4']);
_gaq.push(['_trackPageview']);
function isAnalyticsEnabled() {
try {
return chrome.extension.getBackgroundPage().prefs.get("analyticsEnabled");
} catch (ex) {
console.log(ex);
return true;
}
}
// Prefs seems not available immediately
setTimeout(function() {
if (isAnalyticsEnabled()) {
(function() {
var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
ga.src = 'https://ssl.google-analytics.com/ga.js';
var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
})();
setInterval(function() {
if (isAnalyticsEnabled()) {
_gaq.push(['_trackPageview']);
}
}, 1000 * 60 * 60 * 24);
}
}, 1000);