-
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
New: Make tracking from domains with subdomains possible
- Loading branch information
Showing
7 changed files
with
72 additions
and
42 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,34 @@ | ||
function setCookie() { | ||
// cookie will die in +100 years from now | ||
// 1 * 60 * 60 * 24 * 365 * 100 = 31536000000 | ||
cookie(31536000000); | ||
} | ||
|
||
function deleteCookie() { | ||
cookie(-1); | ||
} | ||
|
||
function cookie(maxAge) { | ||
var domain = document.location.host.split(".").slice(-2).join("."); | ||
document.cookie = "disabledPlausible=true; SameSite=Lax; path=/; max-age=" + maxAge + "; domain=" + domain; | ||
} | ||
(function () { | ||
window.setCookie = function () { | ||
// cookie will die in +100 years from now | ||
// 1 * 60 * 60 * 24 * 365 * 100 = 31536000000 | ||
cookie(31536000000); | ||
}; | ||
|
||
window.deleteCookie = function () { | ||
cookie(-1); | ||
}; | ||
|
||
var host = document.location.host; | ||
var mainDomain = host.split(".").slice(-2).join("."); | ||
var value = "disabledPlausible=true"; | ||
|
||
function set(maxAge, domain) { | ||
document.cookie = value + "; SameSite=Lax; path=/; max-age=" + maxAge + "; domain=" + domain; | ||
} | ||
|
||
function check(maxAge) { | ||
var isSet = document.cookie.indexOf(value) !== -1; | ||
var shouldBeSet = maxAge !== -1; | ||
if ((shouldBeSet && !isSet) || (!shouldBeSet && isSet)) { | ||
set(maxAge, host); | ||
} | ||
} | ||
|
||
function cookie(maxAge) { | ||
set(maxAge, mainDomain); | ||
if (host != mainDomain) { | ||
check(maxAge); | ||
} | ||
} | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters