Skip to content

Commit

Permalink
feat: bypass EasyList
Browse files Browse the repository at this point in the history
  • Loading branch information
SukkaW committed Jun 15, 2020
1 parent 63b6082 commit 56f54ee
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 4 deletions.
17 changes: 16 additions & 1 deletion README.md
Expand Up @@ -31,13 +31,28 @@ Just add those few lines of the code to your website, right before `</body>`. 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.
</script>
<script src="https://cdn.jsdelivr.net/npm/cfga@1.0.1" async></script>
<script src="https://cdn.jsdelivr.net/npm/cfga@1.0.2" async></script>
```

### 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
Expand Down
6 changes: 5 additions & 1 deletion cfga.js
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion cfga.min.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion 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": {
Expand Down

0 comments on commit 56f54ee

Please sign in to comment.