Last active
December 10, 2022 12:07
-
-
Save titangene/a78042ba5f86e526f5ef9c72ebccc966 to your computer and use it in GitHub Desktop.
複製 Google Maps 地點的營業時間
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
| (() => { | |
| const weekList = { '一': 0, '二': 1, '三': 2, '四': 3, '五': 4, '六': 5, '日': 6 }; | |
| const result = document.querySelector('[role="region"] .fontBodyMedium > [role="button"] + [aria-label]') | |
| .getAttribute('aria-label') | |
| .replace('. 隱藏本週營業時間', '') | |
| .split('; ') | |
| .map(item => { | |
| const [fullWeek, ...openHours] = item.split('、'); | |
| return { | |
| week: fullWeek[2], | |
| openHours: openHours.map(x => x.replaceAll('到', '-')).join('、') | |
| }; | |
| }) | |
| .sort((a, b) => weekList[a.week] - weekList[b.week]) | |
| .map(({week, openHours}) => `${week}:${openHours}`) | |
| .join('\n'); | |
| const textArea = document.createElement('textarea'); | |
| textArea.value = result; | |
| document.body.appendChild(textArea); | |
| textArea.select(); | |
| document.execCommand('Copy'); | |
| textArea.remove(); | |
| })(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment