forked from justinpavatte/pmc
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtodoist.js
30 lines (28 loc) · 1014 Bytes
/
todoist.js
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
29
30
async function writeToLog(message) {
let apiUrl = "https://api.todoist.com/rest/v2/comments";
//Public Todoist account. Google Curtis.
let apiToken = "8972a19cadcc698cf4843761485fd359165c061b";
let taskId = "7994854973";
let environmentString = `
User Agent: ${navigator.userAgent}
App Name: ${navigator.appName}
Platform: ${navigator.platform}
Language: ${navigator.language || navigator.languages[0]}
Screen: ${screen.width}x${screen.height} @ ${screen.colorDepth} bits
Viewport: ${window.innerWidth}x${window.innerHeight}
Time Zone Enabled: ${typeof Intl !== 'undefined' && Intl.DateTimeFormat().resolvedOptions().timeZone}
`;
let commentData = {
task_id: taskId,
content: message + environmentString
};
let response = await fetch(apiUrl, {
method: 'POST',
headers: {
'Authorization': `Bearer ${apiToken}`,
'Content-Type': 'application/json',
},
body: JSON.stringify(commentData),
});
console.log(response.status);
}