Skip to content

Commit

Permalink
Add GitHub
Browse files Browse the repository at this point in the history
  • Loading branch information
benjaminoakes committed Oct 19, 2023
1 parent da611d6 commit 3cff08c
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
<option value="mailto:{{selfEmail}}?subject={{title}}&body={{url}}">Email Self 馃こ</option>
<option value="mailto:{{workEmail}}?subject={{title}}&body={{url}}">Email Self at Work 馃彚</option>
<option value="mailto:{{spouseEmail}}?subject={{title}}&body={{url}}">Email Spouse 鉂わ笍</option>
<option value="https://github.com/{{githubPath}}?filename={{uuid}}.txt&value={{url}}">GitHub 馃悪</option>
<option value="https://www.instapaper.com/hello2?u={{url}}&t={{title}}">Instapaper 馃摪</option>
<option value="https://www.instapaper.com/text?u={{url}}">Instapaper Text 馃摉</option>
<option value="https://{{invidiousHost}}{{pathname}}{{search}}">Inviduious 鈻讹笍</option>
Expand All @@ -46,6 +47,8 @@
<form onsubmit="saveToLocalStorage(event)">
<label for="assistantEmail">Assistant email</label><br>
<input type="text" name="assistantEmail"><br>
<label for="githubPath">GitHub Path</label><br>
<input type="text" name="githubPath" placeholder="benjaminoakes/bookmarklets/new/main"><br>
<label for="kindleEmail">Kindle email</label><br>
<input type="text" name="kindleEmail"><br>
<p><a href="https://www.rememberthemilk.com/services/email/">Remember the Milk: How to add a task via email</a></p>
Expand Down Expand Up @@ -88,10 +91,14 @@
const title = searchParams.get("title")
const simpleTitle = title.split(/ [-|路] /)[0].replace(/\[[^\]]+\]/, '').trim()

let uuid
if ('crypto' in self) { uuid = crypto.randomUUID() }

const redirectUrl = event.target.value

const rewrittenUrl = redirectUrl.
replace("{{assistantEmail}}", encodeURIComponent(localStorage.assistantEmail)).
replace("{{githubPath}}", encodeURIComponent(localStorage.githubPath)).
replace("{{kindleEmail}}", encodeURIComponent(localStorage.kindleEmail)).
replace("{{rememberTheMilkInboxEmail}}", encodeURIComponent(localStorage.rememberTheMilkInboxEmail)).
replace("{{selfEmail}}", encodeURIComponent(localStorage.selfEmail)).
Expand All @@ -104,6 +111,7 @@
replace("{{pathname}}", parsedUrl.pathname).
replace("{{search}}", parsedUrl.search).
replace("{{url}}", encodeURIComponent(url)).
replace("{{uuid}}", uuid).
replace("{{rawUrl}}", url).
replace("{{simpleTitle}}", encodeURIComponent(simpleTitle)).
replace("{{title}}", encodeURIComponent(title))
Expand Down

0 comments on commit 3cff08c

Please sign in to comment.