diff --git a/README.md b/README.md index 681c23d..1b46335 100644 --- a/README.md +++ b/README.md @@ -31,13 +31,28 @@ Just add those few lines of the code to your website, right before ``. Do window.ga_tid = "UA-XXXXX-Y"; // {String} The trackerID of your site. window.ga_api = "https://example.com/xxx/"; // {String} The route of your cloudflare workers you just registered before. - + ``` ### 3. Watch this repo with `Releases Only`. Click the `watch` button at the top of the repo and choose `Releases Only`, so you can get notice of release update in time. +## Notice + +Recently `cloudflare-workers-async-google-analytics` has been blocked by [EasyList](https://github.com/easylist/easylist/commit/2ce2444193f5d479fb131e9dc89bbde9c82c8ad1). Great Job though. So I am going to play a cat & mouse game now. + +From `1.0.2` the random string will be added as a parameter to bypass EasyList. Also, this could help, too: + +- Add the route `cfga/jquery.js` for your Cloudflare Workers. +- Use setup as below: + +```js +window.ga_api = "https://example.com/cfga/jquery.js"; // {String} The route of your cloudflare workers you just registered before. +``` + +Block `jquery.js` if you can, haha! + ## Advanced ### Data type the `cfga.min.js` collected and sent diff --git a/cfga.js b/cfga.js index e7ea613..8ca3c8d 100755 --- a/cfga.js +++ b/cfga.js @@ -5,11 +5,15 @@ //min = Math.min, performance = window.performance, t = performance && performance.timing, - filterNumber = function (num) { return isNaN(num) || num == Infinity || num < 0 ? void 0 : num; }; + filterNumber = function (num) { return isNaN(num) || num == Infinity || num < 0 ? void 0 : num; }, + randomStr = function (num) { return Math.random().toString(36).slice(-num); }, + randomNum = function (num) { return Math.ceil(Math.random() * (num - 1)) + 1; }; // sendGA: collect data and send. function sendGA() { var pv_data = [ + // Random String against Easy Privacy + randomStr(randomNum(4)) + '=' + randomStr(randomNum(6)), // GA tid 'ga=' + window.ga_tid, // Title diff --git a/cfga.min.js b/cfga.min.js index 04840d6..900129c 100755 --- a/cfga.min.js +++ b/cfga.min.js @@ -1 +1 @@ -!function(t,e,n){var a=t.screen,r=encodeURIComponent,o=Math.max,i=t.performance,d=i&&i.timing,c=function(t){return isNaN(t)||t==1/0||t<0?void 0:t};function g(){var i=["ga="+t.ga_tid,"dt="+r(e.title),"de="+r(e.characterSet||e.charset),"dr="+r(e.referrer),"ul="+(n.language||n.browserLanguage||n.userLanguage),"sd="+a.colorDepth+"-bit","sr="+a.width+"x"+a.height,"vp="+o(e.documentElement.clientWidth,t.innerWidth||0)+"x"+o(e.documentElement.clientHeight,t.innerHeight||0),"plt="+c(d.loadEventStart-d.navigationStart||0),"dns="+c(d.domainLookupEnd-d.domainLookupStart||0),"pdt="+c(d.responseEnd-d.responseStart||0),"rrt="+c(d.redirectEnd-d.redirectStart||0),"tcp="+c(d.connectEnd-d.connectStart||0),"srt="+c(d.responseStart-d.requestStart||0),"dit="+c(d.domInteractive-d.domLoading||0),"clt="+c(d.domContentLoadedEventStart-d.navigationStart||0),"z="+Date.now()];t.__ga_img=new Image,t.__ga_img.src=t.ga_api+"?"+i.join("&")}"complete"===e.readyState?g():t.addEventListener("load",g)}(window,document,navigator); \ No newline at end of file +!function(t,e,n){var r=t.screen,a=encodeURIComponent,o=Math.max,i=t.performance,d=i&&i.timing,c=function(t){return isNaN(t)||t==1/0||t<0?void 0:t},g=function(t){return Math.random().toString(36).slice(-t)},m=function(t){return Math.ceil(Math.random()*(t-1))+1};function s(){var i=[g(m(4))+"="+g(m(6)),"ga="+t.ga_tid,"dt="+a(e.title),"de="+a(e.characterSet||e.charset),"dr="+a(e.referrer),"ul="+(n.language||n.browserLanguage||n.userLanguage),"sd="+r.colorDepth+"-bit","sr="+r.width+"x"+r.height,"vp="+o(e.documentElement.clientWidth,t.innerWidth||0)+"x"+o(e.documentElement.clientHeight,t.innerHeight||0),"plt="+c(d.loadEventStart-d.navigationStart||0),"dns="+c(d.domainLookupEnd-d.domainLookupStart||0),"pdt="+c(d.responseEnd-d.responseStart||0),"rrt="+c(d.redirectEnd-d.redirectStart||0),"tcp="+c(d.connectEnd-d.connectStart||0),"srt="+c(d.responseStart-d.requestStart||0),"dit="+c(d.domInteractive-d.domLoading||0),"clt="+c(d.domContentLoadedEventStart-d.navigationStart||0),"z="+Date.now()];t.__ga_img=new Image,t.__ga_img.src=t.ga_api+"?"+i.join("&")}"complete"===e.readyState?s():t.addEventListener("load",s)}(window,document,navigator); \ No newline at end of file diff --git a/package.json b/package.json index 01097c2..7c5d6b3 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "cfga", - "version": "1.0.1", + "version": "1.0.2", "description": "The Cloudflare Workers implementation of an async Google Analytics", "main": "cfga.min.js", "scripts": {