Created
August 28, 2023 16:33
-
-
Save mopa/6ee0a3e4824c7d60cd748c28e2d78d0a to your computer and use it in GitHub Desktop.
Revisions
-
mopa created this gist
Aug 28, 2023 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ javascript: (function () { const token = "TOKEN"; fetch("https://api.todoist.com/rest/v2/tasks", { method: "GET", headers: { Authorization: `Bearer ${token}`, }, }) .then((response) => { if (!response.ok) { throw new Error(`HTTP error! status: ${response.status}`); } return response.json(); }) .then(data => { item = data[Math.floor(Math.random()*data.length)]; window.location.href = item.url }) .catch((error) => { console.error("Error:", error); alert(`An error occurred: ${error.message}`); }); })();