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
| window.extensions = { | |
| ...(window.extensions || {}), | |
| notifyMe: { | |
| create: function (message, timeString) { | |
| const [hours, minutes] = timeString.split(":"); | |
| const now = new Date(); | |
| const time = new Date(now.getFullYear(), now.getMonth(), now.getDate(), hours, minutes); | |
| if (now > time) { | |
| throw new Error("Time must be in the future"); | |
| } |
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
| function helloWorld() { | |
| console.log("hello world!"); | |
| } |
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
| // Move day of week starting index from Sunday to Monday | |
| let f = idx => (idx + 6)%7 | |
| for(const [i, dow] of Object.entries(["S", "M", "T", "W", "Th", "F", "S"])) { | |
| console.log(`${dow} ${i} → ${f(parseInt(i))}`) | |
| } | |
| // Get month | |
| function getMonthString(d = new Date()) { | |
| const monthNames = ["January", "February", "March", "April", "May", "June", | |
| "July", "August", "September", "October", "November", "December" |
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
| function createWorkSessionReminder() { | |
| let Reminders = Application('Reminders'); | |
| let app = Application.currentApplication() | |
| app.includeStandardAdditions = true | |
| let now = new Date() | |
| // Set start time to now | |
| let startTime = `${now.getHours()}:${now.getMinutes()}` | |
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
| /** | |
| * Returns the corresponding date suffix | |
| * @param {number} d Day of the month | |
| * @returns Date suffix | |
| */ | |
| function getDateSuffix(d) { | |
| lastDigit = d % 10 | |
| if (d >= 11 && d <= 13) { | |
| return "th" | |
| } else if (lastDigit === 1) { |
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
| function clozifySelectedText() { | |
| var txtArea = document.activeElement; | |
| if (txtArea.selectionStart != undefined) { | |
| var startPos = txtArea.selectionStart; | |
| var endPos = txtArea.selectionEnd; | |
| selectedText = txtArea.value.substring(startPos, endPos); | |
| clozifiedText = txtArea.value.slice(0, startPos) + '[[{]]' + selectedText + '[[}]]' + txtArea.value.slice(endPos); | |
| var valueSetter = Object.getOwnPropertyDescriptor(window.HTMLTextAreaElement.prototype, "value").set; | |
| valueSetter.call(txtArea, clozifiedText); |
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
| var url = document.URL; | |
| var title = url.split("/").pop().replace(/#.*/,"").replace("_"," "); | |
| var range = window.getSelection().getRangeAt(0); | |
| var selectionContents = range.cloneContents(); | |
| var selectionNodes = selectionContents.childNodes; | |
| // Convert hyperlinks to Roam references | |
| var selection = ""; | |
| selectionNodes.forEach((node) => { | |
| if (node.nodeName=="B") { |
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
| /* Hide query title and page titles in query*/ | |
| .rm-query-title, .rm-title-arrow-wrapper{ | |
| display:none!important; | |
| } | |
| /* Hide page mentions in an article (can still get in sidebar) */ | |
| .roam-article .rm-reference-main{ | |
| display:none; | |
| } |