Created
December 7, 2021 21:06
-
-
Save mint149/cee3316ea88577c2202587274fdc90c1 to your computer and use it in GitHub Desktop.
plsk.netに上げたメモをデイリーノートに取り込むスクリプト。(iOSのScriptableアプリを使用)
This file contains 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 iCloud = FileManager.iCloud(); | |
const vaultPath = iCloud.bookmarkedPath('hatopedia'); | |
const dailyNoteName = `${formatDate(new Date())}.md`; | |
const dailyNotePath = `${vaultPath}/Daily Notes/${dailyNoteName}`; | |
console.log(`Target:${dailyNoteName}`); | |
if (!iCloud.fileExists(dailyNotePath)) { | |
console.log('No daily note.'); | |
Script.complete(); | |
return; | |
} | |
console.log('Daily note exist.'); | |
const plsk = new WebView(); | |
await plsk.loadURL('http://plsk.net/nankatekitounayatsu'); | |
const memoGetJs = 'document.getElementById("txt").innerHTML'; | |
const plskString = await plsk.evaluateJavaScript(memoGetJs, false); | |
console.log(plskString); | |
const dailyNoteString = iCloud.readString(dailyNotePath); | |
const connectedString = dailyNoteString + '\n' + plskString; | |
iCloud.writeString(dailyNotePath, connectedString); | |
Script.complete(); | |
return; | |
// 引用:https://qiita.com/toshimin/items/5f13c3b4c28825219231 | |
function formatDate(dt) { | |
var y = dt.getFullYear(); | |
var m = ('00' + (dt.getMonth() + 1)).slice(-2); | |
var d = ('00' + dt.getDate()).slice(-2); | |
return (y + '-' + m + '-' + d); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment