Skip to content

Instantly share code, notes, and snippets.

@hushin
Created September 10, 2024 11:33
Show Gist options
  • Save hushin/133b38e9a8a6050655143cbbe0dae269 to your computer and use it in GitHub Desktop.
Save hushin/133b38e9a8a6050655143cbbe0dae269 to your computer and use it in GitHub Desktop.
Googleのマイアクティビティを日付指定で開く
function generateMyActivityURLJST(date) {
const startDate = new Date(`${date}T00:00:00+09:00`);
const endDate = new Date(`${date}T23:59:59+09:00`);
// ミリ秒単位のタイムスタンプをマイクロ秒に変換
const min = startDate.getTime() * 1000;
const max = endDate.getTime() * 1000 + 999999;
// Google My Activity の URL を生成
const url = `https://myactivity.google.com/myactivity?min=${min}&max=${max}`;
return url;
}
const url = generateMyActivityURLJST('2024-09-05');
location.assign(url);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment