Last active
January 8, 2026 05:48
-
-
Save hogashi/609dd741547a98b6dd91deaf405bc7ea to your computer and use it in GitHub Desktop.
asana-date-word-to-abs / asanaの日付を示す単語表記がまざるのわかりづらいので絶対日付に揃えるUserScript
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 characters
| // ==UserScript== | |
| // @name asana-date-word-to-abs | |
| // @description asanaの日付を示す単語表記がまざるのわかりづらいので絶対日付に揃えるUserScript | |
| // @version 2026-01-08 | |
| // @author hogashi | |
| // @match https://app.asana.com/* | |
| // @grant none | |
| // ==/UserScript== | |
| (function() { | |
| 'use strict'; | |
| let timer; | |
| let count = 0; | |
| const main = () => { | |
| count += 1; | |
| if (count > 3) { | |
| clearInterval(timer); | |
| } | |
| // 'Monday' とか書かれてるの分かりづらいので, 絶対日時 ('Jan 8' など) にする | |
| const dues = document.querySelectorAll('.DueDate-noWrapSegment'); | |
| const nowdt = new Date(); | |
| const nowday = nowdt.getDay(); | |
| console.log({ dues }); | |
| const dayStrToDay = { | |
| Sunday: 0, | |
| Monday: 1, | |
| Tuesday: 2, | |
| Wednesday: 3, | |
| Thursday: 4, | |
| Friday: 5, | |
| Saturday: 6, | |
| }; | |
| dues.forEach((due) => { | |
| // 'Monday' | 'Tuesday' | 'Wednesday' | 'Thursday' | 'Friday' | 'Saturday' | 'Sunday' | 'Yesterday' | 'Today' | 'Tomorrow' | |
| const text = due.textContent || ''; | |
| const day = dayStrToDay[text]; | |
| // 'Yesterday', 'Today', 'Tomorrow' の場合は今の日時から相対的に計算する | |
| // 曜日の場合は今の日時から次のその曜日を計算する | |
| let offset = 0; | |
| if (day === undefined) { | |
| if (text === 'Yesterday') { | |
| offset = -1; | |
| } else if (text === 'Today') { | |
| offset = 0; | |
| } else if (text === 'Tomorrow') { | |
| offset = 1; | |
| } else { | |
| // 不明な文字列 | |
| return; | |
| } | |
| } else { | |
| offset = day - nowday; | |
| if (offset <= 0) { | |
| offset += 7; | |
| } | |
| } | |
| const dueDate = new Date(); | |
| dueDate.setDate(nowdt.getDate() + offset); | |
| const month = dueDate.getMonth() + 1; | |
| const date = dueDate.getDate(); | |
| // 'Jan 8' 形式に変換 | |
| const monthStr = dueDate.toLocaleString('en-US', { month: 'short' }); | |
| const newText = `${monthStr} ${date}`; | |
| due.textContent = newText; | |
| }); | |
| }; | |
| // ページ読み込み完了したあとにタスクが読み込まれるので, 数秒おきに何回かやる | |
| timer = setInterval(main, 2000); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment