This commit is contained in:
Cadey Ratio 2019-08-19 17:18:05 +00:00
parent 815638b2ed
commit d3e5482f3f
2 changed files with 7 additions and 11 deletions

View File

@ -12,7 +12,7 @@
(function() { (function() {
let dnt = navigator.doNotTrack; let dnt = navigator.doNotTrack;
if (dnt == "1") { if (dnt === "1") {
return; return;
} }
@ -20,15 +20,11 @@
function logTime() { function logTime() {
let stopTime = new Date(); let stopTime = new Date();
let message = JSON.stringify( window.navigator.sendBeacon("/api/pageview-timer", JSON.stringify({
{
"path": window.location.pathname, "path": window.location.pathname,
"start_time": startTime.toISOString(), "start_time": startTime.toISOString(),
"end_time": stopTime.toISOString(), "end_time": stopTime.toISOString()
} }));
);
window.navigator.sendBeacon("/api/pageview-timer", message);
} }
window.addEventListener("pagehide", logTime, false); window.addEventListener("pagehide", logTime, false);

View File

@ -76,7 +76,7 @@ function share_on_mastodon() {
var url = window.location.href; var url = window.location.href;
// get the page title from the og:title meta tag, if it exists. // get the page title from the og:title meta tag, if it exists.
var title = document.queryselectorall('meta[property="og:title"]')[0].getattribute("content"); var title = document.querySelectorAll('meta[property="og:title"]')[0].getattribute("content");
// Otherwise, use the <title> tag as the title // Otherwise, use the <title> tag as the title
if (!title) var title = document.getElementsByTagName("title")[0].innerHTML; if (!title) var title = document.getElementsByTagName("title")[0].innerHTML;